I will add one more thing to 0.65 if I find a good name for it. This is something I've wanted for a while, and I suspect I'm not alone, but the data structure we had for this made it rather clumsy ...
In the docs, we have this example:
{{ $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>
I want it rewritten to something like:
<ul>
{{ range (.GetTerms "tags") }}
<li><a href="{{ .Permalink }}">{{ .LinkTitle }}</a></li>
{{ end }}
</ul>
I always get confused when thinking about these tax terms, and I have probably contributed my share to this confusion (and no, we're not switching the
page kinds taxonomyTerm and taxonomy...)...
But from the docs about the above:
Within your content templates, you may wish to display the taxonomies that piece of content is assigned to.
Note that the above is different than site.GetPage "tags", which gives you the taxonomy term list page (which lists the terms for all pages).
/cc @regisphilibert @digitalcraftsman @onedrawingperday @budparr @davidsneighbour and gang.
Oh I'm on your side with this, have been for a long time :)
https://discourse.gohugo.io/t/give-some-love-to-terms-listing/13234
Though in the thread mentioned above I advocate for GetTerms which to me (others might chime in) reads closer to what the function will achieve: Get the terms of X taxonomy.
For me Tags is a Taxonomy wile art is a term from given taxonomy. And beside this (indeed) confusing sentence you quote from the doc, the whole "Film" practical example used in the doc seems to align with my understanding.
Though in the thread mentioned above I advocate for GetTerms which to me (others might chime in) reads closer to what the function will achieve: Get the terms of X taxonomy.
Yea, that may sound better.
<ul>
{{ range (.GetTaxonomies "tags") }}
<li><a href="{{ .Permalink }}">{{ .LinkTitle }}</a></li>
{{ end }}
</ul>
Or:
<ul>
{{ range (.GetTerms "tags") }}
<li><a href="{{ .Permalink }}">{{ .LinkTitle }}</a></li>
{{ end }}
</ul>
Though in the thread mentioned above I advocate for GetTerms which to me (others might chime in) reads closer to what the function will achieve: Get the terms of X taxonomy.
I would favor the proposal of @regisphilibert. From my understanding taxonomies have been the name of a collection of pages which share related terms:
|Taxonomy|Terms|
|---------|-|
|music genre| rock, pop, hip hop, classic|
|colors| red, green, blue|
In @bep's initial code example he wants to get the terms of a given taxonomy. Getting the taxonomies of tags doesn't seem to make sense IMHO as we want to display the kind of tags that exist, i.e. the terms.
OK, GetTermsit is. Thanks for the help!
Hi
{{ range (.GetTerms "categories") }}
does not work for me!
It seems that the GetTerms function returns a list with inconsistent order with the original one because of https://github.com/bep/hugo/commit/9e7e48d17b8b1c78ea1938aea21fcfba4dceb0e5#diff-204b5518c5299155dd3b72a4299751f9R157
@bep
Most helpful comment
I would favor the proposal of @regisphilibert. From my understanding taxonomies have been the name of a collection of pages which share related terms:
|Taxonomy|Terms|
|---------|-|
|music genre| rock, pop, hip hop, classic|
|colors| red, green, blue|
In @bep's initial code example he wants to get the terms of a given taxonomy. Getting the taxonomies of
tagsdoesn't seem to make sense IMHO as we want to display the kind of tags that exist, i.e. the terms.