Taxonomy


Taxonomy

Taxonomy in Tapestry is bound to Content Types via each Content Types configuration. They are used to primarily classify pages into separate taxonomies.

Defining Taxonomy for content types

The configuration for each Content Type has the configuration key taxonomies. This must always be an array, however it doesn't have to have any elements.

The blog Content Type that ships with Tapestry by default comes pre-configured with two taxonomies: categories and tags, therefore its taxonomies configuration looks like the following:

...
    'taxonomies' => [
        'tags',
        'categories'
    ]
...

These can then be used to categorise and tag posts within their Front Matter like so:

---
categories:
    - ocean animals
tags:
    - under water
    - blue
    - aquatic
---

Using Taxonomy in your layouts

Taxonomy is used in layouts via requesting content type taxonomy collections. This is done within the Front Matter of your page by using the following syntax: {contentTypeName}_{taxonmyName}. For example:

---
use:
    - blog_tags
---
<? var_dump($blog_tags); ?>

This can be paired with the TaxonomyArchiveGenerator to generate archive pages for your websites taxonomy.