mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-30 22:39:58 +02:00
Merge commit 'a0c28c943c2f4714fa340b22a583b96f5013090b'
This commit is contained in:
@@ -124,6 +124,18 @@ Taxonomies can be ordered by either alphabetical key or by the number of content
|
||||
|
||||
### Order Alphabetically Example
|
||||
|
||||
In Hugo 0.55 and later you can do:
|
||||
|
||||
```go-html-template
|
||||
<ul>
|
||||
{{ range .Data.Terms.Alphabetical }}
|
||||
<li><a href="{{ .Page.Permalink }}">{{ .Page.Title }}</a> {{ .Count }}</li>
|
||||
{{ end }}
|
||||
</ul>
|
||||
```
|
||||
|
||||
Before that you would have to do something like:
|
||||
|
||||
```go-html-template
|
||||
<ul>
|
||||
{{ $type := .Type }}
|
||||
@@ -137,35 +149,6 @@ Taxonomies can be ordered by either alphabetical key or by the number of content
|
||||
</ul>
|
||||
```
|
||||
|
||||
### Order by Popularity Example
|
||||
|
||||
```go-html-template
|
||||
<ul>
|
||||
{{ $type := .Type }}
|
||||
{{ range $key, $value := .Data.Terms.ByCount }}
|
||||
{{ $name := .Name }}
|
||||
{{ $count := .Count }}
|
||||
{{ with $.Site.GetPage (printf "/%s/%s" $type $name) }}
|
||||
<li><a href="{{ .Permalink }}">{{ $name }}</a> {{ $count }}</li>
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
</ul>
|
||||
```
|
||||
|
||||
### Order by Least Popular Example
|
||||
|
||||
```go-html-template
|
||||
<ul>
|
||||
{{ $type := .Type }}
|
||||
{{ range $key, $value := .Data.Terms.ByCount.Reverse }}
|
||||
{{ $name := .Name }}
|
||||
{{ $count := .Count }}
|
||||
{{ with $.Site.GetPage (printf "/%s/%s" $type $name) }}
|
||||
<li><a href="{{ .Permalink }}">{{ $name }}</a> {{ $count }}</li>
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
</ul>
|
||||
```
|
||||
|
||||
<!-- [See Also Taxonomy Lists](/templates/list/) -->
|
||||
|
||||
@@ -311,6 +294,20 @@ The following example displays all terms in a site's tags taxonomy:
|
||||
|
||||
### Example: List All Site Tags {#example-list-all-site-tags}
|
||||
|
||||
In Hugo 0.55 and later you can simply do:
|
||||
|
||||
```go-html-template
|
||||
<ul>
|
||||
{{ range .Site.Taxonomies.tags }}
|
||||
<li><a href="{{ .Page.Permalink }}">{{ .Page.Title }}</a> {{ .Count }}</li>
|
||||
{{ end }}
|
||||
</ul>
|
||||
```
|
||||
|
||||
Before that you would do something like this:
|
||||
|
||||
{{< todo >}}Clean up rest of the taxonomy examples re Hugo 0.55.{{< /todo >}}
|
||||
|
||||
```go-html-template
|
||||
<ul id="all-tags">
|
||||
{{ range $name, $taxonomy := .Site.Taxonomies.tags }}
|
||||
|
Reference in New Issue
Block a user