Why language homepage is a redirect to default homepage

Hi every one!

I have created a site with Hugo which have two languages: “en” and “it” and written the usual setting:

defaultContentLanguage = “en-us”
defaultContentLanguageInSubdir = true

in the config.toml. I also set up aws lambda edge to redirect user’s requests to page “www_mysite_com” with “accept-language” header to “www_mysite_com/it” if the broswer has this default language and to “www_mysite_com/en” otherwise. Now, the problem is, that the “www_mysite_com/en” page is only a redirect to the “www_mysite_com” which trigger the function again and send the user to “www.mysite.com/it” again, even if the user want to see the english page.

So my question is: why the english home page is a riderect? How can I prevent this behaviour?

Thanks for your work!

What about defaultContentLanguage = "en"?

Thanks for the replay.

Changed (it’s more correct), but I still have the same redirect in public/en/index.html. I don’t understand how can I control it.

Mistery solved: I placed the defaultContentLanguage = "en" and defaultContentLanguageInSubdir = true after the

[languages]
  [languages.it]
    title = "Linfa Robonica Serra idroponica"
    weight = 2

section, which prevent them to be parameters with the intended meaning (Hugo fundamentally interpreted them as languages.languages.it.defaultContentLanguage and ignored them)

1 Like