---
title: Detroit Pistons
nickname: "pistons"
type: team-stats
---
Template:
{{ $data := index .Site.Data.nba.stats.teams .Params.nickname }}
Error:
Error: Error building site: failed to render pages: render of "page" failed: "/layouts/team-stats/single.html:15:16": execute of template failed: template: team-stats/single.html:15:16: executing "main" at <index .Site.Data.nba.stats.teams .Params.nickname>: error calling index: value is nil; should be of type string
Using this earlier in the file works just fine:
{{ if isset .Params "nickname" }}
{{ partial (printf "symbols/nba/_%s.svg" .Params.nickname) . }}
{{ end }}
And printing {{ .Params.nickname }} works fine as well. Why is this index not able to use find this parameter?
Using hugo v0.84.2+extended darwin/arm64 BuildDate=unknown, by the way.
The content file I have at content/nba/team-stats is this:
---
title: Golden State Warriors
nickname: warriors
type: team-stats
---
And I get this error:
Start building sites …
hugo v0.84.3+extended darwin/arm64 BuildDate=unknown
Total in 129 ms
Error: Error building site: failed to render pages: render of "page" failed: "/layouts/team-stats/single.html:2:3": execute of template failed: template: team-stats/single.html:2:3: executing "team-stats/single.html" at <partial (printf "symbols/nba/_%s.svg" .Params.nickname)>: error calling partial: partial "symbols/nba/_%!s(<nil>).svg" not found
If I remove the printf line, I get this error for the second call to .Params.nickname:
Start building sites …
hugo v0.84.3+extended darwin/arm64 BuildDate=unknown
Total in 105 ms
Error: Error building site: failed to render pages: render of "page" failed: "/layouts/team-stats/single.html:2:12": execute of template failed: template: team-stats/single.html:2:12: executing "team-stats/single.html" at <index .Site.Data.nba.stats.teams .Params.nickname>: error calling index: value is nil; should be of type string