Taxonomies
Syntax
SITE.Taxonomies
Returns
page.TaxonomyList
Conceptually, the Taxonomies method on a Site object returns a data structure such as:
taxonomy a:
- term 1:
  - page 1
  - page 2
- term 2:
  - page 1
taxonomy b:
- term 1:
  - page 2
- term 2:
  - page 1
  - page 2
[['taxonomy a']]
  'term 1' = ['page 1', 'page 2']
[['taxonomy a']]
  'term 2' = ['page 1']
[['taxonomy b']]
  'term 1' = ['page 2']
[['taxonomy b']]
  'term 2' = ['page 1', 'page 2']
{
   "taxonomy a": [
      {
         "term 1": [
            "page 1",
            "page 2"
         ]
      },
      {
         "term 2": [
            "page 1"
         ]
      }
   ],
   "taxonomy b": [
      {
         "term 1": [
            "page 2"
         ]
      },
      {
         "term 2": [
            "page 1",
            "page 2"
         ]
      }
   ]
}
For example, on a book review site you might create two taxonomies; one for genres and another for authors.
With this site configuration:
hugo.
 
 
 
taxonomies:
  author: authors
  genre: genres
[taxonomies]
  author = 'authors'
  genre = 'genres'
{
   "taxonomies": {
      "author": "authors",
      "genre": "genres"
   }
}
And this content structure:
content/
├── books/
│   ├── and-then-there-were-none.md --> genres: suspense
│   ├── death-on-the-nile.md        --> genres: suspense
│   └── jamaica-inn.md              --> genres: suspense, romance
│   └── pride-and-prejudice.md      --> genres: romance
└── _index.md
Conceptually, the taxonomies data structure looks like:
authors:
- achristie:
  - And Then There Were None
  - Death on the Nile
- ddmaurier:
  - Jamaica Inn
- jausten:
  - Pride and Prejudice
genres:
- suspense:
  - And Then There Were None
  - Death on the Nile
  - Jamaica Inn
- romance:
  - Jamaica Inn
  - Pride and Prejudice
[[authors]]
  achristie = ['And Then There Were None', 'Death on the Nile']
[[authors]]
  ddmaurier = ['Jamaica Inn']
[[authors]]
  jausten = ['Pride and Prejudice']
[[genres]]
  suspense = ['And Then There Were None', 'Death on the Nile', 'Jamaica Inn']
[[genres]]
  romance = ['Jamaica Inn', 'Pride and Prejudice']
{
   "authors": [
      {
         "achristie": [
            "And Then There Were None",
            "Death on the Nile"
         ]
      },
      {
         "ddmaurier": [
            "Jamaica Inn"
         ]
      },
      {
         "jausten": [
            "Pride and Prejudice"
         ]
      }
   ],
   "genres": [
      {
         "suspense": [
            "And Then There Were None",
            "Death on the Nile",
            "Jamaica Inn"
         ]
      },
      {
         "romance": [
            "Jamaica Inn",
            "Pride and Prejudice"
         ]
      }
   ]
}
To list the “suspense” books:
<ul>
  {{ range .Site.Taxonomies.genres.suspense }}
    <li><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></li>
  {{ end }}
</ul>
Hugo renders this to:
<ul>
  <li><a href="/books/and-then-there-were-none/">And Then There Were None</a></li>
  <li><a href="/books/death-on-the-nile/">Death on the Nile</a></li>
  <li><a href="/books/jamaica-inn/">Jamaica Inn</a></li>
</ul>