Accessing taxonomy metadata from page (single.html or list.html)

Is there a way to access taxonmy metadata from “single.html” or “list.html”?

On my pages, I have a custom taxonomy called “category”:

---
title: 'Page title'
category:
- whatever
---

and I have a file “_index.md” in “content/category/whatever”

---
title: "Whatever"
url: 'veryniceurl'
---

When looping through the taxonomy in single.html or list.html


{{ with .Params.Category }}
	{{ range $key, $value := . }}
		<a href="/category/{{ $value | urlize }}">{{ $value }}</a>
	{{ end }}
{{ end }}

is there a way to access the metadata (title, url, etc) from within the loop?

Please post the taxonomies section of your site configuration.

Hi, it’s

[taxonomies]
	txauthor = 'author'
	txcategory = 'category'
	txtag = 'tag'

I’m trying to transfer a wordpress site, so I’ll have to keep the singular terms (category, author, etc) as the ones visible on the site.

single.html

{{ with .GetTerms "category" }}
  <p>Categories:
    {{ range . }}
      <a href="{{ .RelPermalink }}">{{ .Title }} ({{ .Params.wibble }})</a>
    {{ end }}
  </p>
{{ end }}
1 Like

Tried it - works like a charm! Thanks a lot!

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