How to add distinct tags and categories in Hugo?

Viewed 136

How can I add distinct tags and categories to create the appropriate template? Two templates or one with if and else in taxonomy.html?

1 Answers

.Data.Plural in taxonomy.html return "tags" or "categories" so with one test with if. It's good.

{{ if eq .Data.Plural "categories" }}
    <div class="alert alert-categories"><h1>{{ .Title }}</h1></div>
{{ end }}

{{ if eq .Data.Plural "tags" }}
    <div class="alert alert-tags"><h1>{{ .Title }}</h1></div>
{{ end }}
Related