Layouts
Use layouts to wrap your pages in shared header/footer structures.
Layouts
You can define shared layouts using standard Go templates. These are commonly stored in a layouts/
folder. Layouts use the {{ template }}
and {{ define }}
blocks to include nested content.
<!-- layouts/base.html -->
<html>
<head><title>{{ .Title }}</title></head>
<body>
{{ template "content" . }}
</body>
</html>
<!-- routes/about/index.html -->
{{ define "content" }}
<h1>About Barry</h1>
<p>This page is wrapped by a layout.</p>
{{ end }}
This ensures you don’t repeat HTML wrappers on every page.