This post was heavily inspired more or less copied from Joe Kampschmidt’s post How to list your jekyll posts by tags.

In his post, Joe shows how to create a list of posts sorted by the tags which they appear in. I wanted to achieve the same but instead listing by category rather than tag. I prefer categories as they are added into the URL when generating your site which I think is better for organisation (see here for the differences).

  {% for category in site.categories %}
{% assign category_name = category | first %}
{% assign posts = category | last %}

{{ category_name | capitalize }}
<ul>
{% for post in posts %}
{% if post.categories contains category_name %}
<li>
<a href="{{ post.url }}">{{ post.title }}</a>
<span class="date">{{ post.date | date: "%B, %Y" }}</span>
</li>
{% endif %}
{% endfor %}
</ul>
{% endfor %}