From: Anthony Fok Date: Wed, 3 Sep 2014 00:10:19 +0000 (-0600) Subject: A small fix and update to the multilingual example X-Git-Tag: v0.13~427 X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=ac78d25240b0aa428c5a46314b0a6a4e0621d69b;p=brevno-suite%2Fhugo A small fix and update to the multilingual example Enclose `{{ .Content }}` with a `{{ if .IsPage }}` test to avoid the "Content is not a field of struct type *hugolib.Node" error. Thanks to @spf13 for the tip! Fixes #366. Also update example to Hugo v0.12 conventions: - Convert config.yaml to config.toml to follow what `hugo new site /path/to/site` generates - Rename layouts/chrome to layouts/partials - Convert `template` calls to `partial` calls - Add .gitignore to ignore the `public` directory - Add README.md with pointers to discussions in issues to help bring newcomers up to speed with this multilingual example --- diff --git a/examples/multilingual/.gitignore b/examples/multilingual/.gitignore new file mode 100644 index 00000000..a48cf0de --- /dev/null +++ b/examples/multilingual/.gitignore @@ -0,0 +1 @@ +public diff --git a/examples/multilingual/README.md b/examples/multilingual/README.md new file mode 100644 index 00000000..5e4b4ff3 --- /dev/null +++ b/examples/multilingual/README.md @@ -0,0 +1,13 @@ +# Multilingual website with Hugo + +This example was kindly contributed by Egon Elbre in November 2013 +as a wonderful proof-of-concept for internationalization (i18n) +and multilingualization (m17n) in Hugo-generated websites. + +The example works well for the most part, though some minor issues remain. +Please see relevant discussions below: + +* https://github.com/spf13/hugo/issues/129 Multiple languages +* https://github.com/spf13/hugo/issues/134 Example of a multilingual site + +All contributions are welcome! diff --git a/examples/multilingual/config.toml b/examples/multilingual/config.toml new file mode 100644 index 00000000..094b09b2 --- /dev/null +++ b/examples/multilingual/config.toml @@ -0,0 +1,6 @@ +baseurl = "" + +[indexes] +tag = "tags" +group = "groups" +menu = "menu" diff --git a/examples/multilingual/config.yaml b/examples/multilingual/config.yaml deleted file mode 100644 index 017a9b59..00000000 --- a/examples/multilingual/config.yaml +++ /dev/null @@ -1,5 +0,0 @@ -indexes: - tag: 'tags' - group: 'groups' - menu: 'menu' -baseurl: '' diff --git a/examples/multilingual/layouts/_default/single.html b/examples/multilingual/layouts/_default/single.html index da3640ef..66e4a382 100644 --- a/examples/multilingual/layouts/_default/single.html +++ b/examples/multilingual/layouts/_default/single.html @@ -1,4 +1,4 @@ -{{ template "chrome/head.html" . }} -{{ template "chrome/header.html" . }} -{{ .Content }} -{{ template "chrome/footer.html" . }} \ No newline at end of file +{{ partial "head.html" . }} +{{ partial "header.html" . }} +{{ if .IsPage }}{{ .Content }}{{ end }} +{{ partial "footer.html" . }} diff --git a/examples/multilingual/layouts/chrome/footer.html b/examples/multilingual/layouts/chrome/footer.html deleted file mode 100644 index 2630b2e3..00000000 --- a/examples/multilingual/layouts/chrome/footer.html +++ /dev/null @@ -1,3 +0,0 @@ - - - \ No newline at end of file diff --git a/examples/multilingual/layouts/chrome/head.html b/examples/multilingual/layouts/chrome/head.html deleted file mode 100644 index 44d1d736..00000000 --- a/examples/multilingual/layouts/chrome/head.html +++ /dev/null @@ -1,15 +0,0 @@ - - - - - {{ if .Title }} - {{ if (eq .Params.lang "et") }} - Mitmekeelne - {{ .Title }} - {{ else }} - Multilingual - {{ .Title }} - {{ end }} - {{ end }} - - - - \ No newline at end of file diff --git a/examples/multilingual/layouts/chrome/header.html b/examples/multilingual/layouts/chrome/header.html deleted file mode 100644 index b99b2fbe..00000000 --- a/examples/multilingual/layouts/chrome/header.html +++ /dev/null @@ -1,25 +0,0 @@ -
- - - {{ if (eq .Params.lang "et") }} -

Minu mitmekeelne leht

- {{ else }} -

My multilingual site

- {{ end }} - - -
- -

{{ .Title }}

\ No newline at end of file diff --git a/examples/multilingual/layouts/partials/footer.html b/examples/multilingual/layouts/partials/footer.html new file mode 100644 index 00000000..2630b2e3 --- /dev/null +++ b/examples/multilingual/layouts/partials/footer.html @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/examples/multilingual/layouts/partials/head.html b/examples/multilingual/layouts/partials/head.html new file mode 100644 index 00000000..f89e3ffb --- /dev/null +++ b/examples/multilingual/layouts/partials/head.html @@ -0,0 +1,15 @@ + + + + + {{ if .Title }} + {{ if (eq .Params.lang "et") }} + Mitmekeelne - {{ .Title }} + {{ else }} + Multilingual - {{ .Title }} + {{ end }} + {{ end }} + + + + \ No newline at end of file diff --git a/examples/multilingual/layouts/partials/header.html b/examples/multilingual/layouts/partials/header.html new file mode 100644 index 00000000..a244b8b0 --- /dev/null +++ b/examples/multilingual/layouts/partials/header.html @@ -0,0 +1,25 @@ +
+ + + {{ if (eq .Params.lang "et") }} +

Minu mitmekeelne leht

+ {{ else }} +

My multilingual site

+ {{ end }} + + +
+ +

{{ .Title }}

diff --git a/examples/multilingual/layouts/story/list.html b/examples/multilingual/layouts/story/list.html index 0173244f..a753577d 100644 --- a/examples/multilingual/layouts/story/list.html +++ b/examples/multilingual/layouts/story/list.html @@ -1,5 +1,5 @@ -{{ template "chrome/head.html" . }} -{{ template "chrome/header.html" . }} +{{ partial "head.html" . }} +{{ partial "header.html" . }} {{ range .Site.Indexes.groups.news.Pages }}
@@ -12,4 +12,4 @@
{{ end }} -{{ template "chrome/footer.html" . }} \ No newline at end of file +{{ partial "footer.html" . }} diff --git a/examples/multilingual/layouts/uudis/list.html b/examples/multilingual/layouts/uudis/list.html index 970a48bf..23c0daec 100644 --- a/examples/multilingual/layouts/uudis/list.html +++ b/examples/multilingual/layouts/uudis/list.html @@ -1,5 +1,5 @@ -{{ template "chrome/head.html" . }} -{{ template "chrome/header.html" . }} +{{ partial "head.html" . }} +{{ partial "header.html" . }} {{ range .Site.Indexes.groups.uudised.Pages }}
@@ -12,4 +12,4 @@
{{ end }} -{{ template "chrome/footer.html" . }} \ No newline at end of file +{{ partial "footer.html" . }}