Hugo not recognize single post template for the section

This forum and other websites have many tips what to do sections have own page templates. None work for me.

I have posts in /content/posts/ and other pages in /content/pages/.

config file:

params:
  mainSections:
  - posts
  - pages

permalinks:
  pages: /:slug
  posts: /:slug

theme/layouts/_default/list.html and single.html and baseof.html
theme/layouts/pages/single.html
theme/layouts/index.html

Frontmatter of the page in /content/pages/pagename.md have:
type: page

Now, the Page from Pages grab posts template.

I think maybe you are confusing “kind” page and a section named pages that will have type pages?
So type page I think will miss layouts/pages/ and looks for single.html in _default/ or layouts/page/ ?

The section determines the type, so remove the type from the frontmatter of the markdown files.

I have strange Hugo behaviour.
I changed “pages” section into “staticpages” section and settings.
While Hugo server is running, I removed “type” from frontmatter in staticpages/pagename.md and Hugo used proper template.
However, after restart Hugo server, the problem came back, so Hugo take template from the “posts” section.

To remain current folder structure is:
theme/layouts/_default/list.html and single.html and baseof.html
theme/layouts/staticpages/single.html
theme/layouts/index.html

config file:

params:
  mainSections:
  - posts
  - staticpages

Share your repo

Solved. the Page was duplicated under posts section. Damn :wink: