summaryrefslogtreecommitdiffstats
path: root/docs/content/en/methods/page/Translations.md
diff options
context:
space:
mode:
Diffstat (limited to 'docs/content/en/methods/page/Translations.md')
-rw-r--r--docs/content/en/methods/page/Translations.md11
1 files changed, 6 insertions, 5 deletions
diff --git a/docs/content/en/methods/page/Translations.md b/docs/content/en/methods/page/Translations.md
index 7aaee75ab..1ed256630 100644
--- a/docs/content/en/methods/page/Translations.md
+++ b/docs/content/en/methods/page/Translations.md
@@ -63,8 +63,9 @@ And this template:
{{ with .Translations }}
<ul>
{{ range . }}
- {{ $lang := .Language.LanguageName}}
- <li><a href="{{ .RelPermalink }}">{{ .LinkTitle }} ({{ $lang }})</a></li>
+ {{ $langName := or .Language.LanguageName .Language.Lang }}
+ {{ $langCode := or .Language.LanguageCode .Language.Lang }}
+ <li><a href="{{ .RelPermalink }}" hreflang="{{ $langCode }}">{{ .LinkTitle }} ({{ $langName }})</a></li>
{{ end }}
</ul>
{{ end }}
@@ -74,8 +75,8 @@ Hugo will render this list on the "Book 1" page of the English site:
```html
<ul>
- <li><a href="/de/books/book-1/">Book 1 (Deutsch)</a></li>
- <li><a href="/fr/books/book-1/">Book 1 (Français)</a></li>
+ <li><a href="/de/books/book-1/" hreflang="de-DE">Book 1 (Deutsch)</a></li>
+ <li><a href="/fr/books/book-1/" hreflang="fr-FR">Book 1 (Français)</a></li>
</ul>
```
@@ -83,6 +84,6 @@ Hugo will render this list on the "Book 2" page of the English site:
```html
<ul>
- <li><a href="/de/books/book-1/">Book 1 (Deutsch)</a></li>
+ <li><a href="/de/books/book-1/" hreflang="de-DE">Book 1 (Deutsch)</a></li>
</ul>
```