hugo v0.97.3-078053a43d746a26aa3d48cf1ec7122ae78a9bb4 windows/amd64 BuildDate=2022-04-18T17:22:19Z VendorInfo=gohugoio
When I generate the site I get the error(s):
execute of template failed: template: partials/prints-sidebar.html:7:51: executing “partials/prints-sidebar.html” at <.Parent.Dir>: can’t evaluate field Dir in type page.Page
It seems to be in the next part of the code:
…
{{- $path := (print .Parent.Dir) -}} ← This is line 7
{{- $prints := where .Site.Pages “Section” “artists” -}}
{{- range $prints }}
{{- if hasPrefix .Dir $path }}
…
With a previous version 0.91.2 I didn’t have this problem. What do I need to change?
at <.Dir>: can’t evaluate field Dir in type page.Page
{{- $path := (print .Parent.File.Dir) -}}
{{- $prints := where .Site.Pages "Section" "artists" -}}
{{- range $prints }}
{{- if hasPrefix .Dir $path }} <-- Now an error at this line
at <.Dir>: can’t evaluate field Dir in type page.Page
{{- $path := (print .File.Dir) -}}
{{- $prints := where .Site.Pages "Section" "artists" -}}
{{- range $prints }} <-- Now I get an error at this line
{{- if hasPrefix .File.Dir $path }}
{{- $path := (print .Parent.File.Dir) -}}
{{- $prints := where site.Pages "Section" "artists" -}}
{{- range $prints }} <-- Now I get the error here :(
{{- if hasPrefix .File.Dir $path }}
at <.Dir>: can’t evaluate field Dir in type page.Page
I had a similar error recently and .File.Dir worked for me. The change was introduced in this version. Share your repository and the error you are getting now and perhaps @jmooring can help you.
Fixed!!!
For some reason the error didn’t report the correct file/line number. There was an other file where I also needed to change to .File.Dir.
Thnx for the hints