ominty
November 16, 2020, 1:04pm
1
When I use this method:
It would try to use different taxonomies per language in Frontmatter
EN-pages
tag = [“wines”, “red”]
ES-pages
etiquetas = [“vino”, “tinto”]
and have a blog.html section template where I want to list and link all used taxonomy terms in a sidepanel, how can I get this list for the current language?
In config.toml I have:
[Taxonomies]
[languages.de.taxonomies]
category = "rubriken"
[languages.en.taxonomies]
category = "categories"
for german (default) and english.
The current language tag list is always $.Site.Taxonomies.tags
. You can range over them and display some kind of tag cloud… If there is a “current” in your language related question then it’s ALWAYS solvable by ignoring i18n and just go the “normal” Hugo way.
ju52
November 16, 2020, 3:58pm
3
see
Taxonomy Variables | Hugo (gohugo.io)
you should use tags=[...]
in frontmatter
then you can range over
site.Taxonomies.tags
or
site.Taxonimies.etiquetas
you can chck the language in .Site.Language.Lang
should be “en” or “es”
1 Like
ju52
November 18, 2020, 8:38am
4
you can make different templates for different languages. HUgo will select it
Hugo’s Lookup Order | Hugo (gohugo.io)
ominty
November 21, 2020, 10:06pm
5
I have lots of different taxonomies and each of them has lots of different terms.
So no way to create different templates.
Problem was that I had listed the taxonomies but the links to show the associated list page produced 404 in the additional languages.
But this is fixed now (this is a diff):
{{ $data := .Data }}
{{ range $key,$value := .Data.Terms.ByCount }}
- <h2><a href="/{{ $data.Plural }}/{{ $value.Name | urlize }}.html">{{ $value.Name | humanize }}</a></h2><p class="small">In diesem Bereich: <strong>{{ $value.Count }} Artikel</strong></p>
+ <h2><a href="{{ "/" | relLangURL}}{{ $data.Plural }}/{{ $value.Name | urlize }}.html">{{ $value.Name | humanize | upper }}</a></h2>
{{ end }}
I simply had to prefix the relLangURL
…