What's on this page
Organization and lookup rules
Files organization
Kinds of templates
There are three kinds of templates: layouts, components, and other templates. Layouts are used to render pages, and each layout can include templates and components.
Naming convention
Template files are stored in the layouts/ directory and must be named according to the following convention:
layouts/(<section>/)<type>|<layout>.<format>(.<language>).twig <section>(optional)- The section of the page (e.g.:
blog). <type>- The page type:
home(orindex) for homepage,listfor list,pagefor page, etc. (See Lookup rules for details). <layout>(optional)- The custom layout name defined in the front matter of the page (e.g.:
layout: my-layout). <format>- The output format of the rendered page (e.g.:
html,rss,json,xml, etc.). <language>(optional)- The language of the page (e.g.:
fr).
Examples:
layouts/home.html.twig # `type` is "homepage"
layouts/page.html.twig # `type` is "page"
layouts/page.html.fr.twig # `type` is "page" and `language` is "fr"
layouts/my-layout.html.twig # `layout` is "my-layout"
layouts/blog/list.html.twig # `section` is "blog"
layouts/blog/list.rss.twig # `section` is "blog" and `format` is "rss" <my-site>
├─ ...
├─ layouts
| ├─ index.html.twig # Used by type "homepage"
| ├─ list.html.twig # Used by types "homepage" and "section"
| ├─ list.rss.twig # Used by types "homepage" and "section", for RSS output format
| ├─ page.html.twig # Used by type "page"
| ├─ taxonomy
| | ├─ tags.html.twig # Used by type "vocabulary" of `tags` (list of terms)
| | └─ tag.html.twig # Used by type "term" of `tags` (list of pages)
| ├─ my-layout.html.twig # Used by pages with `layout: my-layout` in the front matter
| ├─ ...
| └─ partials # Included templates
| ├─ footer.html.twig
| └─ ...
└─ themes # Themes layouts and templates
└─ ... Built-in templates
Cecil comes with a set of built-in templates.
Lookup rules
In most of cases you don’t need to specify the layout: Cecil selects the most appropriate layout, according to the page type.
For example, the HTML output of home page (index.md) will be rendered:
- with
my-layout.html.twigif thelayoutvariable is set to "my-layout" (in the front matter) - if not, with
index.html.twigif the file exists - if not, with
home.html.twigif the file exists - if not, with
list.html.twigif the file exists
All rules are detailed below, for each page type, in the priority order.
Type homepage
<layout>.<format>.twigindex.<format>.twighome.<format>.twiglist.<format>.twig_default/<layout>.<format>.twig_default/index.<format>.twig_default/home.<format>.twig_default/list.<format>.twig_default/page.<format>.twig
Type page
<section>/<layout>.<format>.twig<layout>.<format>.twig<section>/page.<format>.twig_default/<layout>.<format>.twigpage.<format>.twig_default/page.<format>.twig
Type section
<layout>.<format>.twig<section>/index.<format>.twig<section>/list.<format>.twigsection/<section>.<format>.twig<parent>/index.<format>.twig,<parent>/list.<format>.twigandsection/<parent>.<format>.twig, for each parent section of a sub-section (nearest first)_default/section.<format>.twiglist.<format>.twig_default/list.<format>.twig
Type vocabulary
taxonomy/<plural>.<format>.twigvocabulary.<format>.twig_default/vocabulary.<format>.twig
Type term
taxonomy/<plural>/<term>.<format>.twigtaxonomy/<singular>.<format>.twigterm.<format>.twig_default/term.<format>.twig_default/list.<format>.twig