mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-18 21:11:19 +02:00
Merge commit '8b9803425e63e1b1801f8d5d676e96368d706722'
This commit is contained in:
@@ -35,7 +35,7 @@ Lang
|
||||
```
|
||||
|
||||
LanguageCode
|
||||
: (`string`) The language code from the site configuration.
|
||||
: (`string`) The language code from the site configuration. Falls back to `Lang` if not defined.
|
||||
|
||||
```go-html-template
|
||||
{{ .Site.Language.LanguageCode }} → de-DE
|
||||
@@ -68,16 +68,10 @@ Some of the methods above are commonly used in a base template as attributes for
|
||||
|
||||
```go-html-template
|
||||
<html
|
||||
lang="{{ or site.Language.LanguageCode site.Language.Lang }}"
|
||||
dir="{{ or site.Language.LanguageDirection `ltr` }}
|
||||
lang="{{ .Site.Language.LanguageCode }}"
|
||||
dir="{{ or .Site.Language.LanguageDirection `ltr` }}
|
||||
>
|
||||
```
|
||||
|
||||
The example above uses the global [`site`] function instead of accessing the `Site` object via the `.Site` notation.
|
||||
|
||||
Also note that each attribute has a fallback value assigned via the [`or`] operator.
|
||||
|
||||
[details]: /methods/page/language
|
||||
[details]: /methods/page/language/
|
||||
[RFC 5646]: https://datatracker.ietf.org/doc/html/rfc5646
|
||||
[`or`]: /functions/go-template/or
|
||||
[`site`]: /functions/global/site
|
||||
|
Reference in New Issue
Block a user