Jekyll provides site variables, such as site.categories to iterate all the categories of the blog and the posts that belogns to it.

1
2
3
4
{% for category in site.categories %}
	{{ category | first }}
	{{ category | last }}
{% endfor %}

With this method the best you can do is like it is shown in this website.

For me that was not enough, I wanted to:

  • List all the categories in a specific post (already possible trough {% for tag in page.categories %}...{% endfor %})
  • Have for each category a page with all the posts styled exactly like the homepage of my blog (This was Not Possible!)

In order to solve that issue and improve the usability of my blog, I realized the jekyll-classify plugin.

This plugin generates categories pages and add custom Liquid Tag for listing categories.

The usage is trivial, to list the categories it is enough to insert in your template the following:

{% list_category %} for categories, this will generate an unordered list with links to categories pages.

To generate the categories pages it is necessary to provide a layout with an iteration of all posts in the current category (each category page will be created following the layout):

1
2
3
{% for post in site.categories[page.category] %}
		# post properties
{% endfor %}

The default layouts name are ‘_layout/tags.html’ and ‘_layout/categories.html’

DEMO

Check out the github repository to install the plugin!

Resources: