# Can .GetTerms support an array of taxonomies?

**URL:** <https://discourse.gohugo.io/t/can-getterms-support-an-array-of-taxonomies/56095>\
**Category:** support\
**Created:** [October 16, 2025, 3:21pm UTC](https://discourse.gohugo.io/t/can-getterms-support-an-array-of-taxonomies/56095 "2025-10-16T15:21:33Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![tifenak](https://avatars.discourse-cdn.com/v4/letter/t/e36b37/32.png) [@tifenak](https://discourse.gohugo.io/u/tifenak)\
**Post date:** [October 16, 2025, 3:21pm UTC](https://discourse.gohugo.io/t/can-getterms-support-an-array-of-taxonomies/56095/1 "2025-10-16T15:21:33Z")

</div>

I am curious coz I am looking for a way to define via `.Param` which terms can show up and a default term to fall back on. For example, I would like to do `get_terms = ['tags']` or `get_terms = ['tags','categories']` and then do `.GetTerms ($.Param "get_terms")`.

> **[GetTerms](https://gohugo.io/methods/page/getterms/#article)**
>
> Returns a collection of term pages for terms defined on the given page in the given taxonomy, ordered according to the sequence in which they appear in front matter.

I am also open to more ideas to configure such a thing.

---

<div class="post-metadata">

**Author:** ![jmooring](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/jmooring/32/4214_2.png) [@jmooring](https://discourse.gohugo.io/u/jmooring)\
**Post date:** [October 16, 2025, 4:34pm UTC](https://discourse.gohugo.io/t/can-getterms-support-an-array-of-taxonomies/56095/2 "2025-10-16T16:34:15Z")

</div>

You would need an outer loop to range through the taxonomies, and an inner loop to range through the terms returns by `.GetTerms`, discarding those you don’t want.

---

<div class="post-metadata">

**Author:** ![tifenak](https://avatars.discourse-cdn.com/v4/letter/t/e36b37/32.png) [@tifenak](https://discourse.gohugo.io/u/tifenak)\
**Post date:** [October 16, 2025, 8:11pm UTC](https://discourse.gohugo.io/t/can-getterms-support-an-array-of-taxonomies/56095/3 "2025-10-16T20:11:35Z")

</div>

An example in code would be appreciated.

---

<div class="post-metadata">

**Author:** ![jmooring](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/jmooring/32/4214_2.png) [@jmooring](https://discourse.gohugo.io/u/jmooring)\
**Post date:** [October 17, 2025, 1:27pm UTC](https://discourse.gohugo.io/t/can-getterms-support-an-array-of-taxonomies/56095/4 "2025-10-17T13:27:37Z")

</div>

Something like…

```plaintext
git clone --single-branch -b hugo-forum-topic-56095 https://github.com/jmooring/hugo-testing hugo-forum-topic-56095
cd hugo-forum-topic-56095
hugo server

```

Files of interest:

- `hugo.toml`
- `layouts/_partials/terms.html`

The partial does two things:

1. Builds a data structure of the terms assigned to the current page, grouped by taxonomy, excluding terms in the “exclude list” as defined in front matter (if any), falling back to the “exclude list” as defined in the site configuration (if any). Invert the logic if you’d rather use an “include list”.
2. Renders the data structure as a nested, unordered list.

Default terms are assigned by cascading from the site configuration.

---

<div class="post-metadata">

**Author:** ![tifenak](https://avatars.discourse-cdn.com/v4/letter/t/e36b37/32.png) [@tifenak](https://discourse.gohugo.io/u/tifenak)\
**Post date:** [October 17, 2025, 4:13pm UTC](https://discourse.gohugo.io/t/can-getterms-support-an-array-of-taxonomies/56095/5 "2025-10-17T16:13:24Z")

</div>

Hi Joe. I made a mistake when I said “terms”. What I really meant is this.

`./config/default/params.toml`

```auto
[list]
  get_ terms = [''] # e.g ['tags'], ['categories','tags'] etc. Could be any user defined taxonomy

[page]
  get_ terms = [''] # e.g ['tags'], ['categories','tags'] etc. Could be any user defined taxonomy

```

So, when a taxonomy is added (or taxonomies are added) in such a way, then the terms from those taxonomies will show up. e.g

```auto
./layout/list.html

{{ with $.Param "list.get_terms" | default "categories" }}
  <!--- Code for .GetTerms goes here. Preferably a reusable partial--->
{{ end }}

./layout/page.html

{{ with $.Param "page.get_terms" | default "categories"}}
  <!--- Code for .GetTerms goes here. Preferably a reusable partial--->
{{ end }}

```

The reusable partial will then fetch the given terms for the defined taxonomies (array) and fall back to categories taxonomy terms if none are user defined.

`Param` here means it should be configurable per page or in params.

The use case is showing the defined taxonomy’s terms in each single page or in each page entry in the list page.

(Maybe `get_terms` should be `get_taxonomy_terms`.)

I hope that’s clear. Thanks in advance.

(The configuration is defined like [list] and [page] also coz styling is different, alongside configuring appearace for page and list pages.)

---

<div class="post-metadata">

**Author:** ![jmooring](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/jmooring/32/4214_2.png) [@jmooring](https://discourse.gohugo.io/u/jmooring)\
**Post date:** [October 17, 2025, 4:17pm UTC](https://discourse.gohugo.io/t/can-getterms-support-an-array-of-taxonomies/56095/6 "2025-10-17T16:17:02Z")

</div>

The approach is the same: outer loop and inner loop.

---

<div class="post-metadata">

**Author:** ![tifenak](https://avatars.discourse-cdn.com/v4/letter/t/e36b37/32.png) [@tifenak](https://discourse.gohugo.io/u/tifenak)\
**Post date:** [October 17, 2025, 5:34pm UTC](https://discourse.gohugo.io/t/can-getterms-support-an-array-of-taxonomies/56095/7 "2025-10-17T17:34:29Z")

</div>

Thanks for the help. Grok filled in the blanks

```auto
 {{ $getTerms := $.Param "taxonomies.get_terms" | default slice }}
{{ $allTaxonomyData := slice }}
{{ range $taxonomyName, $taxonomy := site.Taxonomies }}
  {{ if in $getTerms $taxonomyName }}
    {{ $visibleTerms := slice }}
    {{ range $.GetTerms $taxonomyName }}
      {{ $visibleTerms = $visibleTerms | append . }}
    {{ end }}
    {{ with $visibleTerms }}
      {{ $allTaxonomyData = $allTaxonomyData | append (dict "termPages" $visibleTerms) }}
    {{ end }}
  {{ end }}
{{ end }}

{{ with $allTaxonomyData }}
  <ul>
    {{ range . }}
      {{ with .termPages }}
        {{ range . }}
          <li><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></li>
        {{ end }}
      {{ end }}
    {{ end }}
  </ul>
{{ end }}

```

Now I just change this `taxonomies.get_terms` to `list.taxonomies.get_terms` or `pagetaxonomies.get_terms` for list or single pages.

---

<div class="post-metadata">

**Author:** ![system](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/system/32/1_2.png) [@system](https://discourse.gohugo.io/u/system)\
**Post date:** [October 26, 2025, 9:06am UTC](https://discourse.gohugo.io/t/can-getterms-support-an-array-of-taxonomies/56095/8 "2025-10-26T09:06:34Z")

</div>

Closed on October 26, 2025, 9:06am UTC

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