Content uses incorrect layout

I have an issue where a page does not successfully pull its corresponding layout. In my simple example I’m just trying to create a custom layout for a Contact Us page.
I have the following in the file content/contact/_index.md:

---
title: "Contact"
date: 2022-07-26T23:39:42-04:00
menu: main
---

Contact Us!
![smiley face](/smiley.png)

as well as a file layouts/contact/single.html that I’d like to use to build the page. However, it uses themes/mytheme/layouts/_default/single.html instead. I can’t seem to get around this; I’ve tried explicitly setting the type param to “contact” and it does the same thing.

Everywhere seems to point to this being the correct way to set things up for a custom layout. Is there something I’m missing here?

_index.md uses the list.html layout. index.md would use the single.html layout. Rename your layout to list.html for a start.

Ah I see, thanks. I must have overlooked the underscore detail. Creating a list.html file did fix it. Only problem is that I didn’t intend for it to be a list page, and if I instead change _index.md to index.md to make contact a single page, it doesn’t pick up single.html.

The problem is the “depth” of your page. /section/page/index.md would use layouts/section/single.html. Keep it with the list.html file if you are lower (like /section/index.md). I wouldn’t think about it being a list page too much as long as you don’t have any more content in that section. There is also a section.html layout, just to add to the confusion :wink:

Ah ok, I believe my misunderstanding is in how layouts were applied. The list in this case is just a “root” node for the about section with no singles under it, so it would be technically correct to keep it a list type.

Thank you for your help! I should add also that making the page a single (_index.mdindex.md) and explicitly specifying the type parameter in the front matter (type: "contact") also applied the single.html layout to the page.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.