Getting links to taxonomy term pages

On a page, I want to show links to tag pages of the tags appearing in the page’s front matter.

However, by ranging through .Params.tags, each tag in the list is a string, not the tag page. What I want is to provide a link to the tag page for each tag.

Hope that makes sense. I am a newbie, and don’t know how to explain it better :expressionless:

Check out the doc’s taxonomy templates. You’ll find some exemples.

Thanks, I managed to get the following, which gets me halfway there:

      {{ range .Params.tags }}
        <li><a href="{{ "/tags/" | relLangURL }}{{ . | urlize }}">{{ . }}</a> </li>
      {{ end }}

However, I want to access the variables from the front matter (i.e. the custom metadata) of the individual taxonomy terms’ pages which, from further reading, it seems I must be able to get via the .GetPage function, but how do I get the page for a taxonomy term?

1 Like

Ah, I have found something that seems to work:

      {{ $a := .Site.GetPage "taxonomyTerm" "tags/admin"}}

Then I can access one of my custom metadata variables as follows:

      <div>{{ $a.Params.category }}</div>

It seems like a bit of a workaround. Would have been nice if there was a way to address the taxonomy term pages directly from the current page, but this will do for now!

2 Likes