Localization
Localization lets editors maintain content in several languages. It doesn't translate the Pages CMS interface. For the editing side, see Edit translations.
Pick the scheme that matches how your site already stores translations:
files: one file per language, such asabout.mdandabout.fr.md.fields: language keys inside one file, such astitle: { en: About, fr: À propos }.
1. Declare your languages
At the root of .pages.yml:
i18n:
default: en
locales:
- en
- code: fr
label: FrançaisCodes must match exactly what's in your filenames or keys. Labels are optional. Up to 50 languages.
2. Localize content
Add i18n to each collection or file that has translations. Everything else stays single-language.
One file per language
In .pages.yml, configure the collection to use one file per language:
content:
- name: posts
type: collection
path: content/posts
i18n:
scheme: files
path:
type: filename
position: suffix
default: omit
fields:
- name: title
type: string
- name: body
type: rich-textThis pairs content/posts/about.md (English) with content/posts/about.fr.md (French).
path describes where each language's file lives. It's required for this scheme.
By filename:
By folder, with type: folder. For the file content/posts/guides/about.md and default: omit, French goes to:
after must name an exact ancestor folder. Single files support filename rules and the root, parent and custom folder positions.
With default: omit, names that look like translations are reserved. For example, an English file can't be called about.fr.md.
Languages in one file
In .pages.yml, mark the fields that have a value for each language:
content:
- name: home
type: file
path: data/home.json
i18n:
scheme: fields
fields:
- name: title
type: string
localized: true
- name: published
type: booleanFor example, data/home.json could contain:
{
"title": { "en": "Home", "fr": "Accueil" },
"published": true
}Fields marked localized: true hold one value per language; unmarked fields are shared. Where you put localized decides the shape:
Mark only one level: don't add localized inside something that's already localized.
This scheme works with JSON, YAML, TOML and their front matter variants. The Markdown body can't be localized inside one file; use one file per language for translated bodies.
Per-content languages
A collection or file inherits every project language. To use a subset, set locales on its i18n; this replaces the project list. If that subset leaves out the project's default, also set default.
i18n:
scheme: files
locales: [en, de]
path: { type: filename, position: suffix }Good to know
- Missing translations don't fall back to another language. Your site decides what to show.
- Required localized fields need a value in every language.
- Keys Pages CMS doesn't recognize are preserved.
- Reference fields pick entries in the current language when the target collection is localized;
{locale}is available in their templates. - Localization uses the normal create, edit, rename and delete permissions. There are no per-language permissions.