Customize Hugo Language slug

Hello

How can I customize Language slug?
I’m trying to make two versions of my website - one should be targeted on uk, link shoud look like www.mydomain.com/uk/ (with hreflang tag “en-gb”, I can add this tag in Language Params),
Other version should be targeted on “rest of the world” with www.mydomain.com/, with hreflang tag “en”.
My problem is that Hugo needs Language name, not the Country name, in Language Params.
How can I customize this parameter?

You can use language codes with the country!

Please note: use lowercase language codes, even when using regional languages (ie. use pt-pt instead of pt-PT). Currently Hugo language internals lowercase language codes, which can cause conflicts with settings like defaultContentLanguage which are not lowercased.

Have a look here:

I know that, but I would like to use Country name in url,
instead of this “www.domainname.com/en-gb/”, I would like to make this - “www.domainname.com/uk/” with hreflang tag “en-gb”.

This sort of describes the fundamental limitation:
https://github.com/gohugoio/hugo/issues/9109

[languages.de]
contentDir = 'content/de'
languageCode = 'de-DE'
languageName = 'Deutsch'
weight = 1

The de in the [languages.de] does three things:

  • It defines the directory under which the language-specific site is served
  • It defines the key used for localizing time, date, currency, etc. with github.com/gohugoio/locales
  • It defines the key used for translation lookups (i.e., files in the i18n directory)

These three things cannot be controlled separately.

The languageCode is currently used in two places only—internal templates for alias and rss.

1 Like

Thank you for your answer,
I will use Language name instead of Country name.

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