New error in 0.43, "error calling where: can't iterate over <nil>" [SOLVED]

Hugo Static Site Generator v0.43 darwin/amd64 BuildDate: unknown

In Hugo 0.42.1, this worked:


{{ range ...[some section] }}
  {{ template "interior" . }}
{{ end }}

{{define "interior" }}
	{{ $videos := (where .Site.RegularPages "Section" "video") }}  
	{{ $PlaylistVideos := where ($videos) ".File.Path" "in" .Params.related_videos }}  
{{end}}

In Hugo 0.43 I get the following error:

executing "interior" at <where .Site.RegularP...>: error calling where: can't iterate over <nil>

Putting the logic from interior directly into the range does not throw an error.

I’ve created a test repo with this setup and am not replicating it there.I’ll report more if I can narrow it down.

I’ve added a reduced test case repo: https://github.com/budparr/test-hugo-0.43-issue-templates

The template from which the above code is located is in a partial pulled from the home page. On that page I have other partials that also used {{ template "interior" . }}. I changed the name of the template (e.g. “interior_1” “interior_2” ) and I stopped getting the errors.

However, in my reduced test repo, I did NOT get errors with two partials with two of the same named template.

In the test repo, if I have two separate partials with {{ template "interior" . }} both partials pick up the same content. That is, both partials pick up the content in the interior template of partial 2, however, If I revert back to older versions of Hugo I see this behavior.

It looks to me that name of block templates have to be globally unique now.

Because if I change the name of interior to interior2 in test.html, I get the proper output on the index page:

Partial 1
Interior of partial 1
Post 2
Pages(2)
Partial 2
Interior of partial 2
Post 2
Pages(2)

However when the define "interior" template is declared twice in the theme, the second one takes precedence:

Partial 1
Interior of partial 2
Post 2
Pages(2)
Partial 2
Interior of partial 2
Post 2
Pages(2)

I can’t however pin point in the release notes of 0.43 why this happens now. But I do see this issue (which got into 0.43) that some behaviour around ‘define template’ was improved and fixed.

This is not about “block templates”, but inline template definitions. And not a new issue:

I assumed, because it occurred on older versions, that the issue in my test repo was old, despite the inconsistency I was seeing in my production site. At any rate, I got it working and if there’s nothing here that raises flags for anyone, I’ll mark it as solved.