mikeski.net kotlin java javascript hugo development

mikeski.net development blog

Hugo Taxonomy

Now that we have a Hugo site setup, we want to define a Taxonomy so that we can categorize pages. For example, we will have a series category in our taxonomy. The first series will be our hugo series, and by categorizing all of our Hugo related pages to be in this series Hugo will do some magic for us.

Configuration for Taxonomies

Hugo gives us tags and categories as defaults, but we are going to define a custom series term so we can see how it all works. We will also define a tag term so we can add tags to our articles, as well.

The first thing we do is add the terms to our config file:

taxonomies:
    series: series
    tag: tags

Note that the format is singular: plural for the term.

Now, we can add series and tag information to our front matter to categorize our posts.

Front Matter for Taxonomies

Next, we add our taxonomy data in the front-matter section of our pages. As we said earlier, we are going to have a hugo series of posts. To add our posts to the hugo series, we need to add the value to the front-matter of our posts.

Here is what our first page’s front-matter will look with the series taxonomy information added:

---
title: "Hugo QuickStart"
date: 2019-11-13T07:32:41-05:00
draft: true
weight: 100
series:
  - hugo
---

Now, we’ll add the series information to each hugo post and we have posts group by series now.

Add a layout

mkdir layouts/taxonnomy

tag.html