Example #
Use the urlize function to create a link to a [term page].
Consider this site configuration:
hugo.
taxonomies:
author: authors
[taxonomies]
author = 'authors'
{
"taxonomies": {
"author": "authors"
}
}
And this front matter:
content/books/les-miserables.md
---
authors:
- Victor Hugo
title: Les Misérables
---+++
authors = ['Victor Hugo']
title = 'Les Misérables'
+++{
"authors": [
"Victor Hugo"
],
"title": "Les Misérables"
}
The published site will have this structure:
public/
├── authors/
│ ├── victor-hugo/
│ │ └── index.html
│ └── index.html
├── books/
│ ├── les-miserables/
│ │ └── index.html
│ └── index.html
└── index.html
To create a link to the term page:
{{ $taxonomy := "authors" }}
{{ $term := "Victor Hugo" }}
{{ with index .Site.Taxonomies $taxonomy (urlize $term) }}
<a href="{{ .Page.RelPermalink }}">{{ .Page.LinkTitle }}</a>
{{ end }}
To generate a list of term pages associated with a given content page, use the [GetTerms] method on a Page object.