Download

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 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 }}

What are you waiting for?

Start building your site today.

  1. 1 Download Publii
  2. 2 Write your content
  3. 3 Publish your site
Create website