Hi All
I hope this isn’t too obvious, because I’m stumped!
I have two content folders, “photos” and “projects”, both have JSON formatted markdown files with essentially the exact same variables and formatting.
Example from projects
:
{"project":true,
"shortTitle":"Springfield",
"longTitle":"Springfield (2009)",
"projectDate":"2009-01-01",
"shortDescription":"A collection of photos from my first visit back home after moving to Los Angeles in 2009.",
"longDescription":"",
"links":[],
"images":[{"asset":{"tags":["Springfield"],"url":"https://cdn.sanity.io/images/rjnzi28z/production/650820f49ab6706472b9c7b9b411640f8512b450-2400x1656.jpg"}}
Example from photos
:
{"collection":true,
"shortTitle":"W 4th St Courts",
"longTitle":"West 4th Street Courts, aka 'The Cage'",
"collectionDate":"2021-07-28",
"shortDescription":"Two days at the infamous West 4th Street Courts, sometimes lovingly called \"The Cage\".",
"longDescription":"",
"images":[{"asset":{"tags":["W 4th St Courts"],"url":"https://cdn.sanity.io/images/rjnzi28z/production/9642a5c3dd3c1f8d9f8087b0ca85c110a052dc80-2000x1335.jpg"}}
In my single.html
template for both I have a range:
{{ range .Params.images }}
<img src={{ .asset.url }}>
{{ end }}
It works fine for projects
and puts the image urls in the src field as expected. But for photos
I’m getting the following error:
execute of template failed: template: photos/single.html:12:20: executing "main" at <.asset.url>: nil pointer evaluating interface {}.url
In an attempt to debug, I got the raw data returned by the range using {{ .asset }}
and got essentially the same response in both layouts:
map[tags:[W 4th St Courts] url:https://cdn.sanity.io/images/rjnzi28z/production/9642a5c3dd3c1f8d9f8087b0ca85c110a052dc80-2000x1335.jpg]
map[tags:[Springfield] url:https://cdn.sanity.io/images/rjnzi28z/production/650820f49ab6706472b9c7b9b411640f8512b450-2400x1656.jpg]
I cannot for the life of me figure out why photos
is throwing the nil pointer
error, but projects
is not. Any thoughts?