docs/content/en/methods/site/Language.md
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.
The examples below assume the following language definition.
{{< code-toggle file=hugo >}} [languages.de] direction = 'ltr' label = 'Deutsch' locale = 'de-DE' weight = 2 {{< /code-toggle >}}
{{< new-in 0.158.0 />}}
(string) Returns the direction from the language definition.
{{ .Site.Language.Direction }} → ltr
{{< new-in 0.153.0 />}}
(bool) Reports whether this is the default language.
{{ .Site.Language.IsDefault }} → true
{{< new-in 0.158.0 />}}
(string) Returns the label from the language definition.
{{ .Site.Language.Label }} → Deutsch
{{<deprecated-in 0.158.0 />}}
Use Name instead.
{{<deprecated-in 0.158.0 />}}
Use Locale instead.
{{<deprecated-in 0.158.0 />}}
Use Direction instead.
{{<deprecated-in 0.158.0 />}}
Use Label instead.
{{< new-in 0.158.0 />}}
(string) Returns the locale from the language definition, falling back to Name.
{{ .Site.Language.Locale }} → de-DE
{{< new-in 0.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
{{<deprecated-in 0.158.0 />}}
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` }}"
>