Listing available translations of pages in section/subsections


#1

I ported https://www.contributor-covenant.org/ to Hugo, and I’m running into non-deterministic behavior.

One page lists all the translations, using this code and this partial.
I don’t know if this is the correct approach, but here’s the weirdness:
The languageName for pt sometimes says Português do Brasil, which is the languageName for pt-br, and sometimes it says Português, as expected. The URLs are always correct.

If I save the config, without changing anything, the site rebuilds and I sometimes get the right one, sometimes the wrong one. Currently, our workaround is to manually trigger a deploy on Netlify (with no changes,) and hope for the best. :sweat_smile:

Any ideas why this would happen, or hints on how to do it in a reliable way?

I opened an issue on Hugo, but it was deemed not a bug.

Thanks.


#2

Replying to myself, in case someone else runs into the same issue.
The issue was that I was using .Site.Language.LanguageName, instead of .Language.LanguageName.
I don’t know why the former works (sometimes even correctly :wink:,) but changing it to the latter resolves the issue.