AllTranslations.md - hugo - [fork] hugo port for 9front
HTML git clone https://git.drkhsh.at/hugo.git
DIR Log
DIR Files
DIR Refs
DIR Submodules
DIR README
DIR LICENSE
---
AllTranslations.md (1946B)
---
1 ---
2 title: AllTranslations
3 description: Returns all translations of the given page, including the current language.
4 categories: []
5 keywords: []
6 params:
7 functions_and_methods:
8 returnType: page.Pages
9 signatures: [PAGE.AllTranslations]
10 ---
11
12 With this site configuration:
13
14 {{< code-toggle file=hugo >}}
15 defaultContentLanguage = 'en'
16
17 [languages.en]
18 contentDir = 'content/en'
19 languageCode = 'en-US'
20 languageName = 'English'
21 weight = 1
22
23 [languages.de]
24 contentDir = 'content/de'
25 languageCode = 'de-DE'
26 languageName = 'Deutsch'
27 weight = 2
28
29 [languages.fr]
30 contentDir = 'content/fr'
31 languageCode = 'fr-FR'
32 languageName = 'Français'
33 weight = 3
34 {{< /code-toggle >}}
35
36 And this content:
37
38 ```text
39 content/
40 ├── de/
41 │ ├── books/
42 │ │ ├── book-1.md
43 │ │ └── book-2.md
44 │ └── _index.md
45 ├── en/
46 │ ├── books/
47 │ │ ├── book-1.md
48 │ │ └── book-2.md
49 │ └── _index.md
50 ├── fr/
51 │ ├── books/
52 │ │ └── book-1.md
53 │ └── _index.md
54 └── _index.md
55 ```
56
57 And this template:
58
59 ```go-html-template
60 {{ with .AllTranslations }}
61 <ul>
62 {{ range . }}
63 <li>
64 <a href="{{ .RelPermalink }}" hreflang="{{ .Language.LanguageCode }}">{{ .LinkTitle }} ({{ or .Language.LanguageName .Language.Lang }})</a>
65 </li>
66 {{ end }}
67 </ul>
68 {{ end }}
69 ```
70
71 Hugo will render this list on the "Book 1" page of each site:
72
73 ```html
74 <ul>
75 <li><a href="/books/book-1/" hreflang="en-US">Book 1 (English)</a></li>
76 <li><a href="/de/books/book-1/" hreflang="de-DE">Book 1 (Deutsch)</a></li>
77 <li><a href="/fr/books/book-1/" hreflang="fr-FR">Book 1 (Français)</a></li>
78 </ul>
79 ```
80
81 On the "Book 2" page of the English and German sites, Hugo will render this:
82
83 ```html
84 <ul>
85 <li><a href="/books/book-1/" hreflang="en-US">Book 1 (English)</a></li>
86 <li><a href="/de/books/book-1/" hreflang="de-DE">Book 1 (Deutsch)</a></li>
87 </ul>
88 ```