Hello all,
I’m having trouble getting the theme layout right to match the simple content structure.
From what I’ve read, the layouts/posts/page.html should match up to the blog*.md content and the layouts/page.html should match up with the about-me.md but it isn’t working. It’s ignoring the posts/page.html.
I think i must be missing something about the order of priority or something. I saw that the template system was recently overhauled and wondering if there might be something basic I’m missing in the documentation.
its fairly simple:
I’m unable to reproduce your issue with latest hugo version 0.148.1
seems there is something within different at your site. If you cannot figure that out sharing your repo will be easiest to support you.
try it out here:
git clone --single-branch -b topic-55440-about-me https://github.com/irkode/hugo-forum.git topic-55440-about-me
cd topic-55440-about-me
hugo server
Logfile and structure
hugo v0.148.1-98ba...
WARN Topic 55440 About Me -- mysite\themes\mytheme\layouts\home.html
WARN About Me -- mysite\themes\mytheme\layouts\page.html
WARN Posts -- mysite\themes\mytheme\layouts\section.html
WARN Blog 2 -- mysite\themes\mytheme\layouts\posts\page.html
WARN Blog 1 -- mysite\themes\mytheme\layouts\posts\page.html
WARN Blog 3 -- mysite\themes\mytheme\layouts\posts\page.html
p.s. in general you want to have something more to show on your section pages but the layouts rendered. a content/_index.md and content/posts/_index.md might be valuable.
thank you @irkode the sample code helped out. My content had “type” front matter that was screwing this up. When i removed it, it works as expected.
Specifically the blog*.md files had a frontmatter type: post which made it ignore the layout\posts path and defaulted to the root page.html. It didn’t occur to me the frontmatter type has a higher priority than the path.
I just had to rename the layout/posts path to layout/post to reference the frontmatter instead of the path and it worked.
yes, i never knew type frontmatter would override the section. In fact, he definition of type says that’s pretty much its whole purpose:
content type
A content type is a classification of content inferred from the top-level directory name or the type set in front matter. Pages in the root of the content directory, including the home page, are of type “page”. The content type is a contributing factor in the template lookup order and determines which archetype template to use when creating new content.
This content was imported from a wordpress blog and i guess the conversion tool auto-inserted that and I didn’t understand the implication. I will be removing all type frontmatter so it just follows the path.