Skip to content

Template execution fails if no suffix is given #13601

@cmahnke

Description

@cmahnke

What version of Hugo are you using (hugo version)?

$ hugo version
hugo v0.146.3+extended+withdeploy darwin/arm64 BuildDate=2025-04-12T17:21:50Z VendorInfo=brew

Does this issue reproduce with the latest release?

Yes

Description

Up until 0.145 it was possible to call a partial without an file extension from another. My use case were partials
that act as output format agnostic templates function, those might return just strings.
To make it obvious that those aren't really bound to formats, I just used them without any file extension, see default-lang in the example. This wont work anymore with the new templating (at least on existing sites).

In short: Executing a template (in this case for output format HTML) that doesn't have the file suffix .html fails now.

Message

Error: error building site: render: failed to render pages: render of "/Users/cmahnke/Blogs/hugo-0.146.3/content/post/post-1.md" failed: "/Users/cmahnke/Blogs/hugo-0.146.3/layouts/_default/single.html:4:32": execute of template failed: template: single.html:4:32: executing "main" at <partialCached "functions/i18n/default-lang" .>: error calling partialCached: template: :1:29: executing "_partials/functions/i18n/default-lang" at <.Arg>: can't evaluate field Arg in type *hugolib.pageState

Example

https://github.com/cmahnke/hugo-13601

Updates

  • It seems to be not an issue of template resolution, since there issn't a message that the template wasn't found.
  • Since it used to work with 0.145.0 it's related to backwards compatibility similar to Calls to the template function are not backwards compatible in some cases #13599.
  • Renaming the template to have a suffix (.html) makes it work, even if I don't change the caller. My expectation would have been that this should fail, since the template file don't actually exist under the given file name.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions