Partials
Partials are reusable chunks of content that can be included in any layout or page. They can be authored with a combination of markdown, HTML, and/or Handlebars expressions. Partials cannot have their own front matter, but they do have access to config data and page data. You can also pass data to them as hash arguments.
Creating Partials
Partials are defined declaratively. To add a partial, create a file in your partials folder. Your partials folder is called “partials” unless otherwise specified in your config.
Partial names map to their file location, minus the underscore and file extension. For example, a file named
partials/my-partial.md
will result in a partial called my-partial
that can be
included like this:
{{> my-partial}}
Similarly, a partial located at folder/my-partial.md
will be available as
folder/my-partial
:
{{> folder/my-partial}}
Passing Data to Partials
When including a partial, you can pass data in the form of hash arguments. Hash arguments look similar to HTML attributes.
{{>avatar name="Doxicity" image="https://example.com/image.jpg"}}
Aside from the usual config data and page data, this will also expose name
and
image
to the partial.
To learn more about how partials work, refer to the Handlebars documentation.