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.