Layout lookup path for modules calling "local" partials in v0.146+

I am experiencing an error, where GoHugo does not find partials anymore, if they are located in “weird” places (I guess…). This was not an issue before, so I created a testable minimal case.

I think Hugo is having a hard time resolving local layout files from within modules.

Reproduction

  1. clone this branch
git clone -b v0.146.3-layout-order https://github.com/davidsneighbour/gohugo-debugging.git
  1. install GoHugo v0.145.0 and run hugo server - you will see a red “hello world” on all pages
  2. install GoHugo v0.146.3 and run hugo server - errors as described below

The Issue

I have a GoHugo Module that implements a hook system for theme developers. The theme developer defines a location where the hook should be run, and users can configure partials to run at that location.

In v0.146 this results in errors

gohugo-debugging on  v0.146.3-layout-order [$?] via 🐹 v1.24.2
➜ hugo server

Watching for changes in /home/patrick/github.com/davidsneighbour/gohugo-debugging/{archetypes,assets,content,layouts,static}

Watching for config changes in /home/patrick/github.com/davidsneighbour/gohugo-debugging/hugo.toml, /home/patrick/github.com/davidsneighbour/gohugo-debugging/go.mod

Start building sites …

hugo v0.146.3-05ef8b713a3c091bfca7a3543ed016c64b3c6f88+extended linux/amd64 BuildDate=2025-04-12T17:21:50Z VendorInfo=gohugoio

WARN [dnb/debug-0] additional logging by dnb-debug (see https://dnbql.netlify.app/log)

WARN Partial name "partials/hooks/hello-world.html" starting with 'partials/' (as in {{ partial "partials/hooks/hello-world.html"}}) is most likely not what you want. Before 0.146.0 we did a double lookup in this situation.

You can suppress this warning by adding the following to your site configuration:

ignoreLogs = ['warning-partial-superfluous-prefix']

ERROR render of "/tags/red" failed: "/home/patrick/github.com/davidsneighbour/gohugo-debugging/layouts/_default/baseof.html:11:8": execute of template failed: template: list.html:11:8: executing "list.html" at <partial "func/hook.html" "content-start">: error calling partial: "/home/patrick/.cache/hugo_cache/modules/filecache/modules/pkg/mod/github.com/davidsneighbour/hugo-modules/modules/hooks@v1.2024.16/layouts/partials/func/hook.html:46:24": execute of template failed: template: _partials/func/hook.html:46:24: executing "_partials/func/hook.html" at <partials.Include>: error calling Include: partial "partials/hooks/hello-world.html" not found

ERROR render of "/home/patrick/github.com/davidsneighbour/gohugo-debugging/content/posts/post-1.md" failed: "/home/patrick/github.com/davidsneighbour/gohugo-debugging/layouts/_default/baseof.html:11:8": execute of template failed: template: single.html:11:8: executing "single.html" at <partial "func/hook.html" "content-start">: error calling partial: "/home/patrick/.cache/hugo_cache/modules/filecache/modules/pkg/mod/github.com/davidsneighbour/hugo-modules/modules/hooks@v1.2024.16/layouts/partials/func/hook.html:46:24": execute of template failed: template: _partials/func/hook.html:46:24: executing "_partials/func/hook.html" at <partials.Include>: error calling Include: partial "partials/hooks/hello-world.html" not found

ERROR render of "/tags/green" failed: "/home/patrick/github.com/davidsneighbour/gohugo-debugging/layouts/_default/baseof.html:11:8": execute of template failed: template: list.html:11:8: executing "list.html" at <partial "func/hook.html" "content-start">: error calling partial: "/home/patrick/.cache/hugo_cache/modules/filecache/modules/pkg/mod/github.com/davidsneighbour/hugo-modules/modules/hooks@v1.2024.16/layouts/partials/func/hook.html:46:24": execute of template failed: template: _partials/func/hook.html:46:24: executing "_partials/func/hook.html" at <partials.Include>: error calling Include: partial "partials/hooks/hello-world.html" not found

ERROR render of "/categories" failed: "/home/patrick/github.com/davidsneighbour/gohugo-debugging/layouts/_default/baseof.html:11:8": execute of template failed: template: list.html:11:8: executing "list.html" at <partial "func/hook.html" "content-start">: error calling partial: "/home/patrick/.cache/hugo_cache/modules/filecache/modules/pkg/mod/github.com/davidsneighbour/hugo-modules/modules/hooks@v1.2024.16/layouts/partials/func/hook.html:46:24": execute of template failed: template: _partials/func/hook.html:46:24: executing "_partials/func/hook.html" at <partials.Include>: error calling Include: partial "partials/hooks/hello-world.html" not found

Built in 3 ms

Error: error building site: render: failed to render pages: render of "/home/patrick/github.com/davidsneighbour/gohugo-debugging/content/_index.md" failed: "/home/patrick/github.com/davidsneighbour/gohugo-debugging/layouts/_default/baseof.html:11:8": execute of template failed: template: home.html:11:8: executing "home.html" at <partial "func/hook.html" "content-start">: error calling partial: "/home/patrick/.cache/hugo_cache/modules/filecache/modules/pkg/mod/github.com/davidsneighbour/hugo-modules/modules/hooks@v1.2024.16/layouts/partials/func/hook.html:46:24": execute of template failed: template: _partials/func/hook.html:46:24: executing "_partials/func/hook.html" at <partials.Include>: error calling Include: partial "partials/hooks/hello-world.html" not found

gohugo-debugging on  v0.146.3-layout-order [$?] via 🐹 v1.24.2

❯

Setup

  • “location” of the hook = layouts/_default/baseof.html line 11
  • Hugo Hook Module
  • configuration of the hook = hugo.toml line 29ff

Can you boil this down a bit?

{{ partial “file.html” . }} does not work if a layout file in a module calls a file in the repo that is importing that module.

From the warning and error messages above, it looks like you’re doing this:

{{ partials "partials/foo.html" }}

Instead of:

{{ partials "foo.html" }}

Where the layouts directory is structured like this:

layouts/
└── partials/
    └── foo.html

From the repository, it does not look like it:

The repository above is a minimal example, just hugo new site and hugo new theme with the module.

Let’s ignore this issue. I will use v0.145.0 until I debugged this issue or solved it otherwise. I am dialing down on my “module use” and it’s probably just a loop or some other weird code thing.

I had the same kinda error:

❯ hugo serve
WARN  deprecated: site config key services.twitter.disableInlineCSS was deprecated in Hugo v0.141.0 and will be removed in a future release. Use services.x.disableInlineCSS instead.
Watching for changes in /Users/suyoggarg/Dropbox/suyog7130.github.io/{assets,content,static,themes}
Watching for config changes in /Users/suyoggarg/Dropbox/suyog7130.github.io/config.yml
Start building sites …
hugo v0.146.7+extended+withdeploy darwin/amd64 BuildDate=2025-04-22T17:26:42Z VendorInfo=brew

WARN  Partial name "partials/templates/_funcs/get-page-images" starting with 'partials/' (as in {{ partial "partials/templates/_funcs/get-page-images"}}) is most likely not what you want. Before 0.146.0 we did a double lookup in this situation.
You can suppress this warning by adding the following to your site configuration:
ignoreLogs = ['warning-partial-superfluous-prefix']
ERROR render of "/Users/suyoggarg/Dropbox/suyog7130.github.io/content/archives-hi.md" failed: "/Users/suyoggarg/Dropbox/suyog7130.github.io/themes/hugo-PaperMod/layouts/_default/baseof.html:9:8": execute of template failed: template: archives.html:9:8: executing "archives.html" at <partial "head.html" .>: error calling partial: "/Users/suyoggarg/Dropbox/suyog7130.github.io/themes/hugo-PaperMod/layouts/partials/head.html:88:19": execute of template failed: template: _partials/templates/schema_json.html:88:19: executing "partials/templates/schema_json.html" at <partial "partials/templates/_funcs/get-page-images" .>: error calling partial: partial "partials/templates/_funcs/get-page-images" not found
ERROR render of "/Users/suyoggarg/Dropbox/suyog7130.github.io/content/archives.md" failed: "/Users/suyoggarg/Dropbox/suyog7130.github.io/themes/hugo-PaperMod/layouts/_default/baseof.html:9:8": execute of template failed: template: archives.html:9:8: executing "archives.html" at <partial "head.html" .>: error calling partial: "/Users/suyoggarg/Dropbox/suyog7130.github.io/themes/hugo-PaperMod/layouts/partials/head.html:88:19": execute of template failed: template: _partials/templates/schema_json.html:88:19: executing "partials/templates/schema_json.html" at <partial "partials/templates/_funcs/get-page-images" .>: error calling partial: partial "partials/templates/_funcs/get-page-images" not found
ERROR render of "/Users/suyoggarg/Dropbox/suyog7130.github.io/content/pages/cv.md" failed: "/Users/suyoggarg/Dropbox/suyog7130.github.io/themes/hugo-PaperMod/layouts/_default/baseof.html:9:8": execute of template failed: template: single.html:9:8: executing "single.html" at <partial "head.html" .>: error calling partial: "/Users/suyoggarg/Dropbox/suyog7130.github.io/themes/hugo-PaperMod/layouts/partials/head.html:88:19": execute of template failed: template: _partials/templates/schema_json.html:88:19: executing "partials/templates/schema_json.html" at <partial "partials/templates/_funcs/get-page-images" .>: error calling partial: partial "partials/templates/_funcs/get-page-images" not found
ERROR render of "/Users/suyoggarg/Dropbox/suyog7130.github.io/content/pages/ideas.md" failed: "/Users/suyoggarg/Dropbox/suyog7130.github.io/themes/hugo-PaperMod/layouts/_default/baseof.html:9:8": execute of template failed: template: single.html:9:8: executing "single.html" at <partial "head.html" .>: error calling partial: "/Users/suyoggarg/Dropbox/suyog7130.github.io/themes/hugo-PaperMod/layouts/partials/head.html:88:19": execute of template failed: template: _partials/templates/schema_json.html:88:19: executing "partials/templates/schema_json.html" at <partial "partials/templates/_funcs/get-page-images" .>: error calling partial: partial "partials/templates/_funcs/get-page-images" not found
Built in 124 ms
Error: error building site: render: failed to render pages: render of "/Users/suyoggarg/Dropbox/suyog7130.github.io/content/archives-ja.md" failed: "/Users/suyoggarg/Dropbox/suyog7130.github.io/themes/hugo-PaperMod/layouts/_default/baseof.html:9:8": execute of template failed: template: archives.html:9:8: executing "archives.html" at <partial "head.html" .>: error calling partial: "/Users/suyoggarg/Dropbox/suyog7130.github.io/themes/hugo-PaperMod/layouts/partials/head.html:88:19": execute of template failed: template: _partials/templates/schema_json.html:88:19: executing "partials/templates/schema_json.html" at <partial "partials/templates/_funcs/get-page-images" .>: error calling partial: partial "partials/templates/_funcs/get-page-images" not found

Indeed looking deeper, the schema_json file contained calls like:

layouts/partials/templates/schema_jason.html

{{- $images := partial "partials/templates/_funcs/get-page-images" . -}}

As the warning suggests, prior to v0.146.0, the path used to be doubly looked up, but this seems to have changed with the newer version. So, removing the extra “partial/” from the path name in all statements where it occurs solves the problem for now. Maybe this would be resolved in some future bug correction soon.

This is correct. We couldn’t keep the old behaviour going forward. I assumed this would be rare case (I have only seen it once in the sites I tested with) so I added a WARNING about it, which I think is pretty clear.

1 Like

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