Estimated reading time: 1 minute
Partials are chunks of code that you will use multiple times throughout your site. The header
or nav
or even footer
are the most common ones.
Rather than having to code these in every page you simply code them once. This also helps a lot if you need to change them after you have them in many pages.
It makes sense to create a partial every time you think you may need to use this code in more than one place. You can also create a partial if you want to isolate out a function or chunk of code that you may only use in one page. Seperation of code (some what like object orientation) can make it easier to identify code at a later date.
To create a partial:
partials
{{ partial "header.html" . }}
Part 5 of 15 in the hugo zero to hero series.