From ac78d25240b0aa428c5a46314b0a6a4e0621d69b Mon Sep 17 00:00:00 2001 From: Anthony Fok Date: Tue, 2 Sep 2014 18:10:19 -0600 Subject: [PATCH] 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 --- examples/multilingual/.gitignore | 1 + examples/multilingual/README.md | 13 +++++++++++++ examples/multilingual/config.toml | 6 ++++++ examples/multilingual/config.yaml | 5 ----- examples/multilingual/layouts/_default/single.html | 8 ++++---- .../layouts/{chrome => partials}/footer.html | 0 .../layouts/{chrome => partials}/head.html | 2 +- .../layouts/{chrome => partials}/header.html | 4 ++-- examples/multilingual/layouts/story/list.html | 6 +++--- examples/multilingual/layouts/uudis/list.html | 6 +++--- 10 files changed, 33 insertions(+), 18 deletions(-) create mode 100644 examples/multilingual/.gitignore create mode 100644 examples/multilingual/README.md create mode 100644 examples/multilingual/config.toml delete mode 100644 examples/multilingual/config.yaml rename examples/multilingual/layouts/{chrome => partials}/footer.html (100%) rename examples/multilingual/layouts/{chrome => partials}/head.html (92%) rename examples/multilingual/layouts/{chrome => partials}/header.html (88%) diff --git a/examples/multilingual/.gitignore b/examples/multilingual/.gitignore new file mode 100644 index 000000000..a48cf0de7 --- /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 000000000..5e4b4ff3d --- /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 000000000..094b09b29 --- /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 017a9b59e..000000000 --- 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 da3640efe..66e4a3828 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/partials/footer.html similarity index 100% rename from examples/multilingual/layouts/chrome/footer.html rename to examples/multilingual/layouts/partials/footer.html diff --git a/examples/multilingual/layouts/chrome/head.html b/examples/multilingual/layouts/partials/head.html similarity index 92% rename from examples/multilingual/layouts/chrome/head.html rename to examples/multilingual/layouts/partials/head.html index 44d1d7362..f89e3ffb3 100644 --- a/examples/multilingual/layouts/chrome/head.html +++ b/examples/multilingual/layouts/partials/head.html @@ -1,4 +1,4 @@ - + diff --git a/examples/multilingual/layouts/chrome/header.html b/examples/multilingual/layouts/partials/header.html similarity index 88% rename from examples/multilingual/layouts/chrome/header.html rename to examples/multilingual/layouts/partials/header.html index b99b2fbef..a244b8b0c 100644 --- a/examples/multilingual/layouts/chrome/header.html +++ b/examples/multilingual/layouts/partials/header.html @@ -12,7 +12,7 @@ {{ else }}

My multilingual site

{{ end }} - + -

{{ .Title }}

\ No newline at end of file +

{{ .Title }}

diff --git a/examples/multilingual/layouts/story/list.html b/examples/multilingual/layouts/story/list.html index 0173244f7..a753577d5 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 970a48bfb..23c0daec8 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" . }}