I have a following structure in my Hugo & Doks project:
- content
- docs
- working.md
- working-as-well.md
- get-started2
- working.md
...
- get-started.md
...
- layouts
- get-started2
- single.html
- get-started.html
Content placed in docs and get-started2 has customized layout and works as expected. Great!
However, I have huge pain to set-up custom layout for get-started.md. I cannot do it like with get-started2 - place it into a folder. Client requests to have get started URL as:
www.SomeProject.com/get-started
so it must not be placed in folder (like get-started2)
www.SomeProject.com/get-started2/working
Do you have any hints please?
You have at least three options:
Use front matter to set the "type":
In content/get-started.md set type: mytype in front matter.
The layout will be located at (for example) layout/mytype/single.html.
Use front matter to set the "layout":
In content/get-started.md set layout: mylayout in front matter.
The layout will be located at (for example) layout/_default/mylayout.html
Or use a subdirectory, but make it the section index:
The file is located at content/get-started/_index.md
The layout will be located at (for example) layout/get-started/list.html
Notice that the template name has changed from "single" to "list", but you can still write your layout in exactly the same way.
I use "(for example)" because Hugo has an enormous list of directories/filenames it searches through to find its templates, and if an earlier matching template is found, the custom layout gets ignored.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With