Hello everyone, before posting i was trying to use chat gpt and of course i was searching solution on this forum and stackoverflow… I have problem with adding to theme language switcher.
simple code:
<ul>
{{ range $.Site.Home.AllTranslations }}
<li><a href="{{ .Permalink }}">{{ .Language.LanguageName }}</a></li>
{{ end }}
</ul>
Also, if you’re transpiling Sass to CSS using the “dartsass” option, you’ll need to install Dart Sass instead of whatever sass executable is currently installed.
Error: failed to create config from result: failed to decode "languages": config value "pl-pl" for defaultContentLanguage does not match any language definition
When I change it to the correct value:
defaultContentLanguage = 'pl'
The site builds without error and the language switcher works great.
thanks for your answer, this really makes me wonder because according to what you write I measured the value to “pl” (and to “en”) and I still have the same thing. also I created a new directory with a clean hugo to check and all the time it doesn’t display my switcher correctly.
I’m not sure what to tell you; I cannot reproduce the problem with your site and the configuration correction that I described above. Maybe you can look at this simple working example to figure out what you’re doing differently/wrong:
git clone https://github.com/jmooring/hugo-multilingual-example
cd hugo-multilingual-example
hugo server
You can name the site configuration file either “config.toml” or “hugo.toml” (preferred). I’m not sure what you did, but the “fix” has nothing to do with the file name.