Skip to content
Ultra powered gist embedding for your website
Branch: master
Clone or download
Latest commit e8646e7 Jan 18, 2018
Type Name Latest commit message Commit time
Failed to load latest commit information.
LICENSE Remove the template tags Oct 22, 2014 Update Jan 18, 2018
package.json Update script version and package version and make it meet semver for… Nov 21, 2016

How to use gist-embed to spice up code snippets on your blog

Include jQuery and gist-embed src:

    <script type="text/javascript" src=""></script>
    <script type="text/javascript" src=""></script>

Add an HTML element to your page with a data attribute in the following format, where <gist-id> should be replaced with the id of your gist:

  <code data-gist-id="<gist-id>"></code>

Other ways to use gist-embed

Ruby Gem

@itsNikolay Has created an easy to use ruby gem for gist-embed, you can find it here:


@pasupulaphani Has created a small library to ease the use of gist-embed in your angular projects:


See for all possible ways to use gist-embed:

  • Including a single gist
  • Including individual files from a gist
  • Including specific line numbers from a gist
  • Including specific line numbers from a gist and collapse the others
  • Add a caption (filename for example) to a gist
  • Removing all line numbers from a gist
  • Removing the footer from a gist
  • Highlight lines from a gist


How do I configure line numbers?

  • You can put a single number like "1", a range like "2-5", single line numbers separated with commas like "11,20", or a mix of both like "2-5,11,10-14,20". If you would like to collapse the others instead of hiding them, use the data-gist-lines-expanded="true" option.

Why does my gist-embed have incorrect styling?

  • It may be because the HTML element you are using has pre-existing styles either from the native browser or from a stylesheet include that you don't have control over.
  • You can avoid this by using a generic HTML element such as div instead of code as version 1.4 now targets all elements that have a data-gist-id attribute regardless of their tag name.

How do I highlight line numbers?

  • Use the same pattern for line numbers as data-gist-line, but use the attribute data-gist-highlight-line

Change log

Version 2.7.1 (Jan 18, 2018)

Version 2.7.0 (Jan 17, 2018)

Version 2.6 (Sep 4, 2016)

Version 2.5 (July 6, 2015)

Version 2.4 (Oct 13, 2015)

Version 2.3 (Sep 22, 2015)

Version 2.2 (July 20, 2015)

Version 2.1 (Feb 6, 2015)

  • You can now add data-gist-show-loading="false" to prevent the "Loading..." text from showing when the gist is created.

Version 2.0 (Aug 15, 2014)

  • Merged #29 from steinwaywhw to remove the bottom border when the footer is hidden. Thanks steinwaywhw!

Version 1.9 (July 21, 2014)

  • Merged #25 from scottdorman to use to parse data attributes instead of jQuery.attr. This provides compatibility with knockout bindings. Thanks scottdorman!

Version 1.8 (June 16, 2014)

  • Merged #22 from miguelvps to expose gist-embed as a jQuery plugin. Now you can add new gist-embed elements after the page has loaded. Thanks miguelvps!

Version 1.7 (March 28, 2014)

Version 1.6 (Dec 22, 2013)

  • Allow private gists by not checking the type of id passed in as private gists can start with letters or numbers
  • Print error statement to html for easier debugging

Version 1.5 (Dec 11, 2013)

Version 1.4 (Dec 2, 2013)

  • Changed to use $("[data-gist-id]") as a more general selector that works with any element, not just code tags. Performance should not be affected:

Version 1.3 (July 17, 2013)

  • Github changed their stylesheet property to be relative instead of absolute. Updated gist-embed accordingly to allow for these kinds of changes in the future.

Version 1.2 (March 22, 2013)

  • Breaking change:
    • Removed code elements with id attributes of gist- from being parsed. You must use data-gist-id and specify an integer specifying the id of your gist.
    • Do not use gist- for the value of data-gist-id, only the value of the gist id is needed.
    • Rewrote the data attribute names. Now all attributes are using a data-gist- namespace for all attributes. Please see example.html for options.
    • Do not point directly to gist-embed from github. Host your own version so that if breaking changes are introduced, your websites won't be affected.

Version 1.1 (March 20, 2013)

  • Breaking change:
  • Using the id attribute of your code element to specify the gist id is no longer accepted. You must now use a data attribute to specify the gist id. See above for an example.
  • The reason for this change is that it is not proper HTML markup to have multiple DOM elements with the same id attribute on the same page and that it could lead to conflicts when including the same gist in multiple areas.
  • For the meantime, I will allow for both methods so anyone using this code from github directly won't have broken gists on their page. I plan to deprecate this in the next month.
  • Other changes:
  • Cleaned up example.html to include all possible ways to use gist-embed.
  • Thanks to for providing a way to remove the gist footer, remove all line numbers, and specify line number ranges.
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.