# Difficulties with terms and taxonomies in specific cases

**URL:** <https://discourse.gohugo.io/t/difficulties-with-terms-and-taxonomies-in-specific-cases/53867>\
**Category:** support\
**Tags:** taxonomy\
**Created:** [March 8, 2025, 4:27pm UTC](https://discourse.gohugo.io/t/difficulties-with-terms-and-taxonomies-in-specific-cases/53867 "2025-03-08T16:27:39Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![nfriedli](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/nfriedli/32/26027_2.png) [@nfriedli](https://discourse.gohugo.io/u/nfriedli)\
**Post date:** [March 8, 2025, 4:27pm UTC](https://discourse.gohugo.io/t/difficulties-with-terms-and-taxonomies-in-specific-cases/53867/1 "2025-03-08T16:27:39Z")

</div>

I searched the official documentation (which is constantly being improved) and the forum. But I haven’t found very clear answers to my questions.

Today, I feel like an idiot who doesn’t understand anything about Hugo.

I have 2 taxonomies declared in the configuration:

```auto
[taxonomies]
geo = "geo" # no plural, it's a choice
theme = "themes"

```

And in my pages:

```auto
geo = ["france", "germany", "switzerland"]
themes = ["cinema", "hugo", "music"]

```

I’m looking to do 3 separate things that are causing me problems.

## On a content page (kind = page)

I’d like to list taxonomies and terms, but not do things like that:

```auto
{{ $taxonomyObject := .Site.Taxonomies.geo }}

<p>Geo: {{ range $taxonomyObject}} ... {{ end }}</p>

```

I’d like the taxonomy to be displayed if and only if it’s used on the page, then list the terms. In pseudo code:

```auto
range pageTaxonomies:
    print TaxonomyTitle
    
    range Terms:
        print Term

```

So when I’m on a paris page, I’d like to see:

```txt
geo:
- france

themes:
- cinema
- music

```

## On a taxonomy page (kind = taxonomy)

I’d like to list the site’s other taxonomies as related.

For the moment, I’m listing the terms in the taxonomy, classic usage.

```auto
{{ with .Pages}}
    <ul>
        {{ range . }}
            <li><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></li>
        {{ end }}
    </ul>
{{ end }}

```

Below, I’d like a “see also”: list of other taxonomies on the site.

So when I’m on geo, I’d like to see:

```txt
geo:
- france
- germany
- swizerland

see also:
- themes

```

I think that depending on the variables that exist in Hugo, I need to go through `site.Taxonomies` and remove the current one with an `if eq...`. Right? Or is there another way of doing this?

**I have an answer:**

```auto
<ul>
  {{ range (where site.AllPages "Kind" "taxonomy") }}
    {{ if ne .Page page }} 
      <li><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></li>
    {{ end }}
  {{ end}}
</ul>

```

## On a term page (type = term)

Below the list (similar to the code above), I’d like to see the other terms.

So when I’m on france, I’d like to see:

```txt
france:
- marseille 
- paris
- [my pages]

see also:
- germany
- switzerland

```

It’s for this part of see also that I have no idea how to go about it. I know I missed something, but I’m still wondering what it is…

**I have an answer (taxonomy is a parent of terms!):**

```auto
{{ with .Parent }}
<ul>
  {{ range .Pages }}
    {{ if ne .Page page }} 
      <li><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></li>
    {{ end }}
  {{ end}}
</ul>
{{ end }}

```

Thank you in advance for giving me some clues to help me feel less stupid.

---

<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:** [March 8, 2025, 8:15pm UTC](https://discourse.gohugo.io/t/difficulties-with-terms-and-taxonomies-in-specific-cases/53867/2 "2025-03-08T20:15:18Z")

</div>

For the first one, use the `GetTerms` method on the `Page` object.

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

```

A couple of notes…

- Filter out empty taxonomies
- Be careful how you use the global `page` function ([see warnings](https://gohugo.io/functions/global/page/#warnings))

---

<div class="post-metadata">

**Author:** ![nfriedli](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/nfriedli/32/26027_2.png) [@nfriedli](https://discourse.gohugo.io/u/nfriedli)\
**Post date:** [March 8, 2025, 9:02pm UTC](https://discourse.gohugo.io/t/difficulties-with-terms-and-taxonomies-in-specific-cases/53867/3 "2025-03-08T21:02:33Z")

</div>

Thank you so much! You are always so helpful and precise. Impressive and helpful.

I will read your code carefully and learn a lot.

---

<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:** [March 10, 2025, 9:02pm UTC](https://discourse.gohugo.io/t/difficulties-with-terms-and-taxonomies-in-specific-cases/53867/4 "2025-03-10T21:02:39Z")

</div>

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