Skip to content

templates.Exists fails for mixed-case partial filenames #13684

@deltaclock

Description

@deltaclock

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

$ hugo version
hugo v0.147.0+extended+withdeploy linux/amd64 BuildDate=unknown

Does this issue reproduce with the latest release?

Yes

Details

templates.Exists returns false for partials with uppercase letters in their filename.
From my analysis, the bug originates from:

https://github.com/gohugoio/hugo/blob/b39b24962350090122b5f3927456dde710cffb57/common/paths/pathparser.go#L49C1-L58

It seems that when the template store is created, the filepaths added are normalized, while the argument could be a path containing uppercase letters.
I'm not sure (haven't found any docs) stating the expected format of the partial's filenames, but this issue started appearing from version 0.146.0.

See also a popular theme using mixed-case partial filenames: nunocoracao/blowfish#2102 (comment)

Screenshots

Building the template store: notice the normalized path in s and the original one in unnormalized

Image

Insertion into templatesByPath map of normalized path

Image

templates.Exists failure due to comparison of normalized and unnormalized paths

Image

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions