October 15 2021
Jekyll Tip: Adding Years and Post Counts using Liquid
After 13 years and 177 posts, this blog is a bit long for a single scrolling index, so I added years to delineate the content as well as post count per year.
That involved a bit of programming in Liquid, a template language created by Shopify and used by Jekyll. Liquid does not expose support for hash creation, even though Jekyll can provide hashes like site
. Fortunately, it supports group_by_exp
expressions, available in v3.4+.
Below is the code I used:
I’ve been using Jekyll for eight years now. In 2013, I converted from Wordpress’s database-driven approach to Jekyll’s static HTML-generated approach: “Why I moved from Wordpress to Jekyll”. It continues to work well.
And for those who use Jekyll, you can post Liquid as text in a post by using {% raw %}{% endraw %}
.