After upgrading from 0.122.0-1 to 0.123.3-1 on debian I get the following error:
partials/header.html:2:10": execute of template failed: template: partials/header.html:2:10: executing “partials/header.html” at <where .Site.Pages “File.BaseFileName” $header>: error calling where: runtime error: invalid memory address or nil pointer dereference
How can I solve it ?
I am not a developper, I use hugo to put markdown file on the server, but regularly you do modifications with NO backward compatibility, most time I can find a solution, but here not yet.
Can you help me ?
Here is the content of header.html:
{{ $header := print "_header." .Lang }}
{{ range where .Site.Pages "File.BaseFileName" $header }}
{{ .Content }}
{{ else }}
{{ if .Site.GetPage "page" "_header.md" }}
{{ (.Site.GetPage "page" "_header.md").Content }}
{{ else }}
<a class="baselink" href="{{ .Site.BaseURL }}">{{ .Site.Title }}</a>
{{ end }}
{{ end }}
The site.Pages collection includes all pages, even those not backed by a file (e.g., taxonomy and term pages). Querying this collection based on a file name, when some members of the collection are not backed by a file, is nonsensical and the root of the problem.
We’ve been warning site and theme authors about this construct for several years. For example, with v0.122.0:
WARN .File.BaseFileName on zero object. Wrap it in if or with: {{ with .File }}{{ .BaseFileName }}{{ end }}
Ok , thanks but before a warning was given but with NO FILE NAME , so I never found how to solve.
Now , the file name is given and with you answer I had solved this problem (also in 0.122)
So this can be closed.