I’m fairly new to Hugo and I’m having a bit of a hard time understanding how layouts are selected — I’ve read the docs and searched the forum but something still doesn’t add up in my case.
The situation:
I have a simple page at:
content/contact.md
And I want it to use a custom layout. So I created:
layouts/contact/single.html
Then in the front matter, I’ve tried several combinations like:
type: "contact"
layout: "single"
or even just:
layout: "contact"
But Hugo always ends up using layouts/_default/single.html. No matter what I do, my custom layout never gets picked up.
Just to update: I’ve tried all the recommended solutions, including :
– Creating a layouts/contact.html and using layout: "contact" in the front matter
– Creating a “fake section” with content/contact/_index.md and using layouts/contact/single.html
– Cleaning the cache and restarting Hugo
Unfortunately, nothing works for my orphan page (/contact/), even with a fresh structure and no drafts. Oddly, the exact same approach does work for my “legal pages” section (/pages-legales/), which just adds to the confusion.
At this stage, it really looks like Hugo is broken for orphan pages and custom layouts in v0.148+.
I will try downgrading to 0.147.9 to recover a stable and predictable behavior.
Thanks again for your help—hopefully this will get fixed in a future release.
reading back, you mentioned layouts/_default so maybe you have not everything migrated to the new layout structure.
dunno if that may affect something here, but the bare setup using frontmatter layout works for a workaround/override
try it out here
git clone --single-branch -b topic-55405-contactpage https://github.com/irkode/hugo-forum.git topic-55405-contactpage
cd topic-55405-contactpage
hugo server