Amazing autocomplete terms in taxonomy

Hi dissus community

I was just going to write a feature in taxonomy that would unify
the same singular and plural terms (accidentally entered in Front Matter),
however, there is no such need, Hugo already has it! (Explanation below the introduction)

Great :sparkles: hugo did the work for me
it’s just pure inquisitiveness

p’tit introduction

I am building a portfolio that is to include graphic works of a designer,
I used the native categories to add terms to it, e.g .: pancartes, vectors, illustrations, …
I assume the user might have made a mistake and typed singular categories: illustration

.Data.Terms vs .Site.Taxonomies

I noticed that WeightedPages obtained from .Site.Taxonomies.categories distinguishes between illustrations and illustration,
but the .Data.Terms returns WeightedPages where illustration was unified with illustrations.

Experimentation has revealed that even entering illustratio, illustra, and even just i will unify these terms in the map .Data.Terms.illustrations

And even the value of .Param.categories is replaced:

For demo: We have only two pages “dragon.md” with categories: illustra and “monster.md” with categories: illustrations:

{{ range .Data.Terms }}
	{{ .Pages }}									=> Pages(2)
	{{ $firstWeightedPage := index . 0 }}
	{{ $firstWeightedPage.Params.categories }} 		=> [illustrations]
	{{ $firstWeightedPage.Page.Params.categories }}	=> [illustrations]
{{ end }}

but with range .Site.Taxonomies, we got two terms: :point_right: illustra and :point_right: illustrations where each will keep the value of .Params.categories as is.

it is amazing

Where can I learn more about this

I am unable to reproduce the behavior described.

The following examples return identical results:

layouts/_default/taxonomy.html

{{ range $term, $weightedPages := site.Taxonomies.categories }}
  <h3>{{ $term }}</h3>
  {{ range $weightedPages }}
    <h4><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></h4>
  {{ end }}
{{ end }}

{{ range $term, $weightedPages := .Data.Terms }}
  <h3>{{ $term }}</h3>
  {{ range $weightedPages }}
    <h4><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></h4>
  {{ end }}
{{ end }}

Ok, I noticed today.

hugo v0.104.3-58b824581360148f2d91f5cc83f69bd22c1aa331+extended linux/amd64 BuildDate=2022-10-04T14:25:23Z VendorInfo=snap:0.104.3

it returns identical results.

have a good day!

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