According to this documentation, categories are part of the site.categories
collection. While I feel you are not explicitly overriding categories, Jekyll does not allow you to differentiate between the two by calling site.categories
(built-in) or site.collections.categories
(custom). Instead, you call built-in or custom custom categories using site.categories
.
I created a custom categories
collection with two items: cat1
and cat2
. Next, I iterated through them with the following code:
<h2>Categories</h2>
{%- assign categories = site.categories -%}
{% for category in categories %}
<h3>category title: {{ category.title }}</h3>
{% endfor %}
The output was as expected:

Next, I listed all the posts
in my site, along with the categories
tag. There are three posts, one of which contains the categories
YML front matter. Here is the code I ran:
<h2>Posts</h2>
{%- assign posts = site.posts -%}
{% for post in posts %}
<h3>{{post.title}} - {{post.categories}}</h3>
{% endfor %}
Sure enough, Jekyll displayed all the posts and, where applicable, displayed the post.categories
.

At first glance, it would seem you can create a new categories
custom collection. However, if we apply the logic associated with the Tags and Categories documentation, you will see some sample code for tags that you can also apply to categories.
For example, when I run this code with the custom categories
collection:
<h2>Jekyll Categories</h2>
{% for category in site.categories %}
<h3>{{ category[0] }}</h3>
<ul>
{% for post in category[1] %}
<li><a href="{{ post.url }}">{{ post.title }} - {{ post.categories }}</a></li>
{% endfor %}
</ul>
{% endfor %}
I receive the following error:
If I comment out the custom categories
collection in _config.yml
, I get the following expected output:

You can introduce breaking code into the solution using a custom categories
collection, as that last bit of code should have run successfully.
In my opinion, even if the code runs now, it might be a breaking change later (like in future versions of Jekyll, for example). If you want to use the built-in categories
, along with all the features Jekyll provides, then this seems like a bad idea.
My recommendation is to use a different word as you suggested. Maybe categorization or classification? I like categorization because at least it still seems like categories :-).
Perhaps it is possible to override the built-in categories
collection? @ashmaroli, would you have a moment to provide your thoughts on this?