I would like to set links in my sidebar menu to a Taxonomy list with the same value in the Taxonomy “catalog” as the key for the current Taxonomy, like so:
{{ range $taxonomyname, $taxonomy := .Site.Taxonomies }}
<li>
<a href="#">• {{ humanize $taxonomyname | title }} <span class="fa arrow"></span></a>
<ul class="nav nav-second-level">
{{ range $key, $value := $taxonomy }}
<li>
<a href="#">· {{ title $key }} <span class="fa arrow"></span></a>
<ul class="nav nav-third-level">
{{ if in .Site.Taxonomies.catalog $key }} <- THIS is what's giving me problems
<li hugo-nav="/catalog/{{ $key }}/"><a href="/catalog/{{ $key }}/">⋅ Catalog</a> </li>
{{ end }}
{{ range $value.Pages }}
<li hugo-nav="{{ .RelPermalink}}"><a href="{{ .Permalink}}">⋅ {{ title .LinkTitle }} </a> </li>
{{ end }}
</ul>
<!-- /.nav-third-level -->
</li>
{{ end }}
</ul>
{{ end }}
</li>
It works fine if I do not wrap the link to the catalog in the template function, but without the template function, every key gets a link to a Taxonomy list within catalog, even if there is no list and I get a 404 error. I only want there to be a link if there is a catalog member with the same value as the current key. Right now, I get an error that reads, “can’t evaluate variable Site.” This seems like it should work to me, and nothing else I have found has worked. Please help.