mirror of
https://github.com/gohugoio/hugoDocs.git
synced 2025-09-14 19:04:39 -04:00
Clean up and removal of outdated examples
The README.md states that the docs should "describe the current best practice" (as opposed to older ways). This is the implementation of that principle.
This commit is contained in:
parent
46122c9aa9
commit
ef9c4913cd
@ -124,8 +124,6 @@ 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 }}
|
||||
@ -134,22 +132,6 @@ In Hugo 0.55 and later you can do:
|
||||
</ul>
|
||||
```
|
||||
|
||||
Before that you would have to do something like:
|
||||
|
||||
```go-html-template
|
||||
<ul>
|
||||
{{ $type := .Type }}
|
||||
{{ range $key, $value := .Data.Terms.Alphabetical }}
|
||||
{{ $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/) -->
|
||||
|
||||
## Order Content within Taxonomies
|
||||
@ -220,8 +202,6 @@ Because we are leveraging the front matter system to define taxonomies for conte
|
||||
|
||||
### Example: List Tags in a Single Page Template
|
||||
|
||||
{{< new-in "0.65.0" >}}
|
||||
|
||||
```go-html-template
|
||||
<ul>
|
||||
{{ range (.GetTerms "tags") }}
|
||||
@ -230,20 +210,6 @@ Because we are leveraging the front matter system to define taxonomies for conte
|
||||
</ul>
|
||||
```
|
||||
|
||||
Before Hugo 0.65.0 you needed to do something like this:
|
||||
|
||||
```go-html-template
|
||||
{{ $taxo := "tags" }} <!-- Use the plural form here -->
|
||||
<ul id="{{ $taxo }}">
|
||||
{{ range .Param $taxo }}
|
||||
{{ $name := . }}
|
||||
{{ with $.Site.GetPage (printf "/%s/%s" $taxo ($name | urlize)) }}
|
||||
<li><a href="{{ .Permalink }}">{{ $name }}</a></li>
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
</ul>
|
||||
```
|
||||
|
||||
If you want to list taxonomies inline, you will have to take care of optional plural endings 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 taxonomies, use the following:
|
||||
@ -310,8 +276,6 @@ 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 }}
|
||||
@ -320,20 +284,6 @@ In Hugo 0.55 and later you can simply do:
|
||||
</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 }}
|
||||
{{ with $.Site.GetPage (printf "/tags/%s" $name) }}
|
||||
<li><a href="{{ .Permalink }}">{{ $name }}</a></li>
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
</ul>
|
||||
```
|
||||
|
||||
### Example: List All Taxonomies, Terms, and Assigned Content
|
||||
|
||||
This example will list all taxonomies and their terms, as well as all the content assigned to each of the terms.
|
||||
|
Loading…
x
Reference in New Issue
Block a user