TranslationKey
Returns the translation key of the given page.
Syntax
PAGE.TranslationKey
Returns
string
The translation key creates a relationship between all translations of a given page. The translation key is derived from the file path, or from the translationKey parameter if defined in front matter.
With this site configuration:
defaultContentLanguage: en
languages:
  de:
    contentDir: content/de
    languageCode: de-DE
    languageName: Deutsch
    weight: 2
  en:
    contentDir: content/en
    languageCode: en-US
    languageName: English
    weight: 1
defaultContentLanguage = 'en'
[languages]
  [languages.de]
    contentDir = 'content/de'
    languageCode = 'de-DE'
    languageName = 'Deutsch'
    weight = 2
  [languages.en]
    contentDir = 'content/en'
    languageCode = 'en-US'
    languageName = 'English'
    weight = 1
{
   "defaultContentLanguage": "en",
   "languages": {
      "de": {
         "contentDir": "content/de",
         "languageCode": "de-DE",
         "languageName": "Deutsch",
         "weight": 2
      },
      "en": {
         "contentDir": "content/en",
         "languageCode": "en-US",
         "languageName": "English",
         "weight": 1
      }
   }
}
And this content:
content/
├── de/
│   ├── books/
│   │   ├── buch-1.md
│   │   └── book-2.md
│   └── _index.md
├── en/
│   ├── books/
│   │   ├── book-1.md
│   │   └── book-2.md
│   └── _index.md
└── _index.mdAnd this front matter:
---
title: Book 1
translationKey: foo
---+++
title = 'Book 1'
translationKey = 'foo'
+++{
   "title": "Book 1",
   "translationKey": "foo"
}
---
title: Buch 1
translationKey: foo
---+++
title = 'Buch 1'
translationKey = 'foo'
+++{
   "title": "Buch 1",
   "translationKey": "foo"
}
When rendering either either of the pages above:
{{ .TranslationKey }} → page/fooIf the front matter of Book 2, in both languages, does not include a translation key:
{{ .TranslationKey }} → page/books/book-2Last updated:
March 5, 2025
:
content: Remove "related" array from function and method pages (2fcd21ee5)
Improve this page
