Customizing your Jekyll blog in Github: support for tags (without external plugins), Latex math formulas, comments section
by Alberto Garcia
tags jekyll blogSetting up a blog in Github with Jekyll is a reasonably painless experience (thanks in part to the comprenhensive Github documentation). However, there are a few features that do not come ‘out of the box’:
-
No support for post tagging, or tag index pages (each one showing the posts tagged with an individual tag), without external plugins.
-
No way to render math formulas out of the box
-
As is usual in static blog generators, support for a comments section requires a third party solution.
In this post, we’ll try to fix these issues…
Tag support (without external plugin dependency)
This solution is based on an original post at Christian Specht’s site. I’ve added a small Python3 script that automates the task of regenerating tag index pages, and a small Liquid snippet to add to your post layout that will display links to the tag indexes that are used in the current post page.
- Add tags to your posts markdown, in the frontmatter tags property (only single-word tags are supported)
For example, this post has been tagged with jekyll
and blog
.
- Create a new
tabpage.html
layout in `./_layouts’:
This layout will be used for tags index pages: each one will show links to all the posts that contain the tag.
- Add the following in your
./layouts/post.html
layout:
This will show the tags you’ve used for your post, wherever you placed it in the layout (In this post, they are located between the Title-author and the main content)
- create a
refresh_tags.py
script in your site repo root (Python3):
- call the refresh_tags.py script (from your site repo root) prior everytime you add a tag to a post:
This script will create a ./tags
folder, where all your tag index pages will be stored (like this:
./tags/tag_name/index.html
)
Adding Latex Math formulas with MathJax
Add the following to the <head>
section of _layouts/default.html
:
You can add then Latex formulas in your markdown: e.g.$V^2 + D_i$
will render as $V^2 + D_i$
Comments section in your posts with utterances:
utterances allows you to add comments in your post that are stored as GitHub issues. People wanting to comment on your posts
will need a GitHub account (which is almost a feature, rather than a drawback ). Setup couldn’t be easier: just add the following script call
to your ./_posts/post.html
layout, where you want the comment section to be (change your username/reponame to your Github user name and the repo name of your site):
See their site for more information on configuration options.