Study Guide: Default Taxonomy Template in Hugo
How to create a default taxonomy template in Hugo.
1. Create template file
Copy the file /layouts//list.html to /layouts//terms.html. Replace the page content with some version of the following (CSS removed):
2. List categories
<h3>{{ i18n "categoriesTitle" }}</h3>
<ul>
{{- range $name, $items := .Site.Taxonomies.categories }}
<li><a href="{{ printf "%s/%s" "categories" ($name | urlize | lower) | absURL }}"><i class="fa fa-topics"></i> {{ $name }} ({{ len $items }})</a></li>
{{- end }}
</ul>3. List topics
<h3>{{ i18n "topicsTitle" }}</h3>
<ul>
{{- range $name, $items := .Site.Taxonomies.topics }}
<li><a href="{{ printf "%s/%s" "topics" ($name | urlize | lower) | absURL }}"><i class="fa fa-topics"></i> {{ $name }} ({{ len $items }})</a>
</li>
{{- end }}
</ul>
Related Content
Source: //study/hugo/hugo-default-taxonomy-template/
