Partial not found error

I tried to insert a partial into my templates {{- partial "main/menu.html " . }} but the build kept failing with the partial not found error message. Turns out the problem was the space I inserted accidentally between the work html and the closing quote. Is it possible for Hugo to show a better error message? The partial path is correct, and I was confused why it was failing until I looked at the partial’s code again and noticed the space.

" m ain/ men u . h t ml " is a valid file path.

1 Like

It fails in my site. Not sure why. Says partial not found.

 error calling partial: partial "main/menu.html " not found
$ hugo env
hugo v0.113.0-085c1b3d614e23d218ebf9daad909deaa2390c9a+extended windows/amd64 BuildDate=2023-06-05T15:04:51Z VendorInfo=gohugoio
GOOS="windows"
GOARCH="amd64"
GOVERSION="go1.20.1"
github.com/sass/libsass="3.6.5"
github.com/webmproject/libwebp="v1.2.4"
``

My point is, it should fail and say “file not found”, because you are giving it a valid path (operating systems such as macOS and Linux allows file paths with spaces, newlines, etc.).

So, I bet there is no way around this other than to code carefully.

That’s right, if you tell it to get file A, and file A doesn’t exist, it should throw an error.

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