Functions dealing with french accent

To allocate an id to each article (including each section) I am using the following code:

{{ range .CurrentSection.Sections }}
<a href="#{{ cond (in (.Title|urlize) "%") (.Title | base64Encode) (.Title) | urlize }}">{{ .Title }}</a>
{{ end }}

It works fine but when facing a french accent in the title, such as émissions or mémo the function returns an id as #w4ltaxnzaw9ucw instead of #emissions.
I guess it’s coming from base64Encode function which is not dealing with french accent. (the site default language is french).
I tried also an other function anchorize with same result.
Any help or advise will be welcomed to deal with this issue, if any.
In addition would it be possible to use alternatively the name of the directory in the content structure.

I think this might be very hacky or even have influence in other places, so careful, but you could define a frontmatter linktitle without accents and then use that instead of .Title. The problem is, that linktitle is used in automatic linking and you might see that un-accented result on a page.

I guess you need a readable ID for the anchor?

No. That is not where it is coming from.

{{ urlize "émissions" }} --> %C3%A9missions

Your objective is unclear.

Thank for the various answers.
My objective is to have a readable ID for the anchor (as noted by davidsneighbour) ideally coming from a variable already in frontmatter.
For example, how to change the result.
{{ urlize "émissions" }} --> %C3%A9missions
{{ urlize "émissions" }} --> emissions

Note that the directory’s name is with no accent. Is there a function to get the directory’s name ?

émissions is readable. That’s why:

{{ anchorize "émissions" }} --> émissions

If you want the directory name, look at File Variables, specifically .File.ContentBaseName.

1 Like

Fine, that’s it.
Thank you

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