I’ve been trying to find a way to customise the language URL but retaining the correct ISO language code in HTML.
- Keep the lang="" value correct as per ISO, in this case “ko” for Korean
- The URL should reflect the commonly known two-letter code: in this case “kr” so it should be domain.tld/kr/
So far, I tried the following:
- Add a languageCode per language – the URL changed but so did the lang=""
[languages.kr] languageCode = "ko"
- html lang=“kr”
- Add [languages.ko.permalinks] – did not work
[languages.ko] [languages.ko.permalinks] "/" = "/kr/:slug/" posts = "/kr/:slug-:year:yearday/"
- html lang=“ko”
- Add baseURL per language – default language URL stopped working
[languages.en] baseURL = "domain.tld" [languages.ko] baseURL = "domain.tld/kr"
- The default language is now: domain.tld/en/ when hugo is generating the files. However it works fine as “hugo server”.
- Korean: domain.tld/kr
Anything I missed?
- Theme tested on: hugo-future-imperfect-slim
– I haven’t tried testing in another site I’m preparing for multilingual which is using a different theme. I got stuck with this one.