Skip to content

Commit

Permalink
A small fix and update to the multilingual example
Browse files Browse the repository at this point in the history
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 gohugoio#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
  • Loading branch information
anthonyfok authored and spf13 committed Sep 8, 2014
1 parent 4bb5e32 commit ac78d25
Show file tree
Hide file tree
Showing 10 changed files with 33 additions and 18 deletions.
1 change: 1 addition & 0 deletions examples/multilingual/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
public
13 changes: 13 additions & 0 deletions examples/multilingual/README.md
Original file line number Diff line number Diff line change
@@ -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!
6 changes: 6 additions & 0 deletions examples/multilingual/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
baseurl = ""

[indexes]
tag = "tags"
group = "groups"
menu = "menu"
5 changes: 0 additions & 5 deletions examples/multilingual/config.yaml

This file was deleted.

8 changes: 4 additions & 4 deletions examples/multilingual/layouts/_default/single.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{ template "chrome/head.html" . }}
{{ template "chrome/header.html" . }}
{{ .Content }}
{{ template "chrome/footer.html" . }}
{{ partial "head.html" . }}
{{ partial "header.html" . }}
{{ if .IsPage }}{{ .Content }}{{ end }}
{{ partial "footer.html" . }}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!doctype html>
<!DOCTYPE html>
<html lang="{{ .Params.lang }}">
<head>
<meta charset="utf-8">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ <h1 class="title">Minu mitmekeelne leht</h1>
{{ else }}
<h1 class="title">My multilingual site</h1>
{{ end }}

<nav class="menu main-menu">
<ul>
{{ range (index .Site.Indexes.menu .Params.lang).Pages }}
Expand All @@ -22,4 +22,4 @@ <h1 class="title">My multilingual site</h1>
</nav>
</header>

<h2 class="subtitle">{{ .Title }}</h2>
<h2 class="subtitle">{{ .Title }}</h2>
6 changes: 3 additions & 3 deletions examples/multilingual/layouts/story/list.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{{ template "chrome/head.html" . }}
{{ template "chrome/header.html" . }}
{{ partial "head.html" . }}
{{ partial "header.html" . }}
{{ range .Site.Indexes.groups.news.Pages }}
<article class="post">
<header>
Expand All @@ -12,4 +12,4 @@ <h2><a href='{{ .Permalink }}'>{{ .Title }}</a> </h2>
</footer>
</article>
{{ end }}
{{ template "chrome/footer.html" . }}
{{ partial "footer.html" . }}
6 changes: 3 additions & 3 deletions examples/multilingual/layouts/uudis/list.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{{ template "chrome/head.html" . }}
{{ template "chrome/header.html" . }}
{{ partial "head.html" . }}
{{ partial "header.html" . }}
{{ range .Site.Indexes.groups.uudised.Pages }}
<article class="post">
<header>
Expand All @@ -12,4 +12,4 @@ <h2><a href='{{ .Permalink }}'>{{ .Title }}</a> </h2>
</footer>
</article>
{{ end }}
{{ template "chrome/footer.html" . }}
{{ partial "footer.html" . }}

0 comments on commit ac78d25

Please sign in to comment.