Categories are very simple to add to Jekyll if you keep it simple. When I set this up a lot of other guides were trying to automate the creation of category pages and create global variables to compile and track them. I just wanted 3 simple categories to sort my posts and have pages for each. This is how I set it up if you want to do something similar.

1. Add a category to each post’s meta.

---
title: 'post title'
date: '2023-02-04'
category: guides
---

guides is just an example category here.

2. Display that category on the post’s page:

If you haven’t already, copy the _layouts/post.html file to your root. Add the following to include the category as a link.

{%- if page.category %}
  <a href="/cat/{{ page.category }}">
    {{ page.category }}
  </a>
{% endif %}

You’ll notice that link doesn’t exist yet.

3. Create the category page template:

Create a file at _layouts/category.html that looks like this:

---
layout: default
---

<div class="post">
  <h2 class="post-list-heading">{{ page.category }}</h2>
  <ul>
    {% for post in site.posts %}
      {% if post.category == page.category %}
        <li>
          {%- assign date_format = site.minima.date_format | default: "%b %-d, %Y" -%}
          <span class="post-meta">
            <time>{{ post.date | date: date_format }}</time>
          </span>
          <a href="{{ post.url }}">{{ post.title }}</a>
        </li>
      {% endif %}
    {% endfor %}
  </ul>
</div>

This is the template for the individual category pages. It loops through all the posts, and filters them for posts with the specified category. You can come back and edit this template later.

4. Create the actual pages for each category using that template.

Since I chose to use the link /cat/<category name> I will create a folder at the root called cat and place a markdown file for each category there. The file structure looks like:

cat/
    guides.md
    projects.md
    prose.md

Each of those markdown files look like this:

---
layout: category
title: 'guides'
category: guides
---

Again, guides is just the example. Replace that for each file.

If you add a title, the page automatically gets added to the minima navigation at the top of the site. If you remove the title, the page will still work but it won’t show up in the nav.

That’s it. My categories do not change often, so I find this to be suitable enough for me.