Multilingual

The Relearn theme works with Hugo’s multilingual mode.

It supports many languages, including right-to-left languages.

  • Arabic
  • Simplified Chinese
  • Traditional Chinese
  • Czech
  • Dutch
  • English
  • Finnish
  • French
  • German
  • Hindi
  • Hungarian
  • Indonesian
  • Italian
  • Japanese
  • Korean
  • Polish
  • Portuguese
  • Romanian
  • Russian
  • Spanish
  • Swahili
  • Turkish
  • Vietnamese

Translation by File Name

Here’s how to make your site multilingual using translations by file name:

  1. Set up languages in your hugo.toml file:

    hugo.
    defaultContentLanguage = 'en'
    
    [languages]
      [languages.en]
        languageCode = 'en'
        languageName = 'English'
        title = 'My Website'
        weight = 1
    
      [languages.pir]
        languageCode = 'art-x-pir'
        languageDirection = 'rtl'
        languageName = 'Pirrratish'
        title = 'Arrr, my Website'
        weight = 2
    defaultContentLanguage: en
    languages:
      en:
        languageCode: en
        languageName: English
        title: My Website
        weight: 1
      pir:
        languageCode: art-x-pir
        languageDirection: rtl
        languageName: Pirrratish
        title: Arrr, my Website
        weight: 2
    {
       "defaultContentLanguage": "en",
       "languages": {
          "en": {
             "languageCode": "en",
             "languageName": "English",
             "title": "My Website",
             "weight": 1
          },
          "pir": {
             "languageCode": "art-x-pir",
             "languageDirection": "rtl",
             "languageName": "Pirrratish",
             "title": "Arrr, my Website",
             "weight": 2
          }
       }
    }
  2. Duplicate your content files and add language codes to their file names:

    β”œβ”€β”€ content
    β”‚   β”œβ”€β”€ first-chapter
    β”‚   β”‚   β”œβ”€β”€ first-page
    |   |   |   β”œβ”€β”€ _index.en.md
    |   |   |   └── _index.pir.md
    β”‚   β”‚   β”œβ”€β”€ second-page
    |   |   |   β”œβ”€β”€ index.en.md
    |   |   |   └── index.pir.md
    β”‚   β”‚   β”œβ”€β”€ third-page.en.md
    β”‚   β”‚   └── third-page.pir.md
    β”‚   β”œβ”€β”€ _index.en.md
    β”‚   └── _index.pir.md
    β”œβ”€β”€ themes
    β”‚   └── hugo-theme-relearn
    β”‚       └── ...
    └── hugo.toml

Translation by Content Directory

The theme also support translations by content directory which can be configured in a similar way. This is not used in further examples of this documentation.

Search Settings

Check the search configuration for multilingual options.

Turn Off Language Switching

Option By default the theme shows a language switcher in the lower part of the menu.

To disable the language switcher set disableLanguageSwitchingButton=true

hugo.
[params]
  disableLanguageSwitchingButton = true
params:
  disableLanguageSwitchingButton: true
{
   "params": {
      "disableLanguageSwitchingButton": true
   }
}