Introduction - partials

Partials are reusable fragments of your website's code, placed in separate files to simplify development and maintenance. They are located in the partials directory of your theme.

Loading a Partial

You can load a partial using the following syntax:

{{> head}}

The above code loads the partials/head.hbs file.

Common Partials in Publii Themes

Every Publii theme typically uses several partials, e.g.:

The menu.hbs and pagination.hbs partials are optional. If these files do not exist in your theme, Publii provides default versions.

You can also define your custom partials, which should also be placed in the partials directory.

Support for Partials in Subdirectories

Partials located in subdirectories allow developers to organize their templates better and maintain cleaner project structures.

theme/
|
├── assets/
|
├── partials/
│   ├── header/
│   │   ├── logo.hbs
│   │   ├── navigation.hbs
│   │   └── search.hbs
│   ├── footer/
│   │   ├── copyright.hbs
│   │   ├── links.hbs
│   │   └── social.hbs
│   ├── blog/
│   │   ├── post-meta.hbs
│   │   ├── post-excerpt.hbs
│   │   └── post-tags.hbs
│   └── shared/
│       ├── pagination.hbs
│       └── notifications.hbs
|
└── index.hbs
└── config.json
└── post.hbs
└── page.hbs

In your templates, you can reference partials using their subdirectory paths:

{{> header/logo }}
{{> shared/breadcrumbs }}
{{> footer/social }}

Create your first website with Publii

Join thousands of creators who chose independence. Create content locally and publish lightning-fast, secure websites on your own terms.

Download Publii

Free and open source. Windows, macOS and Linux.

Read the getting started guide