gohugoio / hugo

The world’s fastest framework for building websites.
https://gohugo.io
Apache License 2.0
76.27k stars 7.55k forks source link

Bug with mixed case section/type to mixed case layout folders #12398

Open leahoswald opened 7 months ago

leahoswald commented 7 months ago

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

hugo v0.125.1+extended linux/amd64 BuildDate=unknown

from arch linux

Problem

This issue started occurring with hugo v0.123.0. So it worked before. Nothing else changed in the working tree. For a part of my site, I use a different layout configured under /layouts, but this is ignored starting with 0.123. I've searched for two hours now, but I can't find any problem with my setup. Everything is like described in the docs (https://gohugo.io/templates/views/). And after doing a downgrade to v0.122.0 it is immediately working again.

The folder tree looks similar to this:

/content/artProject/_index.md /content/artProject/oneArtProject.md /content/artProject/anotherArtProject.md

Then there is: /layouts/artProject/list.html

And according to the docs, this should be used, but instead it is always falling back to: /themes/themeName/layouts/_default/lists.html

It sounds a little bit similar to #12146 and #12193, but not the same, and I normally would assume that such a big problem would have been observed by others after the time since the 0.123.0 release.

Oh and if I call hugo with --printUnusedTemplates it also tells me that it is not using the stuff under /layouts

WARN Template artProject/list.html is unused, source file ~/mysite/layouts/artProject/list.html

jmooring commented 7 months ago

It would be helpful if you could share your project with us. I am unable to recreate the problem based on the description above.

leahoswald commented 7 months ago

And now, just to be sure, I changed the folder name from "artProject" to only "art" and it magically works. And I can reproduce it! If the folder name is only lowercase it works, if it contains an upper case it is ignored. Is there any naming scheme I couldn't find in the docs?

EDIT: Updated the original issue to reflect this issue.

jmooring commented 7 months ago

With this content structure:

content/
└── TestDir/
    └── p1.md
Value returned by v0.122.0 Value returned by v0.123.0
{{ .Section }} TestDir testdir
{{ .Type }} TestDir testdir

Which means you can't do this anymore:

layouts/
└── TestDir/
    └── single.html

I'm guessing that both Type and Section are now derived from the logical path (described here) instead of the physical path.

I'm not sure if this is one of the intentional breaking changes in v0.123.0. Regardless, change your layouts structure to:

layouts/
└── testdir/
    └── single.html
leahoswald commented 7 months ago

Sounds plausible that it is caused by the function because copying the folder from layouts to the templates layouts folder doesn't help. So it seems to be a global problem. If it is intended and only lowercase is allowed now we should add some documentation for it.

Oh and it doesn't help to just rename the layout folder to a lowercase version, we need to rename the content structure too.

jmooring commented 7 months ago

it doesn't help to just rename the layout folder to a lowercase version

Yes, it does, try it.

git clone --single-branch -b hugo-github-issue-12398 https://github.com/jmooring/hugo-testing hugo-github-issue-12398
cd hugo-github-issue-12398
hugo server

Then visit http://localhost:1313/testdir/p1/

leahoswald commented 7 months ago

Ah your right, this was a wrong observation either due to caching or changing path names. (It was late yesterday)