mirror of
https://github.com/gohugoio/hugo.git
synced 2025-03-03 11:32:39 +00:00
docs: Add additional example for taxonomies listing
Add another example how to list taxonomies inline, adding title (singular or plural) and commas between taxonomies. See #2143
This commit is contained in:
parent
eda3678742
commit
364686ecbb
1 changed files with 14 additions and 1 deletions
|
@ -1,7 +1,7 @@
|
|||
---
|
||||
aliases:
|
||||
- /indexes/displaying/
|
||||
lastmod: 2015-05-22
|
||||
lastmod: 2016-05-13
|
||||
date: 2013-07-01
|
||||
linktitle: Displaying
|
||||
menu:
|
||||
|
@ -42,6 +42,19 @@ each content piece are located in the usual place
|
|||
{{ end }}
|
||||
</ul>
|
||||
|
||||
If you want to list taxonomies inline, you will have to take
|
||||
care of optional plural ending in the title (if multiple taxonomies),
|
||||
as well as commas. Let's say we have a taxonomy "directors" such as
|
||||
`directors: [ "Joel Coen", "Ethan Coen" ]` in the TOML-format front matter.
|
||||
To list such taxonomy use the following:
|
||||
|
||||
### Example
|
||||
|
||||
{{ if .Params.directors }}
|
||||
<strong>Director{{ if gt (len .Params.directors) 1 }}s{{ end }}:</strong>
|
||||
{{ range $index, $director := .Params.directors }}{{ if gt $index 0 }}, {{ end }}<a href="directors/{{ . | urlize }}">{{ . }}</a>{{ end }}
|
||||
{{ end }}
|
||||
|
||||
## 2. Listing content with the same taxonomy term
|
||||
|
||||
First, you may be asking why you would use this. If you are using a
|
||||
|
|
Loading…
Reference in a new issue