Grouping taxonomy terms

Hello,

We are working on a site with many authors where it would be really useful to be able to associate different taxonomy terms with the same concept. For example different authors will use: “cars”, “automobiles”, “autos” to tag their car related posts. This leads to a proliferation of tags hindering usability and it would be useful for us to be able to say:
tags “automobiles” and “autos” refer to tag “cars”.

So that when we visit the page for “cars” we also see “automobiles” and “autos”, and for “autos” we also see “cars” etc.

Is this possible in hugo? How could that be configured?

thank you!

Create a data file to group term aliases into arrays.

data/tags.json

[
  ["cars", "automobiles", "autos"],
  ["films", "movies"]
]

Then examine these arrays when rendering the term page.

layouts/_default/term.html

{{ $taxonomy := .Data.Plural }}
{{ $term := .Data.Term }}

{{ $p := slice }}
{{ range (index site.Data $taxonomy) }}
  {{ if in . $term }}
    {{ range . }}
      {{ $p = $p | union (index site.Taxonomies $taxonomy .).Pages }}
    {{ end }}
  {{ end }}
{{ end }}

{{ range or $p .Pages }}
  <h2><a href="{{ .RelPermalink }}">{{ .Title }}</a></h2>
{{ end }}
4 Likes

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.