rhazdon / hugo-theme-hello-friend-ng

Pretty basic theme for Hugo that covers all of the essentials. All you have to do is start typing!
https://github.com/rhazdon/hugo-theme-hello-friend-ng/
Other
1.45k stars 761 forks source link

Issues with multilingualism #164

Open bsciretti opened 4 years ago

bsciretti commented 4 years ago

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:

  1. The menu options are the same, in the main language. While clicking it doesn't return the correct language but the main language page
  2. There's no menu choice for languages such in other themes

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 :)

questoph commented 3 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.

TheGroundZero commented 2 years ago

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.

exaucae commented 2 years ago

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.