Values being lowercased?

I’m trying to use hugo to build up a corpus of recipes. Here’s an example recipe:

---
name: Tom Collins
ingredients:
   Club Soda: 4oz
   Gin: 2oz
   Lemon Juice: 1oz
   Simple Syrup: 1tsp
---

Here’s the template fragment to render it:

<h1><a href="{{ .RelPermalink }}">{{ .Params.name }}</a></h1>

<ul>
{{ range $ingr, $amount := .Params.ingredients }}
   <li>{{ $amount }} {{ $ingr }}</li>
{{ end }}
</ul>

Bizarrely, when it is rendered, the ingredients get lowercased:

                     <h1><a href="/cocktails/drinks/tom-collins/">Tom Collins</a></h1>

<ul>

   <li>4oz club soda</li>

   <li>2oz gin</li>

   <li>1oz lemon juice</li>

   <li>1tsp simple syrup</li>

</ul>

Is there something about dictionaries in hugo that force them to be lowercased? Is there a way for me to opt out of this behavior, other than finding the relevant code, replacing it, and having a fork of hugo?

try his way - hope this helps

preserveTaxonomyNames: true seemed to have no effect. The title function works, but is sortav a hack (since I really just want to leave the data alone, not lowercase then title case.) I’m ok with the title function though.

Does hugo lowercase all data by default or something? These aren’t even configured as a taxonomy field

This could have something to do with that (I’m speculating only): Page variables | Hugo

Page-level .Params are only accessible in lowercase.

You could reorganise your ingredients like

ingredients:
  - ingredient: Club Soda
    amount: 4oz
  - ingredient: Gin
    amount: 2oz
  - ingredient: Lemon Juice
    amount: 1oz
  - ingredient: Simple Syrup
    amount: 1tsp

and

{{ range .Params.ingredients }}
 {{ .ingredient }} {{ .amount }}
{{ end }}

should keep the original casing

1 Like