Using Content Blocks and Partials
Your home page layout and single page layout both contain the HTML skeleton. That skeleton is going to get a lot more complex once you add a header, footer, and navigation. Instead of duplicating that code in multiple places, Hugo provides a single place for you to put your skeleton so that all other layouts can build on it. When you created the theme, it generated it for you.
Locate the file themes/basic/layouts/_default/baseof.html and open it in your editor. You’ll see this code:
| <!DOCTYPE html> |
| <html> |
| {{- partial "head.html" . -}} |
| <body> |
| {{- partial "header.html" . -}} |
| <div id="content"> |
| {{- block "main" . }}{{- end }} |
| </div> |
| {{- partial "footer.html" . -}} |
| </body> |
| </html> |
This file ...
Get Build Websites with Hugo now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.