Multilingual Menu & URL Issue with Blowfish Theme

Can’t get language switcher to appear + “Articles” menu doesn’t link to /posts/

Hi everyone,

I’m using the Blowfish theme and running into two issues:

  1. The language switcher doesn’t appear in the top menu (even though ShowLanguageSwitcher = true is set).
  2. When I click the Articles menu item, it just redirects to /fr/ instead of /fr/posts/.

Here’s my config.toml:

toml

baseURL = "https://wilonweb.github.io/multi-author/"
languageCode = "fr"
title = "ClubCode"
theme = "blowfish"
defaultContentLanguage = "fr"
defaultContentLanguageInSubdir = true

[params]
  defaultTheme = "auto"
  ShowReadingTime = true
  ShowPostNavLinks = true
  disableFingerprinting = true
  disableSRI = true
  ShowLanguageSwitcher = true

[languages]

[languages.fr]
languageName = "Français"
weight = 1

[languages.es]
languageName = "Español"
weight = 2

[languages.ar]
languageName = "العربية"
weight = 3

[languages.ar.params]
rtl = true

[[menu.main]]
name = "Accueil"
pageRef = "/"
weight = 1

[[menu.main]]
name = "Articles"
pageRef = "/posts/"
weight = 2

Links:

Thanks in advance for any help or tips!

brief first check:

You use menu in site.config, so define that for all languages see Multilingual Mode Menus

and move the languageCode param to each language

updated because of comment from @deining regarding contentDir

[languages]
   [languages.fr]
      languageName = "Français"
      languageCode = "fr-FR"
      contentDir   = "content/fr"
      weight       = 1
      [languages.fr.params]
         displayName = "Français"
      [languages.fr.menus]
         [[languages.fr.menus.main]]
            name    = "Accueil"
            pageRef = "/"
            weight  = 1
         [[languages.fr.menus.main]]
            name    = "Articles"
            weight  = 2
            pageRef = "/posts/"
1 Like

The language switcher is actually there, but all display names for the languages are not set. You have to add them to your config file, like this:

[languages]

[languages.fr]
languageName = "Français"
weight = 1
[languages.fr.params]
displayName = "Français"
...

I authored a PR for your repo that fixes this issue.

1 Like

You missed to specify the contentDir setting. With the settings below the link to ´/posts/`works.

[languages.fr]
languageName = "Français"
contentDir = "content/fr"
weight = 1
[languages.fr.menus]
      [[languages.fr.menus.main]]
        name = 'Accueil'
        pageRef = '/'
        weight = 1
      [[languages.fr.menus.main]]
        name = 'Articles'
        pageRef = '/posts/'
        weight = 2
...

It might be a good idea to have split up the configuration into multiple separate settings files::

config/_default/hugo.toml
config/_default/languages.toml
config/_default/menus.fr.toml
config/_default/menus.es.toml
...
2 Likes

mmh, if I remember correctly it’s either

  • config file
    or
  • config directory
1 Like

No, I just tried it out, you can have hugo.toml in your root directory plus config/_default/languages.toml and hugo picks up both.

But you are right, it’s certainly better to have both file in the same place:

config/_default/hugo.toml
config/_default/languages.toml

I edited and improved my answer accordingly.

1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.