What's the difference between categories and tags in Jekyll?

Both of their elements can be accessed by for..in, and the way of adding categories and tags are the same. So, what's the difference between categories and tags in Jekyll?


It seems to me that the only important difference is that categories can be used in the post url - a post inside the "beer" and "food" categories, by default, will have this url:

/food/beer/2008/09/09/foo-bar.html

Instead of this one:

/2008/09/09/foo-bar.html

See the post tests for details

Tags have no influence in the urls, at least according to their tests.


From the documentation:

  • Instead of placing posts inside of folders, you can specify one or more categories that the post belongs to. When the site is generated the post will act as though it had been set with these categories normally. Categories (plural key) can be specified as a YAML list or a space-separated string.

  • Similar to categories, one or multiple tags can be added to a post. Also like categories, tags can be specified as a YAML list or a space-separated string.

That only suggests similarities; it doesn't really explain the differences between categories and tags. This video tutorial suggests that:

the only difference between the two of them is that categories can be reflected in the permalinks of your posts.

It goes on to explain that

they can also be hierarchical in nature, but that means, for example, if you came up with a category of food you could come up with a category of cupcakes, which is sort of a subcategory to food. Tags, on the other hand, are flat. They're non-hierarchical in nature

and that

Jekyll really doesn't have any automated means of generating archive pages or content pages based off of those tags and categories.

Support for that kind of thing would be implemented in the theme you're using or you could do it yourself.


The v4.2 documentation has an updated answer.

The hallmark difference between categories and tags is that categories of a post may be incorporated into the generated URL for the post, while tags cannot be.

Therefore, depending on whether front matter has category: classic hollywood, or categories: classic hollywood, the example post above would have the URL as either movies/horror/classic%20hollywood/2019/05/21/bride-of-chucky.html or movies/horror/classic/hollywood/2019/05/21/bride-of-chucky.html respectively.

Both categories and tags are made available to Liquid templates and can be iterated over.

Both categories and tags can be defined in a post's front matter. Categories can also be defined by a post’s file path:

Any directory above _post will be read-in as a category. For example, if a post is at path movies/horror/_posts/2019-05-21-bride-of-chucky.markdown, then movies and horror are automatically registered as categories for that post.

When the post also has front matter defining categories, they just get added to the existing list if not present already.