Getting started

lesson 4. Include your first partials

A website typically consists of a few elements that get repeated on every page, like a header with a menu and a footer. Instead of adding them to every page, you can use a ‘partial’. Partials need to be saved in the ‘/layouts/partials’ directory.

Create a ‘header.html’ file that looks like this:


Create a ‘footer.html’ file that looks like this:


Store both files in the ‘/layouts/partials’ directory. Now update your ‘/layouts/index.html’ file and make sure it looks like this (replacing the code with links to the partials):

{{ partial "header.html" . }}
    <h1>{{ .Title }}</h1>
    {{ .Content }}
{{ partial "footer.html" . }}

Your project should now looks like this:


Next: 5. Add another content file