Embedding Gists with Jekyll on GitHub Pages
Github gists can be embedded into Jekyll pages using the gist
tag.
Configuring Jekyll
Follow the installation guide indicated here. The steps are listed here for reference just in case.
Steps are as follows:
-
Append
jekyll-gist
to yourGemfile
.gem 'jekyll-gist'
-
Add the package to the
_config.yml
file .plugins: - jekyll-gist
Adding the Gist to the Post
Now we can embed existing Gists using the gist
Liquid template tag and the gist ID.
Use the tag as follows in your Jekyll pages, posts and collections:
Basic syntax:
{% gist <gist_id> <optional_file_name> %}
Use example:
{% gist c08ee0f2726fd0e3909d %}
This will create the following script tag:
<script src="https://gist.github.com/parkr/c08ee0f2726fd0e3909d.js"> </script>
You may optionally specify a filename
after the gist_id
:
{% gist c08ee0f2726fd0e3909d test.md %}
This will produce the correct URL to show just the specified file in your post rather than the entire Gist.
It will be rendered as
References:
https://w0lfram1te.com/embedding-gists-with-jekyll-and-github-pages