ref: 3410007dca4012d1dea3a9d953b4d0a180f43e70
parent: 9dab62c559d7665ef1968f0ceba58704a5a29dde
author: digitalcraftsman <[email protected]>
date: Fri Sep 16 11:35:19 EDT 2016
docs: List multilingual tpl vars and show menu creation Fixes #2436
--- a/docs/content/content/multilingual.md
+++ b/docs/content/content/multilingual.md
@@ -142,6 +142,48 @@
i18n|MISSING_TRANSLATION|en|wordCount
```
+
+### Menus
+
+You can define your menus for each language independently. The [creation of a menu]({{< relref "extras/menus.md" >}}) works analogous to earlier versions of Hugo, except that they have to be defined in their language-specific block in the configuration file:
+
+```toml
+DefaultContentLanguage = "en"
+
+[languages.en]
+weight = 0
+languageName = "English"
+
+[[languages.en.menu.main]]
+url = "/"
+name = "Home"
+weight = 0
+
+
+[languages.de]
+weight = 10
+languageName = "Deutsch"
+
+[[languages.de.menu.main]]
+url = "/"
+name = "Startseite"
+weight = 0
+```
+
+The rendering of the main navigation works as usual. `.Site.Menus` will just contain the menu of the current language. Pay attention to the generation of the menu links. `absLangURL` takes care that you link to the correct locale of your website. Otherwise, both menu entries would link to the English version because it's the default content language that resides in the root directory.
+
+```html
+<ul>
+ {{- $currentNode := . -}}
+ {{ range .Site.Menus.main -}}
+ <li class="{{ if $currentNode.IsMenuCurrent "main" . }}active{{ end }}">
+ <a href="{{ .URL | absLangURL }}">{{ .Name }}</a>
+ </li>
+ {{- end }}
+</ul>
+
+```
+
### Multilingual Themes support
To support Multilingual mode in your themes, some considerations must be taken for the URLs in the templates. If there are more than one language, URLs must either come from the built-in `.Permalink` or `.URL`, be constructed with `relLangURL` or `absLangURL` template funcs -- or prefixed with `{{.LanguagePrefix }}`.
--- a/docs/content/templates/variables.md
+++ b/docs/content/templates/variables.md
@@ -178,7 +178,10 @@
**.Site.BuildDrafts** A boolean (Default: false) to indicate whether to build drafts. Defined in the site configuration.<br>
**.Site.Data** Custom data, see [Data Files](/extras/datafiles/).<br>
**.Site.IsMultiLingual** Whether there are more than one language in this site.<br> See [Multilingual]({{< relref "content/multilingual.md" >}}) for more info.<br>
-**.Site.Language** This indicates which language you are currently rendering the website for. This is an object with the attributes set in your language definition in your site config. For the language code, use `.Site.Language.Lang`.<br>
+**.Site.Language** This indicates which language you are currently rendering the website for. This is an object with the attributes set in your language definition in your site config.<br>
+**.Site.Language.Lang** The language code of the current locale, e.g. `en`.<br>
+**.Site.Language.Weight** The weight that defines the order in the `.Site.Languages` list.<br>
+**.Site.Language.LanguageName** The full language name, e.g. `English`.<br>
**.Site.LanguagePrefix** This can be used to prefix theURLs with whats needed to point to the correct language. It will even work when only one language defined. See also the functions [absLangURL and relLangURL]({{< relref "templates/functions.md#abslangurl-rellangurl" >}}).<br>
**.Site.Languages** An ordered list (ordered by defined weight) of languages.<br>
--- a/docs/content/tutorials/create-a-multilingual-site.md
+++ b/docs/content/tutorials/create-a-multilingual-site.md
@@ -11,6 +11,8 @@
weight: 10
---
+> **Note:** Since v0.17 Hugo has built-in support for the creation of multilingual website. [Read more about it]({{< relref "content/multilingual.md" >}}).
+
## Introduction
Hugo allows you to create a multilingual site from its built-in tools. This tutorial will show one way to do it, and assumes: