Skip to content
This repository has been archived by the owner on Jun 10, 2023. It is now read-only.

Commit

Permalink
Add multilanguage support
Browse files Browse the repository at this point in the history
  • Loading branch information
panr committed Jan 20, 2019
1 parent 62709b7 commit e0787f1
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 10 deletions.
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ $ git submodule add https://github.com/panr/hugo-theme-hello-friend.git themes/h
The theme doesn't require any advanced configuration. Just copy:

```
baseurl = "https://example.org/"
baseurl = "/"
languageCode = "en-us"
title = "Hello Friend"
theme = "hello-friend"
Expand Down Expand Up @@ -84,9 +84,15 @@ paginate = 5
identifier = "showcase"
name = "Showcase"
url = "/showcase"
[languages]
[languages.en]
writtenBy = "Written by"
readMore = "Read more"
readOtherPosts = "Read other posts"
```

to `config.toml` file in your Hugo root directory and change params fields.
to `config.toml` file in your Hugo root directory and change params fields. In case you need, here's [a YAML version](https://gist.github.com/panr/8f9b363e358aaa33f6d353c77feee959).

## How to run your site

Expand Down
8 changes: 7 additions & 1 deletion exampleSite/config.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
baseurl = "https://example.org/"
baseurl = "/"
languageCode = "en-us"
title = "Hello Friend"
theme = "hugo-theme-hello-friend"
Expand Down Expand Up @@ -26,3 +26,9 @@ paginate = 5
identifier = "showcase"
name = "Showcase"
url = "/showcase"

[languages]
[languages.en]
writtenBy = "Written by"
readMore = "Read more"
readOtherPosts = "Read other posts"
4 changes: 2 additions & 2 deletions layouts/_default/list.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ <h1 class="post-title"><a href="{{ .Permalink }}">{{ .Title | markdownify }}</a>
<span class="post-date">
{{ .Date.Format "2006-01-02" }}
</span>
<span class="post-author">Written by {{ .Params.Author }}</span>
<span class="post-author">{{ .Site.Params.WrittenBy }} {{ .Params.Author }}</span>
</div>

{{ if .Params.tags }}
Expand All @@ -32,7 +32,7 @@ <h1 class="post-title"><a href="{{ .Permalink }}">{{ .Title | markdownify }}</a>
{{ end }}
{{ end }}
</div>
<div><a class="read-more button" href="{{.RelPermalink}}">Read more</a></div>
<div><a class="read-more button" href="{{.RelPermalink}}">{{ .Site.Params.ReadMore }}</a></div>
</div>
{{ end }}
{{ partial "pagination.html" . }}
Expand Down
4 changes: 2 additions & 2 deletions layouts/_default/single.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ <h2 class="post-title"><a href="{{ .Permalink }}">{{ .Title | markdownify }}</a>
<span class="post-date">
{{ .Date.Format "2006-01-02" }}
</span>
<span class="post-author">Written by {{ .Params.Author }}</span>
<span class="post-author">{{ .Site.Params.WrittenBy }} {{ .Params.Author }}</span>
</div>

{{ if .Params.tags }}
Expand All @@ -26,7 +26,7 @@ <h2 class="post-title"><a href="{{ .Permalink }}">{{ .Title | markdownify }}</a>
{{ if or .NextInSection .PrevInSection }}
<div class="pagination">
<div class="pagination__title">
<span class="pagination__title-h">Read other posts</span>
<span class="pagination__title-h">{{ .Site.Params.ReadOtherPosts }}</span>
<hr />
</div>
<div class="pagination__buttons">
Expand Down
6 changes: 3 additions & 3 deletions theme.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ features = ["blog", "shortcode"]
min_version = 0.30

[author]
name = "panr"
homepage = "https://radoslawkoziel.pl"
twitter = "https://twitter.com/panr"
name = "panr"
homepage = "https://radoslawkoziel.pl"
twitter = "https://twitter.com/panr"

0 comments on commit e0787f1

Please sign in to comment.