DefaultContentLanguageInSubdir

Well, I’m back to Hugo after some months of deliberate absence.

I’m trying to mock-up a skeleton for my next website - which of course has multilingual content - and, after lot of searches, I found the very interesting “https://github.com/aubort/hugo/blob/multilingual-example/docs/content/content/multilingual.md” tutorial.

I correctly defined some basic translations and multi language content for my languages (English, Italian and Portuguese) and I can display them as expected: mydomain/about, mydomain/it.about, mydomain/br/about… and so on.
However, I would like to display the url of the english pages also with the ‘en’ slug, for sake of consistency. As far as I understand, if I define DefaultContentLanguageInSubdir as true in my config.toml, that would be achieved, but this is not the case. I experimented with the true and false, publishing and comparing the published folder: they are absolutely identical.

Of course, there’s something I misunderstood. Could someone kindly point me to the right direction?

Many thanks,
Andrea

Have you defined en as defaultContentLanguage? It is hard to guess without seeing the source.

Yes, defaultContentLanguage is enabled. I try both with it enabled and disabled, nothing changes…

OK, so then there is something here we don’t see, which means you will have to post a link to your Hugo source for us to be able to help you further.

Here it is my bare config. I started from scratch, just to check everything. Same behaviour…

# general setup
baseurl = "http://replace-this-with-your-hugo-site.com/"
title = "My New Hugo Site"
theme = "hugo4"

# languages 
languageCode = "en-us"
defaultContentLanguage = "en"
defaultContenLanguageInSubdir = "true"

[languages.en]
[languages.it]
[languages.br]

When I browse, I still have the english ‘about’ page under mydomain/about and the italian and portugues version respectively under mydomain/it/about and mydomain/br/about.
Any clue?

Well, I do not have how to provide a link, as I’m working on a local machine. Have you some ready multi language skeleton which work as intended, to use as a reference and to learn from?

I’m also interested in any good multi-language template/skeleton with best practices included (menus, localizations for typical content like posts and unique custom pages).

Any news on this issue?

I’ve began to create such an example in my theme “MoodleBox”: It’s not finished, but you may find something useful. See it in action here: moodlebox.net

1 Like

I moved the lines

defaultContentLanguage = "en"
defaultContenLanguageInSubdir = "true"

from the end to almost the beginning of the toml file and they began working as expected. Of course, it is strange to me that the place in the toml file had such an impact (i.e., that when the commands were at the end of the file, they were ignored).

1 Like

This fixed it for me!

moving:

defaultContentLanguage = 'en'
defaultContentLanguageInSubdir = false

higher in the config file made it apply!