Language
Returns the Language object for the given site.
Syntax
SITE.Language
Returns
langs.Language
The Language method on a Site object returns the Language object for the given site, derived from the language definition in your project configuration.
You can also use the Language method on a Page object. See details.
Methods
Use these methods on the Language object.
The examples below assume the following language definition.
languages:
de:
direction: ltr
label: Deutsch
locale: de-DE
weight: 2
[languages]
[languages.de]
direction = 'ltr'
label = 'Deutsch'
locale = 'de-DE'
weight = 2
{
"languages": {
"de": {
"direction": "ltr",
"label": "Deutsch",
"locale": "de-DE",
"weight": 2
}
}
}
Direction- New in v0.158.0
- (
string) Returns thedirectionfrom the language definition.{{ .Site.Language.Direction }} → ltr IsDefault- New in v0.153.0
- (
bool) Reports whether this is the default language.{{ .Site.Language.IsDefault }} → true Label- New in v0.158.0
- (
string) Returns thelabelfrom the language definition.{{ .Site.Language.Label }} → Deutsch Lang- Deprecated in v0.158.0
- Use
Nameinstead. LanguageCode- Deprecated in v0.158.0
- Use
Localeinstead. LanguageDirection- Deprecated in v0.158.0
- Use
Directioninstead. LanguageName- Deprecated in v0.158.0
- Use
Labelinstead. Locale- New in v0.158.0
- (
string) Returns thelocalefrom the language definition, falling back toName.{{ .Site.Language.Locale }} → de-DE Name- New in v0.153.0
- (
string) Returns the language tag as defined by RFC 5646. This is the lowercased key from the language definition.{{ .Site.Language.Name }} → de Weight- Deprecated in v0.158.0
Example
Some of the methods above are commonly used in a base template as attributes for the html element.
<html
lang="{{ .Site.Language.Locale }}"
dir="{{ or .Site.Language.Direction `ltr` }}"
>Last updated:
May 28, 2026
:
content: Replace h3 method sequences with description lists (c8e5b9fd2)
Improve this page