Taxonomy terms: internally anchorized?

The documentation on Taxonomies begins with a short example clarifying the terminology. It uses the taxonomy Actor and a term Bruce Willis.
That would mean, to me, that I could find all pages referring to Bruce Willis like so:

{{$actor := "Bruce Willis"}}
{{$pages := index .Site.Taxonomies.actor $actor}}

(the second line according to Taxonomy variables | Hugo. )
I didn’t try it with actors and Bruce Willis, but with authors. And there, passing the original name of the author to the index method/function above returns an empty map. Which is obvious if I look at the output of printf "%v" .Site.Taxonomies.author:

terms  map[
asfa-wossen-asserate:[WeightedPage(0,"Der letzte Kaiser von Afrika")] 
david-diop:[WeightedPage(0,"Nachts ist unser Blut schwarz")] 
günter-giesenfeld:[WeightedPage(0,"Land der Reisfelder")] 
ismail-kadare:[WeightedPage(0,"Chronik in Stein")
…]]

(reformatted for legibility) Apparently, all terms are “anchorized” before they are entered in Hugo’s internal data structures.

Did I overlook the documentation mentioning that? And how/why is the example Actor/Bruce Willis supposed to work with the index .Site.Taxonomies.actor code?

I’m not saying that the behavior is wrong. But I think would be helpful to make cristal-clear that terms are not used “as such” by Hugo but only after “anchorizing” them. And amending the parts of the documentation referring to terms etc.

Or is that perhaps a config setting that can switch off anchorization of terms?

Because the example is unclear, presented from a organization standpoint, not a technical standpoint.

Such a setting does not exist.

The taxonomy pages in the docs need some love:

Splitting the topic documentation like this makes some sense from a reference standpoint, but it causes duplication, holes, and contradictions (e.g., we correct something on page and forget to do it on another). I went through a similar exercise with menus, also split over three pages, and it took days, not hours, to rewrite, test, and correct.

I’ll open an issue in the docs repo. This has been on my radar for a long time, but it’s not a trivial task.

https://github.com/gohugoio/hugoDocs/issues/2218


EDIT 2024-06-27T08:22:21-07:00

Instead of doing this:

{{ $actor := "Bruce Willis" }}
{{ $pages := index .Site.Taxonomies.actor $actor }}

Do this:

{{ $actor := "Bruce Willis" }}
{{ $pages := .Site.Taxonomies.actor.Get $actor }}

https://gohugo.io/methods/taxonomy/get/

In previous versions of the documentation this method was not well documented, essentially buried in another page.

2 Likes

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.