mirror of
https://github.com/gohugoio/hugoDocs.git
synced 2025-09-16 18:14:37 -04:00
List page kinds to which a taxonomy term may be applied
This commit is contained in:
parent
6094e59bb7
commit
98ddc91a25
@ -293,7 +293,7 @@ genre = 'genres'
|
|||||||
|
|
||||||
Add taxonomy terms as shown below:
|
Add taxonomy terms as shown below:
|
||||||
|
|
||||||
{{< code file=content/example.md >}}
|
{{< code-toggle file=content/example.md fm=true >}}
|
||||||
title = 'Example'
|
title = 'Example'
|
||||||
date = 2024-02-02T04:14:54-08:00
|
date = 2024-02-02T04:14:54-08:00
|
||||||
draft = false
|
draft = false
|
||||||
@ -302,9 +302,30 @@ tags = ['red','blue']
|
|||||||
genres = ['mystery','romance']
|
genres = ['mystery','romance']
|
||||||
[params]
|
[params]
|
||||||
author = 'John Smith'
|
author = 'John Smith'
|
||||||
{{< /code >}}
|
{{< /code-toggle >}}
|
||||||
|
|
||||||
Access taxonomy terms from a template using the [`Params`] or [`GetTerms`] method on a `Page` object:
|
You can add taxonomy terms to the front matter of any these [page kinds]:
|
||||||
|
|
||||||
|
- `home`
|
||||||
|
- `page`
|
||||||
|
- `section`
|
||||||
|
- `taxonomy`
|
||||||
|
- `term`
|
||||||
|
|
||||||
|
[page kinds]: /getting-started/glossary/#page-kind
|
||||||
|
|
||||||
|
Access taxonomy terms from a template using the [`Params`] or [`GetTerms`] method on a `Page` object. For example:
|
||||||
|
|
||||||
|
{{< code file=layouts/_default/single.html >}}
|
||||||
|
{{ with .GetTerms "tags" }}
|
||||||
|
<p>Tags</p>
|
||||||
|
<ul>
|
||||||
|
{{ range . }}
|
||||||
|
<li><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></li>
|
||||||
|
{{ end }}
|
||||||
|
</ul>
|
||||||
|
{{ end }}
|
||||||
|
{{< /code >}}
|
||||||
|
|
||||||
[`Params`]: /methods/page/params/
|
[`Params`]: /methods/page/params/
|
||||||
[`GetTerms`]: /methods/page/getterms/
|
[`GetTerms`]: /methods/page/getterms/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user