The technical choice
HUGO was used for the realization of the website BalziBox as a static web page generator with lightning performance. Small corrections were made to the theme PaperMod on difficulties encountered in multilingual management.
The proposed changes were published on github .
App | version |
---|---|
Hugo: | v0.133.0 |
PaperMod release: | 7.0 |
Multilingual breadcrumbs
Example path of file sistem: /content/articles
Configuration hugo.yaml
...
languages:
en:
permalinks:
page:
articles: /articles/:slug/
section:
articles: /articles/
menu:
main:
- name: Articles
url: articles/
it:
permalinks:
page:
articles: /articoli/:slug/
section:
articles: /articoli/
menu:
main:
- name: Articoli
url: articoli/
...
The problem is found in breadcrumbs, if you use only one language works correctly. I modified the file /layouts/partials/breadcrumbs.html
with the code I attach.
{{- if (.Param "ShowBreadCrumbs") -}}
<div class="breadcrumbs">
{{- range .Ancestors.Reverse }}
<a href="{{ .RelPermalink }}">{{ if .IsHome }}{{ i18n "home" }}{{ else }}{{ print " » " | safeHTML }}{{ .Title }}{{ end }}</a>
{{- end -}}
</div>
{{- end -}}
Translation tag page
Configuration hugo.yaml
...
languages:
en:
taxonomies:
tag: tags
it:
taxonomies:
tag: etichette
...
For tags page the problem is present for other languages, the data are not shown.
The solution:
# i18n/en.yaml
- id: tag
translation: "tags"
# i18n/it.yaml
- id: tag
translation: "etichette"
To solve it you need to change the page code /layouts/_default/single.html
<!-- original code -->
{{- $tags := .Language.Params.Taxonomies.tag | default "tags" }}
<!-- code modified -->
{{- $tags := .Language.Params.Taxonomies.tag | default | i18n "tag" }}