Estimated reading time: 2 minutes
Having the ability to section out your site into logical areas is often essential for sites that discuss more than one thing.
add the control variables top the config.toml file:
[taxonomies]
category = "categories"
tag = "tags"
series = "series"
add in the content variables to the content pages front matter:
categories: "learn hugo"
tags: "cats and tags"
series: "learn hugo"
showing the categories.
Should you want to have the post linked to more than one tag or category or series then simply create an array against the variable:
categories: ["learn hugo", "a second category"]
tags: ["hugo", "cats and tags", "sections"]
series: ["learn hugo", "second series"]
Open your layout list.html or single.html and add in:
{{ range $name, $items := .Site.Taxonomies.categories }}
<li><a href="{{ $.Site.BaseURL }}categories/{{ $name | urlize | lower }}">{{ $name }} <span>({{ len $items }})</span></a></li>
{{ end }}
Add the following to your layout template:
<ul id="all-tags">
{{ range $name, $taxonomy := .Site.Taxonomies.tags }}
<li><a href="{{ "/tags/" | relLangURL }}{{ $name | urlize }}">{{ $name }}</a></li>
{{ end }}
</ul>
Add the following code to your layout template:
{{ range $name, $items := .Site.Taxonomies.series }}
<li><a href="{{ $.Site.BaseURL }}series/{{ $name | urlize | lower }}">{{ $name }} <span>({{ len $items }})</span></a></li>
{{ end }}
Part 11 of 15 in the hugo zero to hero series.