-
Notifications
You must be signed in to change notification settings - Fork 894
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
0.9.0: execute of template failed at <.Parent.File>: nil pointer evaluating page.Page.File -- error when using page type docs #1863
Comments
Seeing the same thing after I updated my work in progress site. #1633 appears to be the culprit, override that page and comment out the if/end and the page renders fine again. section-index.html Comment out the if/end or just remove those lines to go back to 0.8.0 behavior.
|
If I modify {{ $pages = (where $pages ".Parent" "!=" nil) -}}
{{ if (and $pages $pages.File) -}}
{{ $pages = (where $pages "Parent.File.UniqueID" "==" $parent.File.UniqueID) -}}
{{ end -}}
{{ if or $parent.Params.no_list (eq (len $pages) 0) -}} ... then I get a working That said, I'm not sure if the first lines are filters for the $pages object, or if they're setting $pages to a modified value. When I tried a test of Error: error building site: render: failed to render pages: render of "home" failed: "/Users/carl/.local/share/hugo/modules/filecache/modules/pkg/mod/github.com/google/docsy@v0.9.0/layouts/docs/list.html:12:5": execute of template failed: template: docs/list.html:12:5: executing "main" at <partial "section-index.html" .>: error calling partial: "/Users/carl/.local/share/hugo/modules/filecache/modules/pkg/mod/github.com/google/docsy@v0.9.0/layouts/partials/section-index.html:7:21": execute of template failed: template: partials/section-index.html:7:21: executing "partials/section-index.html" at <$pages.Parent>: can't evaluate field Parent in type page.Pages ... hence having little confidence that this is a fix opposed to something that bypasses the problem. |
Heh, I think we were trying and typing at the same time. Agreed, removing the if test also solved the problem - but made me think that the .FileID problem might return if not trapped somehow. I've certainly been seeing Warnings about .FileID being Null elsewhere in some of the sites I've been working on recently, and I'm not sure this is unrelated. |
Looking at that PR you highlighted - I note the text shows the wrapper to be a Edit: Nope - errors too if {{ with .Parent.File -}}
{{ $pages = (where $pages "Parent.File.UniqueID" "==" $parent.File.UniqueID) -}}
{{ end -}} Error: error building site: render: failed to render pages: render of "home" failed: "/Users/carl/.local/share/hugo/modules/filecache/modules/pkg/mod/github.com/google/docsy@v0.9.0/layouts/docs/list.html:12:5": execute of template failed: template: docs/list.html:12:5: executing "main" at <partial "section-index.html" .>: error calling partial: "/Users/carl/.local/share/hugo/modules/filecache/modules/pkg/mod/github.com/google/docsy@v0.9.0/layouts/partials/section-index.html:7:19": execute of template failed: template: partials/section-index.html:7:19: executing "partials/section-index.html" at <.Parent.File>: nil pointer evaluating page.Page.File |
This isn't a working fix for anything other than a single page site. I tried this in a site with several folders of (valid) content and got back this pile of errors: hugo server
Watching for changes in /Users/carl/Projects/pages.oxnet/www/pages-ouh-hugo/pages-ouh-hugo-repo/docs/{archetypes,content,package.json}
Watching for config changes in /Users/carl/Projects/pages.oxnet/www/pages-ouh-hugo/pages-ouh-hugo-repo/docs/hugo.yaml, /Users/carl/Projects/pages.oxnet/www/pages-ouh-hugo/pages-ouh-hugo-repo/docs/go.mod
Start building sites …
hugo v0.122.0-b9a03bd59d5f71a529acb3e33f995e0ef332b3aa+extended darwin/amd64 BuildDate=2024-01-26T15:54:24Z VendorInfo=brew
ERROR render of "taxonomy" failed: "/Users/carl/.local/share/hugo/modules/filecache/modules/pkg/mod/github.com/ouhft/docsy@v0.0.0-20240215095853-47c9d950ff0d/layouts/docs/list.html:12:5": execute of template failed: template: docs/list.html:12:5: executing "main" at <partial "section-index.html" .>: error calling partial: "/Users/carl/.local/share/hugo/modules/filecache/modules/pkg/mod/github.com/ouhft/docsy@v0.0.0-20240215095853-47c9d950ff0d/layouts/partials/section-index.html:7:28": execute of template failed: template: partials/section-index.html:7:28: executing "partials/section-index.html" at <$pages.File>: can't evaluate field File in type page.Pages
ERROR render of "home" failed: "/Users/carl/.local/share/hugo/modules/filecache/modules/pkg/mod/github.com/ouhft/docsy@v0.0.0-20240215095853-47c9d950ff0d/layouts/docs/list.html:12:5": execute of template failed: template: docs/list.html:12:5: executing "main" at <partial "section-index.html" .>: error calling partial: "/Users/carl/.local/share/hugo/modules/filecache/modules/pkg/mod/github.com/ouhft/docsy@v0.0.0-20240215095853-47c9d950ff0d/layouts/partials/section-index.html:7:28": execute of template failed: template: partials/section-index.html:7:28: executing "partials/section-index.html" at <$pages.File>: can't evaluate field File in type page.Pages
ERROR render of "section" failed: "/Users/carl/.local/share/hugo/modules/filecache/modules/pkg/mod/github.com/ouhft/docsy@v0.0.0-20240215095853-47c9d950ff0d/layouts/docs/list.html:12:5": execute of template failed: template: docs/list.html:12:5: executing "main" at <partial "section-index.html" .>: error calling partial: "/Users/carl/.local/share/hugo/modules/filecache/modules/pkg/mod/github.com/ouhft/docsy@v0.0.0-20240215095853-47c9d950ff0d/layouts/partials/section-index.html:7:28": execute of template failed: template: partials/section-index.html:7:28: executing "partials/section-index.html" at <$pages.File>: can't evaluate field File in type page.Pages
Built in 1028 ms
Error: error building site: render: failed to render pages: render of "section" failed: "/Users/carl/.local/share/hugo/modules/filecache/modules/pkg/mod/github.com/ouhft/docsy@v0.0.0-20240215095853-47c9d950ff0d/layouts/docs/list.html:12:5": execute of template failed: template: docs/list.html:12:5: executing "main" at <partial "section-index.html" .>: error calling partial: "/Users/carl/.local/share/hugo/modules/filecache/modules/pkg/mod/github.com/ouhft/docsy@v0.0.0-20240215095853-47c9d950ff0d/layouts/partials/section-index.html:7:28": execute of template failed: template: partials/section-index.html:7:28: executing "partials/section-index.html" at <$pages.File>: can't evaluate field File in type page.Pages The only real difference in this case was this was linked to my fork of the docsy 0.9.0 release. That said, if I follow @chulcher 's advice and just remove the test, the site builds just fine. Albeit with this reappearing: |
For a fix, see: |
This appears to be further broken with Hugo 0.123.1.
gohugoio/hugo#12068, specifically gohugoio/hugo#12068 (comment) relevant? |
No idea if this is applying the fix or just hiding the issue but changing:
to:
allows for a successful build. |
Thanks @chulcher, we'll track the issue you reported via: |
Environment
require github.com/google/docsy v0.9.0 // indirect
hugo version
): 0.122.0 Extendedhugo v0.122.0-b9a03bd59d5f71a529acb3e33f995e0ef332b3aa+extended darwin/amd64 BuildDate=2024-01-26T15:54:24Z VendorInfo=brew
Problem
I first found this issue when updating a new site from 0.8.0 to 0.9.0, first on my own fork, then reconfirmed using the direct from this repo.
Steps to recreate:
hugo new site docs
&cd docs
hugo mod init local.host/temp/docsy-plain-test
hugo mod get github.com/google/docsy@latest
hugo.toml
->hugo.yaml
and populate with:docs/_index.md
with the following content:hugo server
See a valid plain hugo+docsy page at the test url, all good.
_index.md
and addtype: docs
to the frontmatter... and when you save the browser will now show the following error screen:
and the command line echos this with:
I've tried this on about 5 different sites (old and new) and it all narrows down to setting the
type: docs
, and this partial coming up as the fault. I haven't yet found a fix... but I'm puzzled as to if I'm the doing something wrong to have been the first to report this...?The text was updated successfully, but these errors were encountered: