Skip to content

Latest commit

 

History

History
89 lines (68 loc) · 2.69 KB

2-languages.md

File metadata and controls

89 lines (68 loc) · 2.69 KB

Languages

These options define the main language of the site and, for a multilingual website, its additional languages.

language

The main language, defined by its code.

language: <code> # unique code (`en` by default)

By default, only the paths of the other languages pages are prefixed with their language code, but you can also prefix the paths of the main language pages with the following option:

#language: <code>
language:
  code: <code>
  prefix: true

:::info When prefix is set to true, an alias is automatically created for the home page that redirects from / to /<code>/. :::

languages

Options of available languages, used for pages and templates localization.

languages:
  - code: <code>          # unique code, `xx` or `xx-XX` (required, e.g.: `en`, `fr`, `en-US`, `fr-CA`)
    name: <name>          # human readable name (e.g.: `Français`)
    locale: <locale>      # locale code (required, `language_COUNTRY`, e.g.: `en_US`, `fr_FR`, `fr_CA`)
    enabled: <true|false> # enabled or not (`true` by default)

Example:

language: en
languages:
  - code: en
    name: English
    locale: en_US
  - code: fr
    name: Français
    locale: fr_FR

:::info A locale code list is available if needed. :::

Localize

To localize configuration options you must store them under the config key of the language.

Example:

title: "Cecil in English"
languages:
  - code: en
    name: English
    locale: en_US
  - code: fr
    name: Français
    locale: fr_FR
    config:
      title: "Cecil en français"

:::info In templates you can access an option with {{ site.<option> }}, for example {{ site.title }}.
If an option is not available in the current language (e.g.: fr), it falls back to the global one (e.g.: en). :::

The localized options are validated like the global ones: the effective value of the language (the global value overridden by the localized one) must be valid.

Some options apply to the whole site and can't be localized: language, languages, theme, cache, extensions, optimize, server, data, static, pages.dir, pages.ext, pages.frontmatter, pages.converter, pages.generators, pages.default, output.dir, output.formats, output.postprocessors, layouts.dir, layouts.extensions, layouts.autoescape and assets.dir. They are ignored, with a warning, if they are set under the config key of a language.