hugo-theme-relearn/exampleSite/content/configuration/customization/taxonomy.en.md

55 lines
2.9 KiB
Markdown
Raw Permalink Normal View History

+++
2024-10-12 17:28:28 +00:00
categories = ["explanation", "howto", "reference"]
2024-10-06 14:19:13 +00:00
description = "How to display custom taxonomies on your pages"
2024-10-12 17:32:15 +00:00
tags = ["taxonomy"]
title = "Taxonomies"
weight = 7
+++
2024-10-07 13:30:53 +00:00
This page explains how to show custom taxonomies on your pages.
2024-10-07 13:30:53 +00:00
For more details, check the official docs on [setting up custom taxonomies](https://gohugo.io/content-management/taxonomies/#configure-taxonomies) and [using them in your content](https://gohugo.io/content-management/taxonomies/#assign-terms-to-content).
2024-10-07 13:30:53 +00:00
## Default Behavior
2024-10-07 13:30:53 +00:00
The Relearn theme automatically shows Hugo's [default taxonomies](https://gohugo.io/content-management/taxonomies/#default-taxonomies) _tags_ and _categories_ out of the box.
2024-10-07 13:30:53 +00:00
- Tags appear at the top of the page in alphabetical order in form of baggage tags.
- Categories appear at the bottom of the page in alphabetical order as a list prefixed with an icon.
2024-10-07 13:30:53 +00:00
Each item links to a page showing all articles with that term.
2024-10-07 13:30:53 +00:00
## Setting Up Custom Taxonomies
2024-10-07 13:30:53 +00:00
To add custom taxonomies, update your `hugo.toml` file. You also have to add the default taxonomies if you want to use them.
2024-03-02 10:04:52 +00:00
{{< multiconfig file=hugo >}}
2024-10-06 14:19:13 +00:00
[taxonomies]
category = 'categories'
mycustomtag = 'mycustomtags'
tag = 'tags'
2024-03-02 10:04:52 +00:00
{{< /multiconfig >}}
2024-10-07 13:30:53 +00:00
## Showing Custom Taxonomies
2024-10-07 13:30:53 +00:00
To display your custom taxonomy terms, add this to your page (usually in `layouts/partials/content-footer.html`):
2024-03-02 13:19:46 +00:00
````go
{{ partial "term-list.html" (dict
"page" .
2024-10-06 14:19:13 +00:00
"taxonomy" "mycustomtags"
2023-10-05 06:11:46 +00:00
"icon" "layer-group"
) }}
````
### Parameter
| Name | Default | Notes |
|-----------------------|-----------------|-------------|
| **page** | _&lt;empty&gt;_ | Mandatory reference to the page. |
2024-10-06 18:52:53 +00:00
| **taxonomy** | _&lt;empty&gt;_ | The plural name of the taxonomy to display as used in your front matter. |
| **class** | _&lt;empty&gt;_ | Additional CSS classes set on the outermost generated HTML element.<br><br>If set to `tags` you will get the visuals for displaying the _tags_ taxonomy, otherwise it will be a simple list of links as for the _categories_ taxonomy. |
| **style** | `primary` | The style scheme used if **class** is `tags`.<br><br>- by severity: `caution`, `important`, `info`, `note`, `tip`, `warning`<br>- by brand color: `primary`, `secondary`, `accent`<br>- by color: `blue`, `cyan`, `green`, `grey`, `magenta`, `orange`, `red`<br>- by special color: `default`, `transparent`, `code` |
| **color** | see notes | The [CSS color value](https://developer.mozilla.org/en-US/docs/Web/CSS/color_value) to be used if **class** is `tags`. If not set, the chosen color depends on the **style**. Any given value will overwrite the default.<br><br>- for severity styles: a nice matching color for the severity<br>- for all other styles: the corresponding color |
2023-10-24 20:49:34 +00:00
| **icon** | _&lt;empty&gt;_ | An optional [Font Awesome icon name](shortcodes/icon#finding-an-icon) set to the left of the list. |