Skip to content
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

Closed
4 of 12 tasks
marshalc opened this issue Feb 15, 2024 · 10 comments · Fixed by #1866
Assignees
Labels
bug Something isn't working

Comments

@marshalc
Copy link

marshalc commented Feb 15, 2024

Environment

  • Version of Docsy you are using: 0.9.0
  • How are you using Docsy? As a:
    • Hugo module -- require github.com/google/docsy v0.9.0 // indirect
    • NPM module
    • Git submodule
    • Other:
  • Version of Hugo you are using (output of hugo version): 0.122.0 Extended
  • OS:
    • Linux
    • macOS: hugo v0.122.0-b9a03bd59d5f71a529acb3e33f995e0ef332b3aa+extended darwin/amd64 BuildDate=2024-01-26T15:54:24Z VendorInfo=brew
    • Windows
    • Other:

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:

  1. hugo new site docs & cd docs
Congratulations! Your new Hugo site was created in /Users/carl/Projects/temp/docsy-plain-test/docs.

Just a few more steps...

1. Change the current directory to /Users/carl/Projects/temp/docsy-plain-test/docs.
2. Create or install a theme:
   - Create a new theme with the command "hugo new theme <THEMENAME>"
   - Install a theme from https://themes.gohugo.io/
3. Edit hugo.toml, setting the "theme" property to the theme name.
4. Create new content with the command "hugo new content <SECTIONNAME>/<FILENAME>.<FORMAT>".
5. Start the embedded web server with the command "hugo server --buildDrafts".

See documentation at https://gohugo.io/.
  1. hugo mod init local.host/temp/docsy-plain-test
go: creating new go.mod: module local.host/temp/docsy-plain-test
go: to add module requirements and sums:
	go mod tidy
  1. hugo mod get github.com/google/docsy@latest
go: downloading github.com/google/docsy v0.9.0
go: added github.com/google/docsy v0.9.0
  1. Test without any content in place:
hugo server
port 1313 already in use, attempting to use an available port
Watching for changes in /Users/carl/Projects/temp/docsy-plain-test/docs/{archetypes,assets,content,data,i18n,layouts,static}
Watching for config changes in /Users/carl/Projects/temp/docsy-plain-test/docs/hugo.toml, /Users/carl/Projects/temp/docsy-plain-test/docs/go.mod
Start building sites …
hugo v0.122.0-b9a03bd59d5f71a529acb3e33f995e0ef332b3aa+extended darwin/amd64 BuildDate=2024-01-26T15:54:24Z VendorInfo=brew

WARN  found no layout file for "html" for kind "home": You should create a template file which matches Hugo Layouts Lookup Rules for this combination.
WARN  found no layout file for "html" for kind "taxonomy": You should create a template file which matches Hugo Layouts Lookup Rules for this combination.

                   | EN
-------------------+-----
  Pages            |  3
  Paginator pages  |  0
  Non-page files   |  0
  Static files     |  0
  Processed images |  0
  Aliases          |  0
  Sitemaps         |  1
  Cleaned          |  0

Built in 2 ms
Environment: "development"
Serving pages from memory
Running in Fast Render Mode. For full rebuilds on change: hugo server --disableFastRender
Web Server is available at http://localhost:60042/ (bind address 127.0.0.1)
Press Ctrl+C to stop
  1. Add minimal config: rename hugo.toml -> hugo.yaml and populate with:
baseURL: https://localhost:1313/
languageCode: en-gb
title: My New Hugo Site

module:
  proxy: direct
  hugoVersion:
    extended: true
    min: 0.110.0
  imports:
    - path: github.com/google/docsy
      disable: false
  1. Create docs/_index.md with the following content:
---
title: Hello
---

Placeholder
  1. Test site with hugo server
hugo server
port 1313 already in use, attempting to use an available port
Watching for changes in /Users/carl/Projects/temp/docsy-plain-test/docs/{archetypes,assets,content,data,i18n,layouts,static}
Watching for config changes in /Users/carl/Projects/temp/docsy-plain-test/docs/hugo.yaml, /Users/carl/Projects/temp/docsy-plain-test/docs/go.mod
Start building sites …
hugo v0.122.0-b9a03bd59d5f71a529acb3e33f995e0ef332b3aa+extended darwin/amd64 BuildDate=2024-01-26T15:54:24Z VendorInfo=brew


                   | EN
-------------------+-----
  Pages            |  7
  Paginator pages  |  0
  Non-page files   |  0
  Static files     | 30
  Processed images |  0
  Aliases          |  0
  Sitemaps         |  1
  Cleaned          |  0

Built in 658 ms
Environment: "development"
Serving pages from memory
Running in Fast Render Mode. For full rebuilds on change: hugo server --disableFastRender
Web Server is available at http://localhost:60575/ (bind address 127.0.0.1)
Press Ctrl+C to stop

See a valid plain hugo+docsy page at the test url, all good.

  1. Now edit the _index.md and add type: docs to the frontmatter
---
title: Hello
type: docs
---

Placeholder

... and when you save the browser will now show the following error screen:

<div class="error" style="font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0); font-family: Muli, system-ui, -apple-system, &quot;Segoe UI&quot;, Roboto, &quot;Helvetica Neue&quot;, &quot;Noto Sans&quot;, &quot;Liberation Sans&quot;, Arial, sans-serif, &quot;Apple Color Emoji&quot;, &quot;Segoe UI Emoji&quot;, &quot;Segoe UI Symbol&quot;, &quot;Noto Color Emoji&quot;; font-size: 14px;"><div class="highlight" style="overflow-x: auto;"><pre tabindex="0" style="white-space: pre-wrap; overflow-wrap: break-word; font-family: SFMono-Regular, Menlo, Monaco, Consolas, &quot;Liberation Mono&quot;, &quot;Courier New&quot;, monospace; line-height: 1.5; color: rgb(248, 248, 242); background-color: rgb(40, 42, 54); tab-size: 4;"><code class="language-apl" data-lang="apl" style="white-space: pre-wrap; overflow-wrap: break-word; font-family: SFMono-Regular, Menlo, Monaco, Consolas, &quot;Liberation Mono&quot;, &quot;Courier New&quot;, monospace;"><span style="display: flex;"><span> <span style="color: rgb(139, 233, 253); font-style: italic;">render</span>: <span style="color: rgb(139, 233, 253); font-style: italic;">failed</span> <span style="color: rgb(139, 233, 253); font-style: italic;">to</span> <span style="color: rgb(139, 233, 253); font-style: italic;">render</span> <span style="color: rgb(139, 233, 253); font-style: italic;">pages</span>: <span style="color: rgb(139, 233, 253); font-style: italic;">render</span> <span style="color: rgb(139, 233, 253); font-style: italic;">of</span> <span style="color: rgb(241, 250, 140);">"home"</span> <span style="color: rgb(139, 233, 253); font-style: italic;">failed</span>: �<span style="color: rgb(241, 250, 140);">[</span><span style="color: rgb(189, 147, 249);">1</span><span style="color: rgb(241, 250, 140);">;</span><span style="color: rgb(189, 147, 249);">36</span><span style="color: rgb(139, 233, 253); font-style: italic;">m</span><span style="color: rgb(241, 250, 140);">"/Users/carl/.local/share/hugo/modules/filecache/modules/pkg/mod/github.com/google/docsy@v0.9.0/layouts/docs/list.html:12:5"</span><span style="color: rgb(241, 250, 140);">[</span><span style="color: rgb(189, 147, 249);">0</span><span style="color: rgb(139, 233, 253); font-style: italic;">m</span>: <span style="color: rgb(139, 233, 253); font-style: italic;">execute</span> <span style="color: rgb(139, 233, 253); font-style: italic;">of</span> <span style="color: rgb(139, 233, 253); font-style: italic;">template</span> <span style="color: rgb(139, 233, 253); font-style: italic;">failed</span> <span style="color: rgb(139, 233, 253); font-style: italic;">at</span> <span style="color: rgb(255, 121, 198);">&lt;</span><span style="color: rgb(139, 233, 253); font-style: italic;">partial</span> <span style="color: rgb(241, 250, 140);">"section-index.html"</span> <span style="color: rgb(80, 250, 123);">.</span><span style="color: rgb(255, 121, 198);">&gt;</span>: <span style="color: rgb(139, 233, 253); font-style: italic;">error</span> <span style="color: rgb(139, 233, 253); font-style: italic;">calling</span> <span style="color: rgb(139, 233, 253); font-style: italic;">partial</span>: �<span style="color: rgb(241, 250, 140);">[</span><span style="color: rgb(189, 147, 249);">1</span><span style="color: rgb(241, 250, 140);">;</span><span style="color: rgb(189, 147, 249);">36</span><span style="color: rgb(139, 233, 253); font-style: italic;">m</span><span style="color: rgb(241, 250, 140);">"/Users/carl/.local/share/hugo/modules/filecache/modules/pkg/mod/github.com/google/docsy@v0.9.0/layouts/partials/section-index.html:7:17"</span><span style="color: rgb(241, 250, 140);">[</span><span style="color: rgb(189, 147, 249);">0</span><span style="color: rgb(139, 233, 253); font-style: italic;">m</span>: <span style="color: rgb(139, 233, 253); font-style: italic;">execute</span> <span style="color: rgb(139, 233, 253); font-style: italic;">of</span> <span style="color: rgb(139, 233, 253); font-style: italic;">template</span> <span style="color: rgb(139, 233, 253); font-style: italic;">failed</span> <span style="color: rgb(139, 233, 253); font-style: italic;">at</span> <span style="color: rgb(255, 121, 198);">&lt;</span><span style="color: rgb(80, 250, 123);">.</span><span style="color: rgb(139, 233, 253); font-style: italic;">Parent</span><span style="color: rgb(80, 250, 123);">.</span><span style="color: rgb(139, 233, 253); font-style: italic;">File</span><span style="color: rgb(255, 121, 198);">&gt;</span>: <span style="color: rgb(139, 233, 253); font-style: italic;">nil</span> <span style="color: rgb(139, 233, 253); font-style: italic;">pointer</span> <span style="color: rgb(139, 233, 253); font-style: italic;">evaluating</span> <span style="color: rgb(139, 233, 253); font-style: italic;">page</span><span style="color: rgb(80, 250, 123);">.</span><span style="color: rgb(139, 233, 253); font-style: italic;">Page</span><span style="color: rgb(80, 250, 123);">.</span><span style="color: rgb(139, 233, 253); font-style: italic;">File</span> </span></span></code></pre></div></div><hr style="font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; margin-bottom: 1rem; border: medium; height: 1px; background-color: rgb(61, 61, 61); font-family: Muli, system-ui, -apple-system, &quot;Segoe UI&quot;, Roboto, &quot;Helvetica Neue&quot;, &quot;Noto Sans&quot;, &quot;Liberation Sans&quot;, Arial, sans-serif, &quot;Apple Color Emoji&quot;, &quot;Segoe UI Emoji&quot;, &quot;Segoe UI Symbol&quot;, &quot;Noto Color Emoji&quot;; font-size: 14px;"><code class="filename" style="font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: pre-wrap; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; overflow-wrap: break-word; font-family: SFMono-Regular, Menlo, Monaco, Consolas, &quot;Liberation Mono&quot;, &quot;Courier New&quot;, monospace; color: rgb(238, 247, 138); font-size: 0.9rem; line-height: 1.5;">/Users/carl/.local/share/hugo/modules/filecache/modules/pkg/mod/github.com/google/docsy@v0.9.0/layouts/docs/list.html:12:5:</code><span style="font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0); font-family: Muli, system-ui, -apple-system, &quot;Segoe UI&quot;, Roboto, &quot;Helvetica Neue&quot;, &quot;Noto Sans&quot;, &quot;Liberation Sans&quot;, Arial, sans-serif, &quot;Apple Color Emoji&quot;, &quot;Segoe UI Emoji&quot;, &quot;Segoe UI Symbol&quot;, &quot;Noto Color Emoji&quot;; font-size: 14px; background-color: rgb(39, 42, 54); float: none; display: inline !important;"></span><div class="highlight" style="font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; overflow-x: auto; caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0); font-family: Muli, system-ui, -apple-system, &quot;Segoe UI&quot;, Roboto, &quot;Helvetica Neue&quot;, &quot;Noto Sans&quot;, &quot;Liberation Sans&quot;, Arial, sans-serif, &quot;Apple Color Emoji&quot;, &quot;Segoe UI Emoji&quot;, &quot;Segoe UI Symbol&quot;, &quot;Noto Color Emoji&quot;; font-size: 14px;"><div style="color: rgb(248, 248, 242); background-color: rgb(40, 42, 54); tab-size: 4; display: grid;">
  | </header> 	{{ .Content }}   {{ partial "section-index.html" . -}} 	{{ partial "feedback.html" . -}} 	{{ if (.Site.DisqusShortname) -}}
-- | --


</div></div><hr style="font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; margin-bottom: 1rem; border: medium; height: 1px; background-color: rgb(61, 61, 61); font-family: Muli, system-ui, -apple-system, &quot;Segoe UI&quot;, Roboto, &quot;Helvetica Neue&quot;, &quot;Noto Sans&quot;, &quot;Liberation Sans&quot;, Arial, sans-serif, &quot;Apple Color Emoji&quot;, &quot;Segoe UI Emoji&quot;, &quot;Segoe UI Symbol&quot;, &quot;Noto Color Emoji&quot;; font-size: 14px;"><p class="version" style="font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; font-size: 0.75rem; color: rgb(124, 124, 124); font-family: Muli, system-ui, -apple-system, &quot;Segoe UI&quot;, Roboto, &quot;Helvetica Neue&quot;, &quot;Noto Sans&quot;, &quot;Liberation Sans&quot;, Arial, sans-serif, &quot;Apple Color Emoji&quot;, &quot;Segoe UI Emoji&quot;, &quot;Segoe UI Symbol&quot;, &quot;Noto Color Emoji&quot;;">hugo v0.122.0-b9a03bd59d5f71a529acb3e33f995e0ef332b3aa+extended darwin/amd64 BuildDate=2024-01-26T15:54:24Z VendorInfo=brew</p><a href="" style="font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; color: rgb(5, 148, 203); text-decoration: none; font-family: Muli, system-ui, -apple-system, &quot;Segoe UI&quot;, Roboto, &quot;Helvetica Neue&quot;, &quot;Noto Sans&quot;, &quot;Liberation Sans&quot;, Arial, sans-serif, &quot;Apple Color Emoji&quot;, &quot;Segoe UI Emoji&quot;, &quot;Segoe UI Symbol&quot;, &quot;Noto Color Emoji&quot;; font-size: 14px;">Reload Page</a>render: failed to render pages: render of "home" failed: �[1;36m"/Users/carl/.local/share/hugo/modules/filecache/modules/pkg/mod/github.com/google/docsy@v0.9.0/layouts/docs/list.html:12:5"�[0m: execute of template failed at <partial "section-index.html" .>: error calling partial: �[1;36m"/Users/carl/.local/share/hugo/modules/filecache/modules/pkg/mod/github.com/google/docsy@v0.9.0/layouts/partials/section-index.html:7:17"�[0m: execute of template failed at <.Parent.File>: nil pointer evaluating page.Page.File 
/Users/carl/.local/share/hugo/modules/filecache/modules/pkg/mod/github.com/google/docsy@v0.9.0/layouts/docs/list.html:12:5:
	</header>
	{{ .Content }}
  {{ partial "section-index.html" . -}}
	{{ partial "feedback.html" . -}}
	{{ if (.Site.DisqusShortname) -}}
/Users/carl/.local/share/hugo/modules/filecache/modules/pkg/mod/github.com/google/docsy@v0.9.0/layouts/partials/section-index.html:7:17:
    {{ $pages = (where $pages ".Params.hide_summary" "!=" true) -}}
    {{ $pages = (where $pages ".Parent" "!=" nil) -}}
    {{ if .Parent.File -}}
        {{ $pages = (where $pages "Parent.File.UniqueID" "==" $parent.File.UniqueID) -}}
    {{ end -}}
hugo v0.122.0-b9a03bd59d5f71a529acb3e33f995e0ef332b3aa+extended darwin/amd64 BuildDate=2024-01-26T15:54:24Z VendorInfo=brew

[Reload Page](https://github.com/google/docsy/issues/new?assignees=&labels=bug%2Cneeds-triage&projects=&template=bug.md)

and the command line echos this with:

Change detected, rebuilding site.
2024-02-15 22:05:30.764 +0000
Source changed WRITE         "/Users/carl/Projects/temp/docsy-plain-test/docs/content/_index.md"
ERROR Rebuild failed: 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 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:17": execute of template failed at <.Parent.File>: nil pointer evaluating page.Page.File
Total in 6 ms

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...?

@marshalc marshalc added bug Something isn't working needs-triage labels Feb 15, 2024
@chulcher
Copy link

chulcher commented Feb 15, 2024

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 .Parent.File */ -}}
        {{ $pages = (where $pages "Parent.File.UniqueID" "==" $parent.File.UniqueID) -}}
    {{/* end */ -}}

@marshalc
Copy link
Author

If I modify layouts/partials/section-index.html by changing the existence test like so:

    {{ $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 docs page type appearing. However, I'm not at all confident in my go templating language, so I'm unsure if this is doing the correct test - though I think it's checking that $pages, which should have been set to .Parent if parent wasn't nil, is not none, and that it has something set for the .File attribute -- thus the contained clause can presume to find UniqueID on $pages.Parent.File.UniqueID.

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 {{ if (and $pages.Parent $pages.Parent.File) -}}
I got an error 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.

@marshalc
Copy link
Author

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 .Parent.File */ -}}
        {{ $pages = (where $pages "Parent.File.UniqueID" "==" $parent.File.UniqueID) -}}
    {{/* end */ -}}

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.

@marshalc
Copy link
Author

marshalc commented Feb 15, 2024

Looking at that PR you highlighted - I note the text shows the wrapper to be a with - end statement rather than if - end as it seems to be in the code. Wondering if that makes a difference?

Edit: Nope - errors too if if is replaced with with

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

@marshalc
Copy link
Author

marshalc commented Feb 15, 2024

If I modify layouts/partials/section-index.html by changing the existence test like so:

    {{ $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) -}}

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: WARN .File.UniqueID on zero object. Wrap it in if or with: {{ with .File }}{{ .UniqueID }}{{ end }}

@chalin
Copy link
Collaborator

chalin commented Feb 15, 2024

Wow, thank you for the detailed feedback @marshalc and the supporting comments @chulcher.
I'll let @deining take a look since he work on #1633.

marshalc pushed a commit to ouhft/docsy that referenced this issue Feb 15, 2024
@chalin chalin self-assigned this Feb 15, 2024
@chalin
Copy link
Collaborator

chalin commented Feb 15, 2024

For a fix, see:

@chulcher
Copy link

This appears to be further broken with Hugo 0.123.1.

ERROR render of "taxonomy" failed:
"C:\Users\Carson\AppData\Local\hugo_cache\modules\filecache\modules\pkg\mod\github.com\google\docsy@v0.9.1\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: "C:\Users\Carson\AppData\Local\hugo_cache\modules\filecache\modules\pkg\mod\github.com\google\docsy@v0.9.1\layouts\partials\section-index.html:8:69": execute of template failed: template: partials/section-index.html:8:69: executing "partials/section-index.html" at <$parent.File.UniqueID>: error calling UniqueID: runtime error: invalid memory address or nil pointer dereference
Built in 936 ms
Error: error building site: render: failed to render pages: render of "taxonomy" failed: "C:\Users\Carson\AppData\Local\hugo_cache\modules\filecache\modules\pkg\mod\github.com\google\docsy@v0.9.1\layouts\docs\list.html:12:5": execute of template failed: template: docs/list.html:12:5: executing "main" – File is nil; wrap it in if or with: {{ with partial "section-index.html" .>: error calling partial: "C:\Users\Carson\AppData\Local\hugo_cache\modules\filecache\modules\pkg\mod\github.com\google\docsy@v0.9.1\layouts\partials\section-index.html:8:69": execute of template failed: template: partials/section-index.html:8:69: executing "partials/section-index.html" at <.File }}{{ .UniqueID }}{{ end }}

gohugoio/hugo#12068, specifically gohugoio/hugo#12068 (comment) relevant?

@chulcher
Copy link

No idea if this is applying the fix or just hiding the issue but changing:

{{ if and .Parent .Parent.File -}}
        {{ $pages = (where $pages "Parent.File.UniqueID" "==" $parent.File.UniqueID) -}}
{{ end -}}

to:

{{ if and .Parent .Parent.File -}}
    {{with $parent.File}}{{ $pages = (where $pages "Parent.File.UniqueID" "==" .UniqueID) -}}{{end}}
{{ end -}}

allows for a successful build.

@chalin
Copy link
Collaborator

chalin commented Feb 25, 2024

Thanks @chulcher, we'll track the issue you reported via:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants