Open bsciretti opened 4 years ago
ran into the same issue. solved this for me by using the language extension system in hugo and adding the menu info to each file for each language, e.g.,
filename with language extension: profile.en.md
url: "/en/profile/" menu: main: name: "Profile" weight: 2
additionally, i moved the language switcher to the header menu.
This seems to work
languages:
en:
languageName: 'English'
menu:
main:
- identifier: about
name: About Us
url: /about/
weight: 10
nl:
languageName: 'Nederlands'
menu:
main:
- identifier: blog
name: Over ons
url: /over-ons/
weight: 10
Double-check that themes/hello-friend-ng/lay-outs/partials/menu.html
uses relLangURL
(note the Lang
part) and that you don't overwrite it in a custom menu template.
I could not change the menu when switching language.
Here was the console output:
>hugo serve -D
Error: "${ProjectPath}\config.toml:1:1": unmarshal failed: toml: table menu already exists
TOML config:
# failing config.toml
[params]
enableGlobalLanguageMenu = true
[languages]
[languages.en]
languageName = 'English'
contentDir = 'content/en'
weight = 1
[menu]
[[menu.main]]
identifier = "home"
name = "Home"
url = "/"
weight = 1
[languages.fr]
contentDir = 'content/fr'
languageName = 'Français'
title = 'techxaucae'
weight = 4
[menu]
[[menu.main]]
identifier = "home-fr"
name = "Acceuil"
url = "/"
weight = 1
Changing the TOML like so worked fine:
# working config.toml
[params]
enableGlobalLanguageMenu = true
[languages]
[languages.en]
languageName = 'English'
contentDir = 'content/en'
weight = 1
[anguages.en.menu]
[[anguages.en.menu.main]]
identifier = "home"
name = "Home"
url = "/"
weight = 1
[languages.fr]
contentDir = 'content/fr'
languageName = 'Français'
weight = 4
[languages.fr.menu]
[[languages.fr.menu.main]]
identifier = "home-fr"
name = "Acceuil"
url = "/"
weight = 1
Ref: https://gohugo.io/content-management/multilingual/#menus
Hope it helps someone.
I'm trying to create a full multilingual website and, for some extent, it works, like in the string adaptation by language.
Btw, I found some problem:
I don't know if it's a fault in the documentation or an entire thing to add, in the latter case I can make a pull request :)