Files
hugo/content/en/content-management/multilingual.md
T
Bjørn Erik Pedersen e7afabb927 Squashed 'docs/' changes from 80dd7b067..0755fb534
0755fb534 misc: Update docs.yaml
f0c69a38c content: Remove outdated content
43ce895b9 content: Remove outdated new-in badges
c3a382fb7 content: Improve GitLab Pages workflow example
f2a851966 content: Update Vimeo example
044565ab3 content: Fix typo
9f5e8b5f4 content: Update version references
9dc30f225 theme: Address deprecations in v0.158.0
ea0787a6b content: Document css.Build function
f98e4f55c content: Standardize Node.js references
bf683e36f content: Use consistent file system terminology
54ed4c12b content: Document strings.ReplacePairs
779d37978 all: Miscellaneous updates for v0.158.0
be1a20c27 Update HUGO_VERSION to 0.158.0
24cdd7bf7 Fix typos in module configuration documentation
ce37e7b05 content: Address Markdown linting error
592049f02 content: Remove unnecessary workflow customization section
b17b18ce1 content: Update version references in hosting guides
32ec89596 content: Improve urls.PathEscape/PathUnescape examples
9297bb6fa content: Clarify page collection sort order
60192a16f content: Add reference link to glossary term
63d4a992a content: Update documentation contribution guide
946273d67 theme: Adjust feature state notices
d70dfd651 theme: Simplify border classes per Tailwind linter
fc53c7263 theme: Refactor feature status shortcodes
850dc5b2b content: Clean up content for deprecated features
35da1aa3c content: Miscellaneous udpates for v0.157.0
05b69f84e content: More site-to-project changes
291ffc3f6 content: Add blogger2hugo migration tool
53a1bdee3 Update HUGO_VERSION to 0.157.0
808f0431d Merge branch 'tempv0.157.0'
f02222e46 docs: Regen and fix the imaging docshelper output
b0d3364f1 Merge commit '0c2fa2460f485e0eca564dcccf36d34538374922'
d1f37cc6d resources/images: Adjust WebP processing defaults
9a9f02fb8 Add per-request timeout option to `resources.GetRemote`
900c10201 docs: Fix lineNos default value in docs.yaml
0052c975a docs: Regenerate docs.yaml
3e2f98235 Merge commit '8f3c066d23f431fb2c53d97ea489e4c28b42bd82'
dbfd34a1a docs: Update docs.yaml
7e1a08e54 Merge commit '08e1ea5c709d3d49bdc3ce3c21e8fa05a33150d0'
cb6e0a42a tpl: Add missing functions to init files
05544e400 markup/asciidocext: Improve Asciidoctor integration
820b5536a github: Add ai-watchdog workflow and update other workflows' versions
3848aec5f markup/goldmark: Enhance footnote extension with backlinkHTML option
070074dac markup/goldmark: Enhance footnote extension with auto-prefixing option
f92f7ac5c config/security: Add PROGRAMDATA to the osenv allowlist
d1ab84530 minifiers: Update deprecation handling
6c911d1e5 Merge commit 'bfa74537929f409fca841540b971125b7678963a'
61916ab4c resources/page: Add :sectionslug and :sectionslugs permalink tokens
80667667c Add Ancestors (plural) method to GitInfo, rename Ancestor field to Parent
e8fdc1d4d source: Expose Ancestor in GitInfo
079671b41 Merge commit 'bb147f91ee9078e6a55e8c32ab4b2e5dbc5cee45'
9e8a08520 images: Add option for vertical alignment to images.Text
f7c795479 Merge commit 'b3d87dd0fd746f07f9afa6e6a2969aea41da6a38'
283e97783 Merge commit '5be51ac3db225d5df501ed1fa1499c41d97dbf65'
4c6ec5c19 resources/page: Revise the new contentbasename permalinks tokens
fc69d3981 resources/page: Add :contentbasename and :contentbasenameorslug permalink tokens
c5f654716 modules: Add GOAUTH to module config
2a1a832fb js/esbuild: Add drop option
d9fb55352 Merge commit 'a024bc7d76fcc5e49e8210f9b0896db9ef21861a'
84678f5af helpers: Add Chroma styles to docs.yaml
fc8d9e344 Merge commit '346b60358dd8ec2ca228e6635bff9d7914b398b7'
4e4da5e47 Merge commit '81a7b6390036138356773c87a886679c81c524e1'
5df38fde0 docs: Regen CLI docs
3b0f8034b tpl/images: Change signature of images.QR to images.QR TEXT OPTIONS
68187036f images.Text: Add "alignx" option for horizontal alignment
240a85734 docs: Regen CLI docs
21b2917c6 Merge commit 'e9fbadacc3f09191e2e19f112a49777eeb8df06c'
5cc7ad562 tpl/images: Add images.QR function
9b588ee9e Update gocloud and docs for S3-Compatible Endpoints
b24377040 tpl/tplimpl: Update details shortcode
0535f4b22 tpl/tplimpl: Add details shortcode
2dd21cf90 Merge commit 'e477373487abcccdbed95688e37aa74b9b8fc198'
869321ffa dartsass: Add silenceDeprecations option
492981933 Merge commit '838bd312b1a287bb33962ad478dbc54737654f35'
c79b7d840 docs: Regen CLI docs
101410f08 docs: Regenerate CLI docs
700846bc9 Merge commit 'de0df119b504a91c9e1f442b07954f366ffb2932'
1fb46bb7c docs: Regen CLI docs
923fd9044 commands: Add "hugo build" as an alias for "hugo"
244ea3067 Merge commit '39fd3b557014e339bc6c68a7ff34a7734a735ee0'
f2e8913d2 Add support for Obsidian type blockquote alerts
9777cfa83 Merge commit 'dec8cd4ada29218971743333f8ac662a9c06aad8'
b3f6d546c output: Fix docshelper template lookup order for AMP pages
476507712 Add config options page.nextPrevSortOrder/nextPrevInSectionSortOrder
b2507b8ab tpl/transform: Make Plainify and ToMath return template.HTML
154525780 docs: Regen docshelper
9d9a0848c Merge commit 'a6e635ca7d905d9ec3ffd708db2694f680b03aae'
b56a8baa1 math: Add trigonometric functions and some angle helper functions
59f708c0e source: Expose GitInfo Body
7a330c378 Merge commit '8b9803425e63e1b1801f8d5d676e96368d706722'
1ea10926d deploy: Add stripIndexHtml target option
903da161a markup/goldmark: Add the Hugo Goldmark Extras "delete" extension
63cf1ea35 deps: Upgrade github.com/alecthomas/chroma v2.13.0 => v2.14.0
6dcbebe11 config: Remove extraneous BuildConfig setting
1c89b76c2 docs: Regen docshelper
976b30877 markup/goldmark: Support extras extension
0da4eee49 commands: Add gen chromastyles --lineNumbersTableStyle flag
daf545b56 docs: Regen docshelper
a46a8ac97 all: Fix duplicate words in comments
9a3c76650 tpl/tplimpl: Optionally exclude content from sitemap
737b3b210 tpl/tplimpl: Update Google Analytics template and config
9283d3071 docs: Regen CLI docs
fa0437be3 docs: Regen docshelper
c318cd850 docs: Fix hyphens and grammar in synopsis of command 'hugo server'
5896f23a9 js: Support JSX and JSXImportSourceOptions
08b0bca77 Merge commit '2658a71e1b6fe24a8b754a62ce0398a09d270d86'
c4c5be6c2 docs: Regen docshelper
ec07d66fe Add images.Dither filter
3b23f2b89 docs: Regen CLI docs
d1c5d6a5e docs: Regenerate docshelper
6c8c9da77 Merge commit '6efb279bfacbd7304cef994be8181c6f804e7dd4'
5ce83ee91 docs: Make null booleans falsy in the docs helper
1185cfc71 docs: Regen docs helper
aab11aad7 Merge commit '9b0050e9aabe4be65c78ccf292a348f309d50ccd' as 'docs'

git-subtree-dir: docs
git-subtree-split: 0755fb534d8b4cde8a0227698da634e3536283ff
2026-03-23 18:21:25 +01:00

12 KiB

title, linkTitle, description, categories, keywords, aliases
title linkTitle description categories keywords aliases
Multilingual mode Multilingual Localize your project for each language and region, including translations, images, dates, currencies, numbers, percentages, and collation sequence. Hugo's multilingual framework supports single-host and multihost configurations.
/content/multilingual/
/tutorials/create-a-multilingual-site/

Configuration

See configure languages.

Translate your content

There are two ways to manage your content translations. Both ensure each page is assigned a language and is linked to its counterpart translations.

Translation by file name

Considering the following example:

  1. /content/about.en.md
  2. /content/about.fr.md

The first file is assigned the English language and is linked to the second. The second file is assigned the French language and is linked to the first.

Their language is assigned according to the language code added as a suffix to the file name.

By having the same path and base file name, the content pieces are linked together as translated pages.

Note

If a file has no language code, it will be assigned the default language.

Translation by content directory

This system uses different content directories for each of the languages. Each language's content directory is set using the contentDir parameter.

{{< code-toggle file=hugo >}} [languages.en] contentDir = 'content/english' label = "English" weight = 10

[languages.fr] contentDir = 'content/french' label = "Français" weight = 20 {{< /code-toggle >}}

The value of contentDir can be any valid path -- even absolute path references. The only restriction is that the content directories cannot overlap.

Considering the following example in conjunction with the configuration above:

  1. /content/english/about.md
  2. /content/french/about.md

The first file is assigned the English language and is linked to the second. The second file is assigned the French language and is linked to the first.

Their language is assigned according to the content directory they are placed in.

By having the same path and basename (relative to their language content directory), the content pieces are linked together as translated pages.

Bypassing default linking

Any pages sharing the same translationKey set in front matter will be linked as translated pages regardless of basename or location.

Considering the following example:

  1. /content/about-us.en.md
  2. /content/om.nn.md
  3. /content/presentation/a-propos.fr.md

{{< code-toggle file=hugo >}} translationKey: "about" {{< /code-toggle >}}

By setting the translationKey front matter parameter to about in all three pages, they will be linked as translated pages.

Because paths and file names are used to handle linking, all translated pages will share the same URL (apart from the language subdirectory).

To localize URLs:

  • For a regular page, set either slug or url in front matter
  • For a section page, set url in front matter

For example, a French translation can have its own localized slug.

{{< code-toggle file=content/about.fr.md fm=true >}} title: A Propos slug: "a-propos" {{< /code-toggle >}}

At render, Hugo will build both /about/ and /fr/a-propos/ without affecting the translation link.

Page bundles

To avoid the burden of having to duplicate files, each Page Bundle inherits the resources of its linked translated pages' bundles except for the content files (Markdown files, HTML files etc.).

Therefore, from within a template, the page will have access to the files from all linked pages' bundles.

If, across the linked bundles, two or more files share the same basename, only one will be included and chosen as follows:

  • File from current language bundle, if present.
  • First file found across bundles by order of language Weight.

Note

Page Bundle resources follow the same language assignment logic as content files, both by file name (image.jpg, image.fr.jpg) and by directory (english/about/header.jpg, french/about/header.jpg).

Translation of strings

See the lang.Translate template function.

Localization

The following localization examples assume your project's primary language is English, with translations to French and German.

{{< code-toggle file=hugo >}} defaultContentLanguage = 'en'

[languages] [languages.en] contentDir = 'content/en' label = 'English' weight = 1 [languages.fr] contentDir = 'content/fr' label = 'Français' weight = 2 [languages.de] contentDir = 'content/de' label = 'Deutsch' weight = 3

{{< /code-toggle >}}

Dates

With this front matter:

{{< code-toggle file=hugo >}} date = 2021-11-03T12:34:56+01:00 {{< /code-toggle >}}

And this template code:

{{ .Date | time.Format ":date_full" }}

The rendered page displays:

Language Value
English Wednesday, November 3, 2021
Français mercredi 3 novembre 2021
Deutsch Mittwoch, 3. November 2021

See time.Format for details.

Currency

With this template code:

{{ 512.5032 | lang.FormatCurrency 2 "USD" }}

The rendered page displays:

Language Value
English $512.50
Français 512,50 $US
Deutsch 512,50 $

See lang.FormatCurrency and lang.FormatAccounting for details.

Numbers

With this template code:

{{ 512.5032 | lang.FormatNumber 2 }}

The rendered page displays:

Language Value
English 512.50
Français 512,50
Deutsch 512,50

See lang.FormatNumber and lang.FormatNumberCustom for details.

Percentages

With this template code:

{{ 512.5032 | lang.FormatPercent 2 }}

The rendered page displays:

Language Value
English 512.50%
Français 512,50 %
Deutsch 512,50 %

See lang.FormatPercent for details.

Menus

Localization of menu entries depends on how you define them:

  • When you define menu entries automatically using the section pages menu, you must use translation tables to localize each entry.
  • When you define menu entries in front matter, they are already localized based on the front matter itself. If the front matter values are insufficient, use translation tables to localize each entry.
  • When you define menu entries in your project configuration, you must create language-specific menu entries under each language key. If the names of the menu entries are insufficient, use translation tables to localize each entry.

Create language-specific menu entries

Method 1 -- Use a single configuration file

For a simple menu with a small number of entries, use a single configuration file. For example:

{{< code-toggle file=hugo >}} [languages.de] label = 'Deutsch' locale = 'de-DE' weight = 1

languages.de.menus.main name = 'Produkte' pageRef = '/products' weight = 10

languages.de.menus.main name = 'Leistungen' pageRef = '/services' weight = 20

[languages.en] label = 'English' locale = 'en-US' weight = 2

languages.en.menus.main name = 'Products' pageRef = '/products' weight = 10

languages.en.menus.main name = 'Services' pageRef = '/services' weight = 20 {{< /code-toggle >}}

Method 2 -- Use a configuration directory

With a more complex menu structure, create a configuration directory and split the menu entries into multiple files, one file per language. For example:

config/
└── _default/
    ├── menus.de.toml
    ├── menus.en.toml
    └── hugo.toml

{{< code-toggle file=config/_default/menus.de >}} main name = 'Produkte' pageRef = '/products' weight = 10 main name = 'Leistungen' pageRef = '/services' weight = 20 {{< /code-toggle >}}

{{< code-toggle file=config/_default/menus.en >}} main name = 'Products' pageRef = '/products' weight = 10 main name = 'Services' pageRef = '/services' weight = 20 {{< /code-toggle >}}

Use translation tables

When rendering the text that appears in menu each entry, the example menu template does this:

{{ or (T .Identifier) .Name | safeHTML }}

It queries the translation table for the current language using the menu entry's identifier and returns the translated string. If the translation table does not exist, or if the identifier key is not present in the translation table, it falls back to name.

The identifier depends on how you define menu entries:

  • If you define the menu entry automatically using the section pages menu, the identifier is the page's .Section.
  • If you define the menu entry in your project configuration or in front matter, set the identifier property to the desired value.

For example, if you define menu entries in project configuration:

{{< code-toggle file=hugo >}} menus.main identifier = 'products' name = 'Products' pageRef = '/products' weight = 10 menus.main identifier = 'services' name = 'Services' pageRef = '/services' weight = 20 {{< / code-toggle >}}

Create corresponding entries in the translation tables:

{{< code-toggle file=i18n/de >}} products = 'Produkte' services = 'Leistungen' {{< / code-toggle >}}

Missing translations

If a string does not have a translation for the current language, Hugo will use the value from the default language. If no default value is set, an empty string will be shown.

While translating a Hugo website, it can be handy to have a visual indicator of missing translations. The enableMissingTranslationPlaceholders configuration option will flag all untranslated strings with the placeholder [i18n] identifier, where identifier is the id of the missing translation.

Note

Hugo will generate your website with these missing translation placeholders. It might not be suitable for production environments.

For merging of content from other languages (i.e. missing content translations), see lang.Merge.

To track down missing translation strings, run Hugo with the --printI18nWarnings flag:

hugo build --printI18nWarnings | grep i18n
i18n|MISSING_TRANSLATION|en|wordCount

Multilingual themes support

To support Multilingual mode in your themes, some considerations must be taken for the URLs in the templates. If there is more than one language, URLs must meet the following criteria:

  • Come from the built-in .Permalink or .RelPermalink
  • Be constructed with the relLangURL or absLangURL template function, or be prefixed with {{ .LanguagePrefix }}

If there is more than one language defined, the LanguagePrefix method will return /en (or whatever the current language is). If not enabled, it will be an empty string (and is therefore harmless for single-language Hugo websites).

Generate multilingual content with hugo new content

If you organize content with translations in the same directory:

hugo new content post/test.en.md
hugo new content post/test.de.md

If you organize content with translations in different directories:

hugo new content content/en/post/test.md
hugo new content content/de/post/test.md