Jekyll display posts by category

Got it! Needed an intermediate posts loop before listing out individual posts <ul> {% for category in site.categories %} <li><a name=”{{ category | first }}”>{{ category | first }}</a> <ul> {% for post in category.last %} <li><a href=”https://stackoverflow.com/questions/20872861/{{ post.url }}”>{{ post.title }}</a></li> {% endfor %} </ul> </li> {% endfor %} </ul>

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 %}

How can I show just the most recent post on my home page with jekyll?

This can be accomplished through the use of limit: {% for post in site.posts limit:1 %} … Show the post … {% endfor %} You can also use limit and offset together to “feature” your most recent post: <h1>Latest Post</h1> {% for post in site.posts limit:1 %} … Show the first post all big … … Read more

Sorted navigation menu with Jekyll and Liquid

Since Jekyll 2.2.0 you can sort an array of objects by any object property. You can now do : {% assign pages = site.pages | sort:”weight” %} <ul> {% for p in pages %} <li> <a {% if p.url == page.url %}class=”active”{% endif %} href=”https://stackoverflow.com/questions/9053066/{{ p.url }}”> {{ p.title }} </a> </li> {% endfor %} … Read more