I have a contact page (contact.md) and an about page (about.md). I want them to have the same header and footer but not the same “main” element because this element will have different structure and styles.
Instead of creating a separate layout for each, how would I go about having a shared layout and “insert” the contents in the middle?
Hi,
Have a read about base templates here: https://gohugo.io/templates/base/
How do I tie it all together?
I have layouts/page/baseof.html
content/about.md
content/contact.md
Frontmatter contains type: page.
I defined blocks in layout/partials/about.html and layout/partials/contact.html
I want baseof.html to get the blocks from these files somehow. How to achieve this?
My two cent is create baseof.html
in layouts/_default
then add the the layout for custom type inside layouts/page/
contact.html #layout for contact page
about.html #layout for about page
define all the block then use different main section for each layout.
the last step add type
and layout
in front matter of each page content.
type: page
layout: your_layout
This is what I ended up doing