I am working on a bilingual site now, and was experimenting with taxonomy settings. I’m not sure if this is working as expected, or, if it’s a bug.
Given a config.toml
with:
baseURL = "http://thesite.jp"
defaultContentLanguage = "ja"
languageCode = "ja-jp"
enableGitInfo = "true"
enableemoji = "false"
[permalinks]
post = "/:year/:month/:day/:slug/"
page = "/:filename/"
[params]
sitedescription = "blahblah"
keywords = "blahblah"
# various defaults …
[taxonomies]
tag = "tags"
[languages]
[languages.ja]
languageName = "日本語"
title = "XYZ部会"
weight = 1
author = "XYZ部会 事務局"
[languages.en]
languageName = "English"
title = "XYZ Committee"
weight = 2
author = "XYZ Committee Office"
… I can list tags using this sort of code in a partial ranging on .Site.Taxonomies.tags
:
{{ "<!-- ENTERING partial list-tags.html -->" | safeHTML }}
<hr class="class1">
<p class="class2">
{{ $thislang := .Lang }}
<a class="class3" href="{{ if eq $thislang "en" }}/en/{{ else }}/{{ end }}tags">{{ i18n "tagsListBrowse" }}</a><span class="red class4">❦</span>
{{ range $name, $taxonomy := .Site.Taxonomies.tags }}
<a class="class5" href="{{ if eq $thislang "en" }}/en/{{ else }}/{{ end }}tags/{{ $name | urlize }}">{{ $name }}</a><span class="red class4"i>❦</span>
{{ end }}
</p>
{{ "<!-- LEAVING partial list-tags.html -->" | safeHTML }}
But, if I put the taxonomies under each language section, like:
[languages]
[languages.ja]
languageName = "日本語"
title = "XYZ部会"
weight = 1
author = "XYZ部会 事務局"
[languages.ja.taxonomies]
tag = "tags"
[languages.en]
languageName = "English"
title = "XYZ Committee"
weight = 2
author = "XYZ Committee Office"
[languages.en.taxonomies]
tag = "tags"
… the English side does not render. I assume it’s because I kept the taxo name and plural the same as the default language’s. Further, when I put {{ .Site.Taxonomies.tags }}
outside the range to inspect it, it appears blank for English but populates for Japanese (default).
So I am correct to assume the rule of thumb here is, “specify a language taxonomy only if the string is to be different from the default one”?
Second, a question: is there something like {{ .URL | absLangURL }}
that you can use in navs, but for taxonomy lists? I’d like to use a cleaner way than href="{{ if eq $thislang "en" }}/en/{{ else }}/{{ end }}tags">
and generic so I can use it for any taxo, if it exists.