hugo
hugo copied to clipboard
Add languagePrefix to language config
What version of Hugo are you using (hugo version
)?
$ hugo version hugo v0.92.0-B3549403+extended windows/amd64 BuildDate=2022-01-12T08:23:18Z VendorInfo=gohugoio
Does this issue reproduce with the latest release?
Yes!
When I set 'languageCode' with uppercase letters in the configuration file, the generated language folder name is still lowercase.
Language config:
disablePathToLower = true
[en]
contentDir = 'content/en'
languageName = 'English'
languageCode = 'en'
weight = 10
title = "My New Hugo Site"
[zh-Hans]
contentDir = 'content/zh-Hans'
languageName = '简体中文'
languageCode = 'zh-Hans'
weight = 20
title = "我的新Hugo站点"
Generated directory:
First, I assume that you placed disablePathToLower = true
in the root table of your site config, or in one or more of the [languages.xx]
tables. As shown, under the [languages]
table, the build will throw en error.
Error: Failed to parse multilingual config: Language config is not a map: bool
Second, disablePathToLower
has no effect on the public/langcode directory name. It will always be lowercase.
Third, be aware of this proposal: https://github.com/gohugoio/hugo/issues/9171
Finally, be aware of this issue: https://github.com/gohugoio/hugo/issues/9109
If you use zh-Hans
instead of zh_hans
, localization of dates, currencies, numbers, and percentages will fail.
@jmooring I read these questions carefully. I fully understand the original intention of this design, but I think the choice should be left to the user, determined by the user's configuration, not by Hugo's default decision.
Can anyone tell me this problem will be fixed?
This is counterintuitive and problematic when trying to migrate an existing website to Hugo without breaking existing URLs on a case-sensitive server.