hugo: Taxonomies names does not match urlized

The documentation here says: https://gohugo.io/content-management/taxonomies/#preserve-taxonomy-values

“Therefore, if you want to have a taxonomy term with special characters such as Gérard Depardieu instead of Gerard Depardieu, set the value for preserveTaxonomyNames to true in your site config.”

“Note that if you use preserveTaxonomyNames and intend to manually construct URLs to the archive pages, you will need to pass the taxonomy values through the urlize template function.”

However, in v0.54.0 this is not the behaviour I am seeing. preserveTaxonomyNames is false, but names are not normalized.

I have defined a taxonomy called “author” which has peoples names in it.

However, when I do:

    {{ with $.Site.GetPage (printf "/author/%s" ( $author | urlize )) }}
      <a href="{{ .RelPermalink }}">{{ $author }}</a>
    {{ end }}

It doesn’t get the page for authors with accents in their names

{{ "Olivier Cochard-Labbé" | urlize }} = olivier-cochard-labb%C3%A9

but the taxonomy is: olivier-cochard-labbé

How do I encode the url the same way that the taxonomy is encoded, or get the taxonomy to be urlize’d?

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 6
  • Comments: 16

Commits related to this issue

Most upvoted comments

I’ve got it working by fixing theme templates by changing from this

{{ $series := .Params.series | urlize}}

to this

{{ $series := .Params.series | anchorize}}

Anchorize function doesn’t do urlencoding.

I’ve the same problem, I think hugo should have a function to calculate a key from a name (a term name here) like toKey, toIndex, keyize or indexize with the same logic it’s internal do to calculate the index/key

anchorize, and urlize are not for this purpose and user use them because such a function do not exists