I’m working on a page where I have a taxonomy named 'states'. Each term is named with the abbreviated name for this state. However, I would like to display some extra metadata for each term. I have created folders that are /content/states/<TERM>/_index.md. In _index.md I have added the first metadata variable that I want to use:
---
title: "State Name"
---
Now I am trying to create a list of all states and their associated content. How do I go about to list title instead of the term name for each term in the list.
I am currently using the following code:
{{ range $taxonomyName, $taxonomy := .Site.Taxonomies.states }}
<h4>{{ $taxonomyName }}</h4>
<ul>
{{ range $taxonomy.Pages }}
<li hugo-nav="{{ .RelPermalink}}"><a href="{{ .Permalink}}"> {{ .LinkTitle }} </a> </li>
{{ end }}
</ul>
{{ end }}
How do I list title instead of the value printed from the $taxonomyName variable?
I did try using {{ .Title }} but then I get the following error:
Error while rendering "section": template: /Development/hugo/layouts/<SECTION>/list.html:22:54: executing "main" at <.Title>: can't evaluate field Title in type hugolib.WeightedPages
I have struggled with this for a few days now, but I still haven’t found a solution. I would appreciate if anyone could chime in and let me know what I am doing wrong?
Share a link to your site’s source, and I will clone it and take a look. To troubleshoot this, we have to take a look at the templates, otherwise we’d need to create a site from scratch, and I am not personally into that.
If you check the layout in partials/concurso/list-by-state.html you’ll see the code.
And as you can see in /content/states/*/_index.md the ones that are there has a parameter “title” defined. I’m unable to call this in my template. I would still prefer the short name for the term to be the 2-letter abbreviation, but I would like to display the full name of the state in some layouts.