Include jekyll / liquid template data in a YAML variable?

Today I ran into a similar problem. As a solution I created the following simple Jekyll filter-plugin which allows to expand nested liquid-templates in (e.g. liquid-variables in the YAML front matter): module Jekyll module LiquifyFilter def liquify(input) Liquid::Template.parse(input).render(@context) end end end Liquid::Template.register_filter(Jekyll::LiquifyFilter) Filters can be added to a Jekyll site by placing them in the … Read more

Iterate over hashes in liquid templates

When you iterate over a hash using a variable called hash, hash[0] contains the key and hash[1] contains the value on each iteration. {% for link_hash in page.links %} {% for link in link_hash %} <a href=”https://stackoverflow.com/questions/8206869/{{ link[1] }}”>{{ link[0] }}</a> {% endfor %} {% endfor %}

Jekyll/Liquid Templating: How to group blog posts by year?

It can be done with much, much less Liquid code than in the existing answers: {% for post in site.posts %} {% assign currentdate = post.date | date: “%Y” %} {% if currentdate != date %} <li id=”y{{currentdate}}”>{{ currentdate }}</li> {% assign date = currentdate %} {% endif %} <li><a href=”https://stackoverflow.com/questions/19086284/{{ post.url }}”>{{ post.title }}</a></li> … Read more