When to use capitalisation for values in data & partials?


First post here from a newbie. Generally learning Hugo and it’s great.
But… I’m running into some problems and I’m clueless about this one.

I was roughly following the guide for Jaco Pastorius discography from https://gohugo.io/templates/data-templates/

The example worked, but I wanted something different.
Instead of discography, I’ve put some basic data into each bass player data file (TOML), like so:
name = John guitar = Gibson

So then in my partial, instead of using range for the discography, I simply wanted to display the name and the guitar brand, like so:
<p>{{ .name }}: {{ .guitar }}</p>

Well, turns out this doesn’t work!

After 1 hour of panic googling and browsing this forum, I just tried to capitalise the “name” in both data file and the partial, and… it worked.

Could anyone clarify why I need to use capitalisation?
Where in the docs is this specified?
Why I don’t have to capitalise the “guitar”?


(capitalize capitalization)

@bzx Huh. I’ve never run into this before. I think I can help if given a bit more context, please. Do you happen to have your source somewhere I can clone and test locally?

@rdwatters hey, thanks for your response… I think I realised that in templates all the variables must be referred to with a capital letter (it’s coming from Go language requirement I guess).

I don’t have a source, and anyway, I also realised that I need to solve my problem otherwise, by using content files.


PS. if you really want to test it for yourself, just modify the data file for Pastorius albums, and add a field with:
name = Jaco and guitar = Gibson above the discography, and then in the partial try to call these values… the “Name” will have to be capitalised, the “guitar” won’t…