# Front matter

The _front matter_ can contain custom variables applied to the current page.

It must be the first thing in the file and must be valid [YAML](https://en.wikipedia.org/wiki/YAML).

:::info
YAML is the default format: you can use INI, TOML or JSON instead with the [`pages.frontmatter`](../configuration/4-pages.md#pages-frontmatter) option.
:::

:::tip
The front matter is validated: the types of predefined variables are checked, and you can declare your own rules (required variables, types, allowed values, default values, etc.) by section or by page with the [`pages.schema`](../configuration/4-pages.md#pages-schema) option.
:::

## Predefined variables

| Variable    | Description       | Default value                                      | Example       |
| ----------- | ----------------- | -------------------------------------------------- | ------------- |
| `title`     | Title             | File name without extension, prefix and language suffix. | `Post 1`      |
| `layout`    | Template          | See [_Lookup rules_](../templates/1-lookup-rules.md#lookup-rules). | `404`         |
| `date`      | Creation date     | File modification date (PHP _DateTime_ object).    | `2019-04-15`  |
| `section`   | Section           | Page's _Section_.                                  | `blog`        |
| `path`      | Path              | Page's _path_.                                     | `blog/post-1` |
| `slug`      | Slug              | Page's _slug_.                                     | `post-1`      |
| `weight`    | Sort order        | File [weight prefix](1-pages.md#weight), if any.   | `10`          |
| `language`  | Language code     | File language suffix, or the main [language](../configuration/2-languages.md#language). | `fr` |
| `langref`   | Translations reference | Page's _path_ (without language).             | `blog/post-1` |
| `published` | Published or not  | `true`.                                            | `false`       |
| `draft`     | Draft or not      | `false`.                                           | `true`        |

:::info
All the predefined variables can be overridden except `section`.
:::

:::important
The values of `path` and `slug` must already be slugified (e.g.: `my-post`, not `My Post`), otherwise the build fails. They can't contain `.` or `..` segments.
:::

:::tip
`draft: true` is the same as `published: false`. Unpublished pages can be previewed with the `--drafts` option of the [`build`](../commands/4-build.md) and [`serve`](../commands/3-serve.md) commands.
:::

## updated

The `updated` variable is used to define the last modification date of a page.

_Example:_

```yaml
---
updated: 2026-02-02
---
```

:::info
`lastmod` is an alias of `updated`.
:::

:::warning
Before version 8.80.1, the `updated` variable was a predefined variable. It is now an optional variable (and must be defined in the front matter to be used).
:::

## menu

A page can be added to a [menu](../configuration/1-site.md#menus).

The entry name is the page `title` and the URL is the page `path`.

The same page can be added to multiple menus, and each entry's position can be set with the `weight` key (lowest first). The `name` key can be used to override the default entry name per menu.

_Examples:_

```yaml
---
menu: main
---
```

```yaml
---
menu: [main, navigation] # same page in multiple menus
---
```

```yaml
---
menu:
  main:
    weight: 10
  navigation:
    weight: 20
---
```

```yaml
---
title: 'Our Expertise'
menu:
  main:
    weight: 15
  footer:
    weight: 15
    name: "Expertise" # override the entry name in this menu
---
```

## Taxonomy

Taxonomy allows you to connect, relate and classify your website’s content.  
In Cecil, these terms are gathered within vocabularies.

Vocabularies are declared in the [_Configuration_](../configuration/1-site.md#taxonomies).

Vocabulary
: A categorization of content (e.g.: `tags`, `categories`, etc.).

Term
: A term is an item of a vocabulary (e.g.: `Development`, `PHP`, etc.).

_Example:_

```yaml
---
tags: ["Development", "PHP"]
---
```

Cecil then generates, for each vocabulary:

- a page listing its terms, e.g.: `/tags/`
- a page per term listing its pages, e.g.: `/tags/development/` and `/tags/php/`

See [templates lookup rules](../templates/1-lookup-rules.md#type-vocabulary) and [taxonomy variables](../templates/2-variables.md#taxonomy) to customize those pages.

## Schedule

Schedules pages’ publication.

_Example:_

The page is published from 2023-02-07 (if the current date is >= 2023-02-07):

```yaml
---
schedule:
  publish: 2023-02-07
---
```

The page is published until 2022-04-28 (if the current date is < 2022-04-28, i.e. before midnight):

```yaml
---
schedule:
  expiry: 2022-04-28
---
```

Both can be combined: the page is published if the `publish` date is reached **and** the `expiry` date is not passed.

## redirect

As indicated by its name, the `redirect` variable is used to redirect a page to a dedicated URL.

_Example:_

```yaml
---
redirect: "https://arnaudligny.fr"
---
```

:::info
Redirect works with the [`redirect.html.twig`](https://github.com/Cecilapp/Cecil/blob/main/resources/layouts/_default/redirect.html.twig) template.
:::

## alias

An alias is a redirection to the current page.

_Example:_

```yaml
---
title: "About"
alias:
  - contact
---
```

In the previous example `contact/` redirects to `about/`.

:::info
`aliases` is still supported for backward compatibility.
:::

## output

Defines the output format of the page.

Available formats are: `html`, `atom`, `rss`, `json`, `xml`, etc.  
You can define one or more formats in an array.

It’s not required to define an output format, but if you do, it must be one of the available formats defined in the [_Configuration_](../configuration/8-output.md#output-formats).

_Example:_

```yaml
---
output: [html, atom]
---
```

## uglyurl

Set `uglyurl` to `true` to publish the page as a file named after its path (e.g.: `blog/post-1.html`) instead of an `index.html` file in a folder (e.g.: `blog/post-1/index.html`).

_Example:_

```yaml
---
uglyurl: true
---
```

## external

A page with an `external` variable tries to fetch the content of the pointed resource, and uses it as the page body.

_Example:_

```yaml
---
external: "https://raw.githubusercontent.com/Cecilapp/Cecil/main/README.md"
---
```

The resource can be:

- a remote file, with an `http://` or `https://` URL (other schemes, like `file://` or `php://`, are not allowed);
- a local file, with a path relative to the site directory (e.g.: `../README.md`), that must be inside the parent directory of the site.

## excluded

Set `excluded` to `true` to hide a page from list pages (e.g.: _Home page_, _Section_, _Sitemap_, etc.).

_Example:_

```yaml
---
excluded: true
---
```

:::info
`excluded` is different from [`published`](#predefined-variables): an excluded page is published but hidden from list pages.
:::

:::warning
Since version 8.49.0, the previous `exclude` variable has been renamed `excluded` (`exclude` is still supported for backward compatibility).
:::
