Set to Home page different DefaultContentLanguage from the site

Hello! I’m new with Hugo. In my site conf I have the DefaultContentLanguage = "fr" but I want to set only in the home page (/) the DefaultContentLanguage to English.

So my site will look like this:
example.com/ → english
example.com/fr → french
example.com/post → french

I don’t think it is possible to only have a particular page set in a different language.

Have you checked: Multilingual Mode | Hugo?

If you enable multilingual mode your site languages will become something like (using fr as default):

example.com - fr
example.com/post/ - fr

If your user switches to English:
example.com/en/ - en
example.com/en/post/ - en (if you add an English version of your articles; otherwise, there’s nothing there)

Your theme will also need to be adjusted if it doesn’t have multilingual support built in. Like adding a language list or dropdown, or some links have to updated (for example: instead of absURL it should be absLangURL; or relURL it should be relLangURL in the theme’s code).

thank you :smiley: but the approach you mention doesn’t work for me :’(

I really need the example.com in en and the rest of the site in fr

another thing that may work, do you know if is possible to have the Multilingual Mode in only one page / type of content / content folder

for example:

/content
| - - /about
|     | - - index.fr.md
|     | - - index.en.md
| 
| - - /post (only fr)

I just thought of something, I use this in my landing page (since it’s only a list of links):

  1. Setup your site based on the Multilingual Mode | Hugo instructions.
  2. Edit your theme’s baseof.html (or whichever file is appropriate) and add:
    {{ with .Params.redirectto }}<meta http-equiv="refresh" content="0; url='{{ . }}'" />{{ end }}
    
  3. Then in the English .md files add this to the frontmatter:
    redirectto = ""
    

There is another possible way but I haven’t tried this (I only thought about this now) it’s by using Links and Cross References | Hugo.

{{< relref path="document.md" lang="fr" >}}

I think you can do something like this in your baseof.html file (or whichever is appropriate for your theme):

{{ if and (not .IsHome) (ne .Language.Lang "fr") }}<meta http-equiv="refresh" content="0; url='{{< relref path="document.md" lang="fr" >}}'" />{{ end }}

At least this way, you don’t have to add a frontmatter in each post.md file.

I hope it works, or some other way. Shalom!