Hugo not redirecting to default language

After the languages were set in config.toml with this:

defaultContentLanguage = "pt"

LanguageName = "Português"

LanguageName = "English"

visiting localhost:1313 we still see the content in English and not the default Portuguese. What could be causing this?

I have no idea based on the little you’re showing us.

I’m unsure what else would be relevant … the site is using this theme:

And the content is structured this way:

- posts
   |_ post_1/
   |_ post_2/

Also tried with my own blog, and it’s still redirecting to /en instead of the defaultContentLanguage set in config.toml

I think you need to link to a “failing site”.

I was able to reproduce on a ‘clean’ version, without the original content:

lift every root level options (like: DefaultContentLanguage = "pt") to the top of your config.toml

You can’t have nested options, for example:

  # Site author
  author = "Marvin"

like this and then define root level options, for example:

DefaultContentLanguage = "pt"

Root level options has to be defined at the top, like this:

DefaultContentLanguage = "pt"

  # Site author
  author = "Marvin"



Yeah that fixed it … thank you for your help!

Woah. Thanks for finding the issue. I had the same issue.

But why the heck do all root keys have to go first? Is that some TOML or hugo thing?

This is an old thread, but if I recall correctly, Hugo expects that to be at the root, so it’s both a Toml structure issue and Hugo’s expectation that we have defined those parameters in the right place.