Skip to content

0.9.0: execute of template failed at <.Parent.File>: nil pointer evaluating page.Page.File -- error when using page type docs #1863

@marshalc

Description

@marshalc

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

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions