Cecil logo Cecil
What's on this page

Extend templates

Templates can be extended with custom functions and filters, or packaged as a reusable theme.

Functions and filters

You can add custom functions and custom filters with a Twig extension.

Theme

It’s easy to build a theme: create a folder <theme> with the following structure (like a website but without pages):

<my-site>
└─ themes
   └─ <theme>
      ├─ config.yml
      ├─ assets
      ├─ layouts
      ├─ schemas
      ├─ static
      └─ translations

Then enable it with the theme configuration option.

The theme config.yml overrides the default configuration and is merged with the site configuration, which takes precedence, except for lists of values: the site values are added to the theme ones, and a theme value can only be removed with false (e.g. homepage: {atom: false}).

The schemas directory of the theme holds the front matter schemas of the variables its templates expect: the schemas of the site override them variable by variable.

Required themes

A theme can require other themes (e.g. a component theme providing a search box, or a plugin) with the theme option of its config.yml:

/themes/<theme>/config.yml

theme:
  - <required-theme>

Required themes are enabled with the theme, with no other configuration of the site: their layouts, assets, static files, translations, extensions and config.yml are loaded. They are added after the themes of the site, so the theme (like the site) overrides the themes it requires.