After getting sick of TOML’s way of structuring nested arrays/hash I converted all my Front Matters with hugo convert toYAML --unsafe
command and adjusted the very few it couldn’t handle manually and everything was, apparently, working fine.
Apparently because there’s a line in my listing template that performs an isset
check over an argument grouped along others in a array/hash like this:
...
meta:
headline: "Lorem ipsum dolor"
duration: "PT21M57S"
image: "path/to/big/picture/image.jpg"
height: 720
width: 1280
embedURL: "some_youtube_URL"
uploadDate: "2017-03-27T22:47:00-03:00"
...
The … means that there are more parameters before and after this block.
This array/hash is used to create meta tags accordingly to Schema.org. Since all meta tags are related to a video and the video URL is defined under embedURL
in my template I have:
{{ if isset .Params.meta "embedurl" }}
Do something
{{ else }}
No video sources found
{{ end }}
Back when all Front Matters were created in TOML that line worked flawlessly, afterall I had taken in account Hugo’s weird choice to lowercase all parameter names.
But since I converted to YAML this test always returns false
and thus always reaches the {{ else }}
.
And I’ve tested quite a bit and this only happens with the camel cased arguments. In the partial I use to generate these meta tags (personal preference over a {{ range }}
) I have, for example:
{{ with (.Params.meta.headline) }}<meta itemprop="headline" content="{{ . | plainify }}">{{ end }}
And it works perfectly but doing the same for .Params.meta.embedurl
(or the original the camel cased format) doesn’t work and the line is not even rendered.
What’s going on?