I have two languages english and german. The english language is the default
languauge. The content of the browser is displayed in example.com/. But I would like to
see the content in example.com/en. and example.com/de How do I change this?
In /content/en and content/de I have a _index.md All links, the German-speaking
and English-speaking pages are displayed in the browser, regardless of the
language. Please have a look at my page.
… which is correct for the settings. The language switcher in the footer just goes to the top though, not to the equivalent URL. Like if you’re on Security in English, when you click the german button, it goes to the top of the German site.
Hmm. I’m just in the middle of setting up a similar one, with / for japanese and /en/ for the English, and, I have this kind of thing for my filenames in content:
about.md
about.en.md
I’m not sure if the name of the file has to be the same or not, to make Hugo recognize that about.en.md is a translation of about.md. Maybe if you want the url path to be different, try making the filenames the same root, and specify the slug inside the frontmatter?
security.de.md
security.en.md
And specify slug in the one that is supposed to be German language.
The above is speculation; sorry, I have not tried it.
Now I have two folder in the root dir. /en and /de. What I have to do that the content automatically switch to the one of the two languages? When I open the browser https://example.com the webserver This site is currently under construction. But I need example.com/en or example.com/de
You have that because that’s the way you set up Hugo, but Hugo doesn’t forward in this case (edit 1). If you want a subfolder per language, yet still need http://mydomain.com/ to jump to http://mydomain.com/de (or /en), then you need to set forwarding on the webserver side. If Apache, you’d do this with an .htaccess (you can store it in your /static folder).
Forwarding rules in Apache are troublesome (can’t say for nginx or caddy), so I’d go for specifying one language as main, keeping its files in the root, and having the second language as the “sub” on in a subfolder. Or get another domain and do multi-host.
Edit 1 - except, yes, you can set an alias on an individual page. I have not tested if you can do this with / (in its attached _index.md) and I doubt it would work.