I’m going nuts trying to get this to work, from my homepage I have a link called “Features” which links to “/features/”, now I want to have a special template running for just that “subpage” but the closest I can get is having that page displayed the same as my “Blog” page, which uses single.html and list.html from the _default folder, does anyone have a solution for me, can’t really find what I need in the docs.
Thanks, I’ve got it working now, although I think there’s a strange behavior, in my content/features/ folder I have a file called _index.md which basically only stores a title for that specific “subpage”, but for my layout stored in layouts/features to work properly it needs to be called list.html which is strange as there aren’t any more files in my content folder and as such I would think that the layout file should be called single.html instead, am I missing something here?
In case you want to use code rather than emphasis for file names:
As for yer deal, I’d come at it from a different angle. You are trying to fit your special page into the site, but instead figure out what kind of page it is, and then modify the correct template.
For instance, is features a directory or a single page? _index.html is for adding content to the various list views (sections, taxonomies, those kinds of things). It sounds like you want a single page that renders differently than the other single pages on your site.
If I were doing this, I’d probably put special one-off pages in their own section, and using front matter I’d set everything.
Then I’d create a template based on the single page lookup order, which given my example would be at /layouts/pages/special.html.
That should do it for ya!
If this seems more difficult than it needs to be, it is because we have an open convention (lookup order) to allow for maximum flexibility. You can accomplish your goal differently, and it is just as valid. But really focus on understanding the lookup order and you’ll figure out what works for your site.
However! You can also change all the permalinks for the section by adding the following to your config.html:
Then all the content you put in the pages section will take their slug or title and generate the URL off the baseURL. If I add an about page at /content/pages/about.md that looks like:
It will create the page at example.org/about. I use :slug in the permalink so I can override. For instance, the following also generates the same about URL as the previous example:
title: "About all the awesome things I put online"
Note: your site will look for permalinks in the config, and then override on a per content basis. So you can combine the two methods I’ve added here, but if you do without fully understanding it you will run into trouble. So for now, pick one or the other.
Finally, the reason to put pages in a section like that is if you have a lot of pages that hang off the root domain, you can keep them in their own directory, rather than in your content directory. It is tidier.