Creating Tag page in Jekyll that considers both pages and posts (GitHub pages compatible!)
A pages+posts “tags” page for your Jekyll blog
After a lot of debugging I finally can render a Tags page for Jekyll that:
- Does not use any plugins, for complete compatibility with GitHub pages!
- If you do not need to host on Github pages, take a look at this plugin, jekyll-tagories. Source code on GitHub.
- Considers
tags:
in both pages and posts. AFAIK Jekyll team has decided not to support this after discussing it on GitHub.- Within each tag of the list, combines the posts and pages that are tagged with that particular tag, sorts them by title and prints the list, so that for every tag you get a list of alphabetically ordered pages/posts.
- Demo here
The page is hacky, but it is what I could manage using pure Liquid language. It is not that slow as it may seem at first, however. It added 0.5 seconds of build time to this blog, more or less, on my Lenovo T420
Check out the code
Raw source is available on my GitHub here.