Taxonomies

Taxonomies in PieCrust define pieces of page metadata for which you want to have index pages created for you.

Taxonomy example

A common example of taxonomies is the “category” of a blog post. If you have blog posts in categories “recipes“, “kitchen tips” and “restaurant reviews“, you want 3 pages to be created automatically for you so that someone can see a list of all recipes, kitchen tips, and restaurant reviews (and those pages may have sub-pages if they’re using pagination to only show 10 or so at a time).

But if you write a new blog post and put it in category “utensil reviews“, you want a new page listing all utensil reviews to also be created.

You basically want PieCrust to “dynamically” generate those listing pages (called “taxonomy index pages“) for each value ever used in that given taxonomy.

Taxonomy configuration

Taxonomies are defined under site/taxonomies in the website configuration:

site:
    taxonomies:
        categories:
            multiple: true
            page: pages:_cat.md
        authors:
            page: pages:_author.md

These settings should be defined as a map. Each entry is the name of the taxonomy, and is associated with the settings for that taxonomy. Settings include:

  • multiple: Defines whether a page can have more than one value assigned for this taxonomy. Defaults to false (i.e. only a single value can be assigned).

  • term: Taxonomies are usually named using plural nouns. The term setting lets you define the singular form, which is used to make some messages read better.

  • page: Defines the page to use to generate the index page for this taxonomy. This is a page reference.