Capitalization of related items

We recently upgraded our company website from Hugo 0.16 to 0.4x. One thing I haven’t been able to figure out how to fix is that many of our list templates include, for each item, links to related products we offer:

{{ if .Params.related }}
{{range $key, $value := .Params.related }}
<a href="{{ $value }}" class=“learn-more”>
{{ $key }}
</a><br />
{{ end }}
{{end}}

and these links now have lowercased $keys instead of keys which respect the manner in which the product name was typed in markdown frontmatter. I believe we used to use preserveTaxonomyNames: true to address this issue, but that feature seems to have been deprecated. What is the current mechanism for ensuring that related link names will respect the manner in which they were typed? It is important to us that ProductNAME not appear as productname.

The Params keys are lowercased, no way around that. You can however use it case-insensitive in the templates i.e. .Site.Params.myParam.

That said. I suspect you want an array/slice and not a map – as you then can preserve order and write proper titles for your related items etc.

A related tip:

Here’s a great article from @regis who talks detailed about related content: https://regisphilibert.com/blog/2018/04/hugo-optmized-relashionships-with-related-content/

2 Likes

Thanks for the tips! I think we will move to using an array of custom frontmatter for this, as we’re not taking advantage of the other functionality of Related Content anyway.