Upgrade from 0.122 to 0.123

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 }}

When posting code, configuration, or data on this forum, please wrap the text within backticks or use the </> button in the menu.

```
my code
```

I’ve edited your post accordingly.

Take this example:

{{ where site.Pages "File.BaseFileName" "p1" }}

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 }}

With v0.123.0 and later we’ve stopped warning you, throwing an error instead. Whether or not we should be doing that is debatable: https://github.com/gohugoio/hugo/issues/12176

Instead of querying all pages, just query regular pages (excludes section, taxonomy, and term pages):

{{ where site.RegularPages "File.BaseFileName" "p1" }}

Or query the logical path using a regular expression:

{{ where site.Pages "Path" "like" "^/p1$" }}

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.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.