<commit_before><!--
description: "Works with templates and use variables."
alias: documentation/layouts
-->

# Templates

Cecil use [Twig](https://twig.symfony.com) as template engine, so refer to the [official documentation](https://twig.symfony.com/doc/templates.html) for basic usage.

## Example

```twig
<h1>{{ page.title }} | {{ site.title }}</h1>
<span>{{ page.date|date('j M Y') }}</span>
<p>{{ page.content }}</p>
<p>{{ page.customvar }}</p>
```

## Files organization

Templates files are stored in `layouts/`.

```plaintext
<mywebsite>
├─ content
├─ layouts
|  ├─ _default           <- Contains default templates
|  |  ├─ list.html.twig  <- Used by "section" and "term" pages type
|  |  └─ page.html.twig  <- Used by "page" pages type
|  └─ index.html.twig    <- Used by the "homepage" type
└─ themes
   └─ <theme>            <- A custom theme
      ├─ layouts
      └─ ...
```

## Lookup rules

Cecil searches for the best layout to use, for a given page, in a defined order.

> In most of cases you don’t need to specify the template in layout variable: Cecil selects the most appropriate template for you.

**Notes:**

> `<format>` is the output format (ie: `html`).  
> `<layout>` is the value of variable `layout` set in front matter (ie: `layout: post`).  
> `<section>` is the page’s *Section* (ie: `blog`).

### _homepage_

1. `<layout>.<format>.twig`
2. **`index.<format>.twig`** (ie: `index.html.twig`)
3. `_default/list.<format>.twig`
4. `_default/page.<format>.twig`

### _page_

1. `<section>/<layout>.<format>.twig`
2. `<layout>.<format>.twig`
3. `<section>/page.<format>.twig`
4. **`page.<format>.twig`** (ie: `page.html.twig`)
5. `_default/page.<format>.twig`

### _section_

1. `section/<section>.<format>.twig`
2. `_default/section.<format>.twig`
3. `_default/list.<format>.twig`

### _vocabulary_

1. `taxonomy/<plural>.<format>.twig`
2. `_default/vocabulary.<format>.twig`

### _term_

1. `taxonomy/<term>.<format>.twig`
2. `_default/term.<format>.twig`
3. `_default/list.<format>.twig`

## Variables<commit_msg>Update 3.Templates.md<commit_after><!--
description: "Works with templates and use variables."
alias: documentation/layouts
-->

# Templates

Cecil use [Twig](https://twig.symfony.com) as template engine, so refer to the [official documentation](https://twig.symfony.com/doc/templates.html) for basic usage.

## Example

```twig
<h1>{{ page.title }} | {{ site.title }}</h1>
<span>{{ page.date|date('j M Y') }}</span>
<p>{{ page.content }}</p>
<p>{{ page.customvar }}</p>
```

## Files organization

Templates files are stored in `layouts/`.

```plaintext
<mywebsite>
├─ content
├─ layouts
|  ├─ _default           <- Contains default templates
|  |  ├─ list.html.twig  <- Used by "section" and "term" pages type
|  |  └─ page.html.twig  <- Used by "page" pages type
|  └─ index.html.twig    <- Used by the "homepage" type
└─ themes
   └─ <theme>            <- A custom theme
      ├─ layouts
      └─ ...
```

## Lookup rules

Cecil searches for the best layout to use, for a given page, in a defined order.

> In most of cases you don’t need to specify the template in layout variable: Cecil selects the most appropriate template for you.

**Notes:**

> `<format>` is the output format (ie: `html`).  
> `<layout>` is the value of variable `layout` set in front matter (ie: `layout: post`).  
> `<section>` is the page’s *Section* (ie: `blog`).

### _homepage_

1. `<layout>.<format>.twig`
2. `index.<format>.twig`
3. `_default/list.<format>.twig`
4. `_default/page.<format>.twig`

### _page_

1. `<section>/<layout>.<format>.twig`
2. `<layout>.<format>.twig`
3. `<section>/page.<format>.twig`
4. `page.<format>.twig`
5. `_default/page.<format>.twig`

### _section_

1. `section/<section>.<format>.twig`
2. `_default/section.<format>.twig`
3. `_default/list.<format>.twig`

### _vocabulary_

1. `taxonomy/<plural>.<format>.twig`
2. `_default/vocabulary.<format>.twig`

### _term_

1. `taxonomy/<term>.<format>.twig`
2. `_default/term.<format>.twig`
3. `_default/list.<format>.twig`

## Variables
{'fraction_non_alphanumeric': 0.19707848477345877, 'fraction_numerical': 0.00965585540975489, 'mean_word_length': 3.730679156908665, 'pattern_counts': {'":': 0, '<': 91, '<?xml version=': 0, '>': 89, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4696477', 'n_tokens_mistral': 1518, 'n_tokens_neox': 1484, 'n_words': 412}