| 1 |
--- |
| 2 |
title: Keywords |
| 3 |
description: Returns a slice of keywords as defined in front matter. |
| 4 |
categories: [] |
| 5 |
keywords: [] |
| 6 |
params: |
| 7 |
functions_and_methods: |
| 8 |
returnType: '[]string' |
| 9 |
signatures: [PAGE.Keywords] |
| 10 |
--- |
| 11 |
|
| 12 |
By default, Hugo evaluates the keywords when creating collections of [related content][]. |
| 13 |
|
| 14 |
{{< code-toggle file=content/recipes/sushi.md fm=true >}} |
| 15 |
title = 'How to make spicy tuna hand rolls' |
| 16 |
keywords = ['tuna','sriracha','nori','rice'] |
| 17 |
{{< /code-toggle >}} |
| 18 |
|
| 19 |
To list the keywords within a template: |
| 20 |
|
| 21 |
```go-html-template |
| 22 |
{{ range .Keywords }} |
| 23 |
{{ . }} |
| 24 |
{{ end }} |
| 25 |
``` |
| 26 |
|
| 27 |
Or use the [`delimit`][] function: |
| 28 |
|
| 29 |
```go-html-template |
| 30 |
{{ delimit .Keywords ", " ", and " }} → tuna, sriracha, nori, and rice |
| 31 |
``` |
| 32 |
|
| 33 |
Keywords are also a useful [taxonomy][]: |
| 34 |
|
| 35 |
{{< code-toggle file=hugo >}} |
| 36 |
[taxonomies] |
| 37 |
tag = 'tags' |
| 38 |
keyword = 'keywords' |
| 39 |
category = 'categories' |
| 40 |
{{< /code-toggle >}} |
| 41 |
|
| 42 |
[`delimit`]: /functions/collections/delimit/ |
| 43 |
[related content]: /content-management/related-content/ |
| 44 |
[taxonomy]: /content-management/taxonomies/ |