diff --git a/content/content/multilingual.md b/content/content/multilingual.md index f93738f9f..35dd1382e 100644 --- a/content/content/multilingual.md +++ b/content/content/multilingual.md @@ -135,7 +135,7 @@ This uses a definition like this one in `i18n/en-US.yaml`: ### 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 `relURL` or `absURL` -- or prefixed with `{{.LanguagePrefix }}`. +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 }}`. If there are more than one language defined, the`LanguagePrefix` variable will equal `"/en"` (or whatever your `CurrentLanguage` is). If not enabled, it will be an empty string, so it is harmless for single-language sites. diff --git a/content/templates/functions.md b/content/templates/functions.md index aa55ced4f..5fb540065 100644 --- a/content/templates/functions.md +++ b/content/templates/functions.md @@ -787,6 +787,13 @@ e.g.: `{{ i18n "translation_id" }}` * `{{ mul 1000 (time "2016-05-28T10:30:00.00+10:00").Unix }}` → 1464395400000 (Unix time in milliseconds) ## URLs +### absLangURL, relLangURL +These are similar to the `absURL` and `relURL` relatives below, but will add the correct language prefix when the site is configured with more than one language. + +So for a site `baseURL` set to `http://mysite.com/hugo/` and the current language is `en`: + +* `{{ "blog/" | absLangURL }}` → "http://mysite.com/hugo/en/blog/" +* `{{ "blog/" | relLangURL }}` → "/hugo/en/blog/" ### absURL, relURL