<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="https://cecil.app/fr/xsl/atom.xsl" media="all"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="fr">
  <id>https://cecil.app/fr/documentation/templates/</id>
  <title>Cecil - Templates</title>
  <subtitle><![CDATA[Cecil est une application PHP en ligne de commande qui fusionne des pages Markdown, des médias et des templates Twig afin de générer un site Web statique.]]></subtitle>
  <link href="https://cecil.app/fr/documentation/templates/atom.xml" rel="self" type="application/atom+xml" />
  <link href="https://cecil.app/fr/documentation/templates/" rel="alternate" type="text/html" />
  <updated>2026-10-07T22:51:43+00:00</updated>
  <author>
    <name>Cecil</name>
    <uri>https://cecil.app</uri>
  </author>
  <entry xml:lang="fr">
    <id>https://cecil.app/fr/documentation/templates/regles-de-recherche/</id>
    <title>Organisation et règles de recherche</title>
    <published>2026-05-26T00:00:00+00:00</published>
    <updated>2026-10-05T00:00:00+00:00</updated>
    <link href="https://cecil.app/fr/documentation/templates/regles-de-recherche/" rel="alternate" type="text/html" />
    <content type="html">
      <![CDATA[<h1>Organisation et règles de recherche</h1>
<h2 id="organisation-des-fichiers">Organisation des fichiers</h2>
<h3 id="types-de-templates">Types de templates</h3>
<p>Il existe trois types de templates, <strong><em>layouts</em></strong>, <strong><em>components</em></strong> et <strong><em>autres templates</em></strong> : <em>layouts</em> sont utilisés pour afficher les <a href="/fr/documentation/contenu/pages/">pages</a>, et chacun d'eux peut <a href="https://twig.symfony.com/doc/templates.html#including-other-templates" target="_blank" rel="noopener noreferrer">inclure des templates</a> et <a href="/fr/documentation/templates/composants/">components</a>.</p>
<h3 id="convention-de-nommage">Convention de nommage</h3>
<p>Les fichiers templates sont stockés dans le répertoire <code translate="no">layouts/</code> et doivent être nommés selon la convention suivante :</p>
<pre><code class="language-plaintext hljs plaintext" translate="no">layouts/(&lt;section&gt;/)&lt;type&gt;|&lt;layout&gt;.&lt;format&gt;(.&lt;language&gt;).twig</code></pre>
<dl>
<dt><code translate="no">&lt;section&gt;</code> (<em>facultatif</em>)</dt>
<dd>La section de la page (ex. : <code translate="no">blog</code>).</dd>
<dt><code translate="no">&lt;type&gt;</code></dt>
<dd>Le type de page : <code translate="no">home</code> (ou <code translate="no">index</code>) pour <em>homepage</em>, <code translate="no">list</code> pour <em>list</em>, <code translate="no">page</code> pour <em>page</em>, etc. (Voir <a href="#regles-de-recherche"><em>Règles de recherche</em></a> pour plus de détails).</dd>
<dt><code translate="no">&lt;layout&gt;</code> (<em>facultatif</em>)</dt>
<dd>Le nom de la layout personnalisée défini dans le <a href="/fr/documentation/contenu/pages/#front-matter">front-matter</a> de la page (par exemple : <code translate="no">layout: my-layout</code>).</dd>
<dt><code translate="no">&lt;format&gt;</code></dt>
<dd>Le <a href="/fr/documentation/configuration/sortie/#output-formats">format de sortie</a> de la page rendue (par exemple : <code translate="no">html</code>, <code translate="no">rss</code>, <code translate="no">json</code>, <code translate="no">xml</code>, etc.).</dd>
<dt><code translate="no">&lt;language&gt;</code> (<em>facultatif</em>)</dt>
<dd>La langue de la page (ex. : <code translate="no">fr</code>).</dd>
</dl>
<p><em>Exemples :</em></p>
<pre><code class="language-plaintext hljs plaintext" translate="no">layouts/home.html.twig       # `type` est "homepage"
layouts/page.html.twig       # `type` est "page"
layouts/page.html.fr.twig    # `type` est "page" et `language` est "fr"
layouts/my-layout.html.twig  # `layout` est "my-layout"
layouts/blog/list.html.twig  # `section` est "blog"
layouts/blog/list.rss.twig   # `section` est "blog" et `format` est "rss"</code></pre>
<pre><code class="language-plaintext hljs plaintext" translate="no">&lt;mon-site&gt;
├─ ...
├─ layouts
|  ├─ index.html.twig      # Utilisé par le type "homepage"
|  ├─ list.html.twig       # Utilisé par les types "homepage" et "section"
|  ├─ list.rss.twig        # Utilisé par les types "homepage" et "section", pour le format de sortie RSS
|  ├─ page.html.twig       # Utilisé par le type "page"
|  ├─ taxonomy
|  |  ├─ tags.html.twig    # Utilisé par le type "vocabulary" de `tags` (liste des termes)
|  |  └─ tag.html.twig     # Utilisé par le type "term" de `tags` (liste des pages)
|  ├─ my-layout.html.twig  # Utilisé par les pages avec `layout: my-layout` dans le front-matter
|  ├─ ...
|  └─ partials
|     ├─ footer.html.twig  # Template inclus
|     └─ ...
└─ themes                  # Layouts et templates des thèmes
   └─ ...</code></pre>
<h3 id="templates-integres">Templates intégrés</h3>
<p>Cecil est livré avec un ensemble de <a href="https://github.com/Cecilapp/Cecil/tree/main/resources/layouts" target="_blank" rel="noopener noreferrer">templates intégrés</a>.</p>
<aside class="note note-tip"><p>Si vous avez besoin de modifier des templates intégrés, vous pouvez facilement les extraire via la commande suivante : ils seront copiés dans le répertoire <code translate="no">layouts</code> de votre site.</p>
<pre><code class="language-bash hljs bash" translate="no">php cecil.phar util:templates:extract</code></pre></aside>
<h2 id="regles-de-recherche">Règles de recherche</h2>
<p>Dans la plupart des cas <strong>vous n'avez pas besoin de préciser la layout</strong> : Cecil sélectionne la layout la plus appropriée, en fonction du <strong>type de la page</strong>.</p>
<p>Par exemple, la sortie HTML de <strong>home page</strong> (<code translate="no">index.md</code>) sera rendue :</p>
<ol>
<li>avec <code translate="no">my-layout.html.twig</code> si la variable <code translate="no">layout</code> est définie sur "my-layout" (dans le préambule)</li>
<li>sinon, avec <code translate="no">index.html.twig</code> si le fichier existe</li>
<li>sinon, avec <code translate="no">home.html.twig</code> si le fichier existe</li>
<li>sinon, avec <code translate="no">list.html.twig</code> si le fichier existe</li>
</ol>
<p>Toutes les règles sont détaillées ci-dessous, pour chaque type de page, par ordre de priorité.</p>
<h3 id="type-homepage">Type <em>homepage</em></h3>
<ol>
<li><code translate="no">&lt;layout&gt;.&lt;format&gt;.twig</code></li>
<li><code translate="no">index.&lt;format&gt;.twig</code></li>
<li><code translate="no">home.&lt;format&gt;.twig</code></li>
<li><code translate="no">list.&lt;format&gt;.twig</code></li>
<li><code translate="no">_default/&lt;layout&gt;.&lt;format&gt;.twig</code></li>
<li><code translate="no">_default/index.&lt;format&gt;.twig</code></li>
<li><code translate="no">_default/home.&lt;format&gt;.twig</code></li>
<li><code translate="no">_default/list.&lt;format&gt;.twig</code></li>
<li><code translate="no">_default/page.&lt;format&gt;.twig</code></li>
</ol>
<h3 id="type-page">Type <em>page</em></h3>
<ol>
<li><code translate="no">&lt;section&gt;/&lt;layout&gt;.&lt;format&gt;.twig</code></li>
<li><code translate="no">&lt;layout&gt;.&lt;format&gt;.twig</code></li>
<li><code translate="no">&lt;section&gt;/page.&lt;format&gt;.twig</code></li>
<li><code translate="no">_default/&lt;layout&gt;.&lt;format&gt;.twig</code></li>
<li><code translate="no">page.&lt;format&gt;.twig</code></li>
<li><code translate="no">_default/page.&lt;format&gt;.twig</code></li>
</ol>
<h3 id="type-section">Type <em>section</em></h3>
<ol>
<li><code translate="no">&lt;layout&gt;.&lt;format&gt;.twig</code></li>
<li><code translate="no">&lt;section&gt;/index.&lt;format&gt;.twig</code></li>
<li><code translate="no">&lt;section&gt;/list.&lt;format&gt;.twig</code></li>
<li><code translate="no">section/&lt;section&gt;.&lt;format&gt;.twig</code></li>
<li><code translate="no">&lt;parent&gt;/index.&lt;format&gt;.twig</code>, <code translate="no">&lt;parent&gt;/list.&lt;format&gt;.twig</code> et <code translate="no">section/&lt;parent&gt;.&lt;format&gt;.twig</code>, pour chaque section parente d’une sous-section (la plus proche en premier)</li>
<li><code translate="no">_default/section.&lt;format&gt;.twig</code></li>
<li><code translate="no">list.&lt;format&gt;.twig</code></li>
<li><code translate="no">_default/list.&lt;format&gt;.twig</code></li>
</ol>
<aside class="note note-tip"><p>La <code translate="no">&lt;section&gt;</code> d’une <a href="/fr/documentation/contenu/pages/#sous-section">sous-section</a> est son chemin complet (ex. : <code translate="no">blog/2024</code>), et une sous-section se replie sur les templates de ses sections parentes : si <code translate="no">blog/2024/list.html.twig</code> n’existe pas, la sous-section <code translate="no">blog/2024</code> est rendue avec <code translate="no">blog/list.html.twig</code>.</p></aside>
<h3 id="type-vocabulary">Type <em>vocabulary</em></h3>
<ol>
<li><code translate="no">taxonomy/&lt;plural&gt;.&lt;format&gt;.twig</code></li>
<li><code translate="no">vocabulary.&lt;format&gt;.twig</code></li>
<li><code translate="no">_default/vocabulary.&lt;format&gt;.twig</code></li>
</ol>
<h3 id="type-term">Type <em>term</em></h3>
<ol>
<li><code translate="no">taxonomy/&lt;plural&gt;/&lt;term&gt;.&lt;format&gt;.twig</code></li>
<li><code translate="no">taxonomy/&lt;singular&gt;.&lt;format&gt;.twig</code></li>
<li><code translate="no">term.&lt;format&gt;.twig</code></li>
<li><code translate="no">_default/term.&lt;format&gt;.twig</code></li>
<li><code translate="no">_default/list.&lt;format&gt;.twig</code></li>
</ol>
<aside class="note note-important"><p>Le template du <strong>vocabulaire</strong> est nommé d’après le <strong>pluriel</strong> (ex. : <code translate="no">taxonomy/categories.html.twig</code> pour <code translate="no">/categories/</code>), tandis que le template d’un <strong>terme</strong> est nommé d’après le <strong>singulier</strong> (ex. : <code translate="no">taxonomy/category.html.twig</code> pour <code translate="no">/categories/data-sovereignty/</code>).</p></aside>
<aside class="note note-tip"><p><code translate="no">&lt;term&gt;</code> est le nom du terme « slugifié » : un template dédié au terme « Data Sovereignty » du vocabulaire <code translate="no">categories</code> est <code translate="no">taxonomy/categories/data-sovereignty.html.twig</code>.</p></aside>
<aside class="note note-info"><p>La plupart de ces layouts sont disponibles par défaut, voir <a href="#templates-integres">templates intégrés</a>.</p></aside>]]>
    </content>
  </entry>
  <entry xml:lang="fr">
    <id>https://cecil.app/fr/documentation/templates/reference/fonctions/</id>
    <title>Fonctions</title>
    <published>2026-05-26T00:00:00+00:00</published>
    <updated>2026-10-05T00:00:00+00:00</updated>
    <link href="https://cecil.app/fr/documentation/templates/reference/fonctions/" rel="alternate" type="text/html" />
    <content type="html">
      <![CDATA[<h1>Fonctions</h1>
<blockquote>
<p><a href="https://twig.symfony.com/doc/functions/index.html" target="_blank" rel="noopener noreferrer">Fonctions</a> peut être appelée pour générer du contenu. Les fonctions sont appelées par leur nom suivi de parenthèses (<code translate="no">()</code>) et peuvent avoir des arguments.</p>
</blockquote>
<h2 id="url">url</h2>
<p>Crée une URL valide pour une page, une entrée de menu, un actif, un ID de page ou un chemin.</p>
<pre><code class="language-twig hljs twig" translate="no"><span class="hljs-template-variable">{{ url(value, {options}) }}</span></code></pre>
<table>
<thead>
<tr>
<th>Options</th>
<th>Descriptif</th>
<th>Tapez</th>
<th>Par défaut</th>
</tr>
</thead>
<tbody>
<tr>
<td>canonique</td>
<td>Préfixez l'URL avec <a href="/fr/configuration/site/#baseurl"><code translate="no">baseurl</code></a> ou utilisez <a href="/fr/configuration/site/#options-metatags"><code translate="no">canonical.url</code></a> s'il existe.</td>
<td>booléen</td>
<td><code translate="no">false</code></td>
</tr>
<tr>
<td>formats</td>
<td>Définit la page <a href="/fr/configuration/output/#output-formats">format de sortie</a> (par exemple : <code translate="no">json</code>).</td>
<td>chaîne</td>
<td><code translate="no">html</code></td>
</tr>
<tr>
<td>langue</td>
<td>Définit la page <a href="/fr/configuration/languages/#language">langue</a> (ex. : <code translate="no">fr</code>).</td>
<td>chaîne</td>
<td>nul</td>
</tr>
</tbody>
</table>
<p><em>Exemples :</em></p>
<pre><code class="language-twig hljs twig" translate="no"><span class="hljs-comment">{# page #}</span><span class="xml">
</span><span class="hljs-template-variable">{{ url(page) }}</span><span class="xml">
</span><span class="hljs-template-variable">{{ url(page, {canonical: true}) }}</span><span class="xml">
</span><span class="hljs-template-variable">{{ url(page, {format: json}) }}</span><span class="xml">
</span><span class="hljs-template-variable">{{ url(page, {language: fr}) }}</span><span class="xml">
</span><span class="hljs-comment">{# menu entry #}</span><span class="xml">
</span><span class="hljs-template-variable">{{ url(site.menus.main.about) }}</span><span class="xml">
</span><span class="hljs-comment">{# asset #}</span><span class="xml">
</span><span class="hljs-template-variable">{{ url(asset('styles.css')) }}</span><span class="xml">
</span><span class="hljs-comment">{# page ID #}</span><span class="xml">
</span><span class="hljs-template-variable">{{ url('page-id') }}</span><span class="xml">
</span><span class="hljs-comment">{# path #}</span><span class="xml">
</span><span class="hljs-template-variable">{{ url('about-me/') }}</span><span class="xml">
</span><span class="hljs-template-variable">{{ url('tags/' ~ tag) }}</span></code></pre>
<aside class="note note-info"><p>Pour plus de commodité, la fonction <code translate="no">url</code> est également disponible sous forme de filtre :</p>
<pre><code class="language-twig hljs twig" translate="no"><span class="hljs-comment">{# page #}</span><span class="xml">
</span><span class="hljs-template-variable">{{ page|url }}</span><span class="xml">
</span><span class="hljs-template-variable">{{ page|url({canonical: true, format: json, language: fr}) }}</span><span class="xml">
</span><span class="hljs-comment">{# asset #}</span><span class="xml">
</span><span class="hljs-template-variable">{{ asset('styles.css')|url }}</span></code></pre></aside>
<aside class="note note-tip"><p>Lorsque la valeur est une chaîne, <code translate="no">url()</code> la « slugifie » pour trouver un ID de page correspondant (ex. : <code translate="no">url('tags/My Tag')</code> retourne l’URL de la page <code translate="no">tags/my-tag</code>). Si aucune page ne correspond, la chaîne est conservée comme chemin, avec les caractères invalides (ex. : espaces) encodés.</p></aside>
<h2 id="html">html</h2>
<p>Crée un élément HTML à partir d'un actif (ou d'un tableau d'actifs avec des attributs personnalisés).</p>
<pre><code class="language-twig hljs twig" translate="no"><span class="hljs-template-variable">{{ html(asset, {attributes}, {options}) }}</span><span class="xml">
</span><span class="hljs-comment">{# dedicated functions for each common type of asset #}</span><span class="xml">
</span><span class="hljs-template-variable">{{ css(asset) }}</span><span class="xml">
</span><span class="hljs-template-variable">{{ js(asset) }}</span><span class="xml">
</span><span class="hljs-template-variable">{{ image(asset) }}</span><span class="xml">
</span><span class="hljs-template-variable">{{ audio(asset) }}</span><span class="xml">
</span><span class="hljs-template-variable">{{ video(asset) }}</span></code></pre>
<table>
<thead>
<tr>
<th>Options</th>
<th>Descriptif</th>
<th>Tapez</th>
</tr>
</thead>
<tbody>
<tr>
<td>attributs</td>
<td>Ajoute le couple <code translate="no">name="value"</code> à l'élément HTML.</td>
<td>tableau</td>
</tr>
<tr>
<td>options</td>
<td><code translate="no">{preload: boolean}</code> : préchargements.<br>Pour les images :<br><code translate="no">{formats: array}</code> : ajoute des formats alternatifs.<br><code translate="no">{responsive: bool|string}</code> : ajoute des images réactives (basées sur <code translate="no">width</code> ou des pixels <code translate="no">density</code>).<br><code translate="no">{placeholder: string}</code> : remplit l'arrière-plan de l'image avant son chargement (<code translate="no">color</code> ou <code translate="no">lqip</code>).</td>
<td>tableau</td>
</tr>
</tbody>
</table>
<aside class="note note-warning"><p>Depuis la version <ins>8.42.0</ins>, la fonction <code translate="no">html</code> remplace le filtre <code translate="no">html</code> obsolète.</p></aside>
<aside class="note note-tip"><p>Vous pouvez définir un comportement global par défaut des options d'images (<code translate="no">formats</code>, <code translate="no">responsive</code> et <code translate="no">placeholder</code>) via la <a href="/fr/configuration/layouts/#layouts-images">configuration des layouts</a>.</p>
<p>Lorsque <a href="/fr/configuration/layouts/#layouts-images"><code translate="no">layouts.images.dark_suffix</code></a> est configuré (par exemple <code translate="no">.dark</code>), Cecil recherche automatiquement une variante sombre de chaque image (par exemple <code translate="no">photo.dark.jpg</code> aux côtés de <code translate="no">photo.jpg</code>) et génère un élément <code translate="no">&lt;picture&gt;</code> avec un <code translate="no">&lt;source media="(prefers-color-scheme: dark)"&gt;</code>.</p>
<p>De la même manière, lorsque <a href="/fr/configuration/layouts/#layouts-images"><code translate="no">layouts.images.mobile_suffix</code></a> est configuré (par exemple <code translate="no">.mobile</code>), Cecil recherche une variante mobile de chaque image (par exemple <code translate="no">photo.mobile.jpg</code>) et ajoute un <code translate="no">&lt;source&gt;</code> avec la media query <a href="/fr/configuration/layouts/#layouts-images"><code translate="no">layouts.images.mobile_media_query</code></a>. Si une variante sombre de l’image mobile existe (par exemple <code translate="no">photo.mobile.dark.jpg</code>), elle est utilisée sur mobile en mode sombre.</p></aside>
<p><em>Exemples :</em></p>
<pre><code class="language-twig hljs twig" translate="no"><span class="hljs-comment">{# CSS with an attribute #}</span><span class="xml">
</span><span class="hljs-template-variable">{{ html(asset('print.css'), {media: 'print'}) }}</span><span class="xml">
</span><span class="hljs-comment">{# CSS with an attribute and an option #}</span><span class="xml">
</span><span class="hljs-template-variable">{{ html(asset('styles.css'), {title: 'Main theme'}, {preload: true}) }}</span><span class="xml">
</span><span class="hljs-comment">{# Array of assets with media query #}</span><span class="xml">
</span><span class="hljs-template-variable">{{ html([
  {asset: asset('css/style.css')},
  {asset: asset('css/style-dark.css'), attributes: {media: '(prefers-color-scheme: dark)'}}</span><span class="xml">
]) }}
</span><span class="hljs-comment">{# JavaScript #}</span><span class="xml">
</span><span class="hljs-template-variable">{{ html(asset('script.js')) }}</span><span class="xml">
</span><span class="hljs-comment">{# image without specific attributes nor options #}</span><span class="xml">
</span><span class="hljs-template-variable">{{ html(asset('image.png')) }}</span><span class="xml">
</span><span class="hljs-comment">{# image with specific attributes, responsive images and alternative formats #}</span><span class="xml">
</span><span class="hljs-template-variable">{{ html(asset('image.jpg'), {alt: 'Description', loading: 'lazy'}, {responsive: true, formats: ['avif', 'webp']}) }}</span><span class="xml">
</span><span class="hljs-comment">{# image with responsive pixels density images #}</span><span class="xml">
</span><span class="hljs-template-variable">{{ html(asset('image.jpg'), options={responsive: 'density'}, attributes={width: 256}) }}</span><span class="xml">
</span><span class="hljs-comment">{# image with a Low-Quality Image Placeholder #}</span><span class="xml">
</span><span class="hljs-template-variable">{{ html(asset('image.jpg'), {alt: 'Description', loading: 'lazy'}, {placeholder: 'lqip'}) }}</span><span class="xml">
</span><span class="hljs-comment">{# Audio #}</span><span class="xml">
</span><span class="hljs-template-variable">{{ html(asset('audio.mp3')) }}</span><span class="xml">
</span><span class="hljs-comment">{# Video #}</span><span class="xml">
</span><span class="hljs-template-variable">{{ html(asset('video.mp4')) }}</span></code></pre>
<aside class="note note-info"><p>Pour plus de commodité, la fonction <code translate="no">html</code> reste disponible en tant que filtre (mais est considérée comme obsolète) :</p>
<pre><code class="language-twig hljs twig" translate="no"><span class="hljs-template-variable">{{ asset|html({attributes}, {options}) }}</span></code></pre></aside>
<h2 id="readtime">readtime</h2>
<p>Détermine le temps de lecture d'un texte, en minutes.</p>
<pre><code class="language-twig hljs twig" translate="no"><span class="hljs-template-variable">{{ readtime(value) }}</span></code></pre>
<p><em>Exemple:</em></p>
<pre><code class="language-twig hljs twig" translate="no"><span class="hljs-template-variable">{{ readtime(page.content) }}</span><span class="xml"> min</span></code></pre>
<h2 id="hash">hash</h2>
<p>Calcule le hachage d'un objet, d'un tableau ou d'une chaîne avec un algorithme donné.</p>
<pre><code class="language-twig hljs twig" translate="no"><span class="hljs-template-variable">{{ hash(value, algorithm) }}</span></code></pre>
<p><code translate="no">algorithm</code> peut être n'importe quel algorithme pris en charge par la fonction <code translate="no">hash()</code> de PHP (par exemple : <code translate="no">md5</code>, <code translate="no">sha256</code>, etc.). La valeur par défaut est <code translate="no">xxh128</code>.</p>
<p><em>Exemple:</em></p>
<pre><code class="language-twig hljs twig" translate="no"><span class="hljs-template-variable">{{ hash('my string', 'sha256') }}</span></code></pre>
<h2 id="cache-key">cache_key</h2>
<p>Calcule une clé de cache pour <a href="/fr/documentation/cache/#fragments-de-cache"><em>fragments</em> cache</a> en fonction d'un nom et d'une valeur facultative.</p>
<pre><code class="language-twig hljs twig" translate="no"><span class="hljs-template-tag">{% <span class="hljs-name">cache</span> cache_key(name, value) %}</span><span class="xml">
  </span><span class="hljs-comment">{# cacheable content #}</span><span class="xml">
</span><span class="hljs-template-tag">{% <span class="hljs-name">endcache</span> %}</span></code></pre>
<p>La fonction ajoute un hachage de la valeur (peut être une chaîne, un tableau ou un objet) au nom (ainsi que la langue actuelle et l'ID de build pour être sûr que la clé de cache générée est unique), donc si la valeur est modifiée, la clé de cache est également modifiée et le cache est automatiquement vidé.</p>
<h2 id="getenv">getenv</h2>
<p>Obtient la valeur d'une variable d'environnement à partir de sa clé.</p>
<pre><code class="language-twig hljs twig" translate="no"><span class="hljs-template-variable">{{ getenv(var) }}</span></code></pre>
<p><em>Exemple:</em></p>
<pre><code class="language-twig hljs twig" translate="no"><span class="hljs-template-variable">{{ getenv('VAR') }}</span></code></pre>
<h2 id="dump">dump</h2>
<p>La fonction <code translate="no">dump</code> affiche les informations sur une variable de modèle. Ceci est surtout utile pour déboguer un modèle qui ne se comporte pas comme prévu en introspectant ses variables :</p>
<pre><code class="language-twig hljs twig" translate="no"><span class="hljs-template-variable">{{ <span class="hljs-name">dump</span><span class="hljs-params">(user)</span> }}</span></code></pre>
<aside class="note note-important"><p>Le <a href="/fr/configuration/site/#debug"><em>debug mode</em></a> doit être activé.</p></aside>
<h2 id="d">d</h2>
<p>La fonction <code translate="no">d()</code> est la version HTML de <a href="#dump"><code translate="no">dump()</code></a> et utilise le <a href="https://symfony.com/doc/5.4/components/var_dumper.html" target="_blank" rel="noopener noreferrer">Symfony VarDumper Component</a> en arrière-plan.</p>
<pre><code class="language-twig hljs twig" translate="no"><span class="hljs-template-variable">{{ d(variable, {theme: light}) }}</span></code></pre>
<ul>
<li>Si <em>variable</em> n'est pas fourni, la fonction renvoie le contexte Twig actuel</li>
<li>Les thèmes disponibles sont « clair » (par défaut) et « sombre »</li>
</ul>
<aside class="note note-important"><p>Le <a href="/fr/configuration/site/#debug"><em>debug mode</em></a> doit être activé.</p></aside>]]>
    </content>
  </entry>
  <entry xml:lang="fr">
    <id>https://cecil.app/fr/documentation/templates/variables/</id>
    <title>Variables</title>
    <published>2026-05-26T00:00:00+00:00</published>
    <updated>2026-10-06T00:00:00+00:00</updated>
    <link href="https://cecil.app/fr/documentation/templates/variables/" rel="alternate" type="text/html" />
    <content type="html">
      <![CDATA[<h1>Variables</h1>
<blockquote>
<p>L'application transmet des variables aux templates pour manipulation dans le modèle. Les variables peuvent également avoir des attributs ou des éléments auxquels vous pouvez accéder.
Utilisez un point (.) pour accéder aux attributs d'une variable : <code translate="no">{{ foo.bar }}</code></p>
</blockquote>
<p>Vous pouvez utiliser des variables de différentes portées : <a href="#site"><code translate="no">site</code></a>, <a href="#page"><code translate="no">page</code></a>, <a href="#cecil"><code translate="no">cecil</code></a>.</p>
<h2 id="site">site</h2>
<p>La variable <code translate="no">site</code> contient des variables intégrées <strong>et</strong> celles définies dans la <a href="/fr/documentation/configuration/">configuration</a>.</p>
<table>
<thead>
<tr>
<th>Variables</th>
<th>Descriptif</th>
</tr>
</thead>
<tbody>
<tr>
<td><code translate="no">site.pages</code></td>
<td>Collection de toutes les pages, dans la langue actuelle.</td>
</tr>
<tr>
<td><code translate="no">site.allpages</code></td>
<td>Collection de toutes les pages, dans toutes les langues.</td>
</tr>
<tr>
<td><code translate="no">site.page(id)</code></td>
<td>Une page avec l'ID donné.</td>
</tr>
<tr>
<td><code translate="no">site.taxonomies</code></td>
<td>Recueil de vocabulaires.</td>
</tr>
<tr>
<td><code translate="no">site.home</code></td>
<td>ID de la page d'accueil.</td>
</tr>
<tr>
<td><code translate="no">site.time</code></td>
<td>Actuel <a href="https://wikipedia.org/wiki/Unix_time" target="_blank" rel="noopener noreferrer"><em>Timestamp</em></a>.</td>
</tr>
<tr>
<td><code translate="no">site.debug</code></td>
<td>État du mode débogage (<code translate="no">true</code> ou <code translate="no">false</code>).</td>
</tr>
<tr>
<td><code translate="no">site.build</code></td>
<td>ID de build actuel.</td>
</tr>
</tbody>
</table>
<p><em>Exemple:</em></p>
<pre><code class="language-yaml hljs yaml" translate="no"><span class="hljs-attr">title:</span> <span class="hljs-string">"My amazing website!"</span></code></pre>
<p>Peut être affiché dans un modèle avec :</p>
<pre><code class="language-twig hljs twig" translate="no"><span class="hljs-template-variable">{{ site.title }}</span></code></pre>
<aside class="note note-important"><p>Utilisez la méthode <code translate="no">showable</code> sur la collection de pages pour renvoyer uniquement les pages publiées et non les pages <em>virtuelles/redirectes/exclues</em>.</p>
<p><em>Exemple:</em></p>
<pre><code class="language-twig hljs twig" translate="no"><span class="hljs-template-tag">{% <span class="hljs-name"><span class="hljs-keyword">for</span></span> page in site.pages.showable %}</span><span class="xml">
  <span class="hljs-tag">&lt;<span class="hljs-name">a</span> <span class="hljs-attr">href</span>=<span class="hljs-string">"</span></span></span><span class="hljs-template-variable">{{ url(page) }}</span><span class="xml"><span class="hljs-tag"><span class="hljs-string">"</span>&gt;</span></span><span class="hljs-template-variable">{{ page.title }}</span><span class="xml"><span class="hljs-tag">&lt;/<span class="hljs-name">a</span>&gt;</span>
</span><span class="hljs-template-tag">{% <span class="hljs-name"><span class="hljs-keyword">endfor</span></span> %}</span></code></pre></aside>
<aside class="note note-warning"><p>Dans certains cas, vous pouvez rencontrer des conflits entre la configuration et les variables intégrées (ex. : <code translate="no">pages.default</code> configuration), vous pouvez donc utiliser <code translate="no">config.&lt;variable&gt;</code> (avec <code translate="no">&lt;variable&gt;</code> est le nom/chemin de la variable) pour accéder directement à la configuration brute.</p>
<p>Exemple:</p>
<pre><code class="language-twig hljs twig" translate="no"><span class="hljs-template-variable">{{ config.pages.default.sitemap.priority }}</span></code></pre></aside>
<h3 id="site-menus">site.menus</h3>
<p>Bouclez sur <code translate="no">site.menus.&lt;menu&gt;</code> pour obtenir chaque entrée de la collection <code translate="no">&lt;menu&gt;</code> (par exemple : <code translate="no">main</code>).</p>
<table>
<thead>
<tr>
<th>Variables</th>
<th>Descriptif</th>
</tr>
</thead>
<tbody>
<tr>
<td><code translate="no">&lt;entry&gt;.name</code></td>
<td>Nom de l'entrée.</td>
</tr>
<tr>
<td><code translate="no">&lt;entry&gt;.url</code></td>
<td>URL d'entrée.</td>
</tr>
<tr>
<td><code translate="no">&lt;entry&gt;.weight</code></td>
<td>Poids d'entrée (utile pour trier les entrées de menu).</td>
</tr>
</tbody>
</table>
<p><em>Exemple:</em></p>
<pre><code class="language-twig hljs twig" translate="no"><span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">nav</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">ol</span>&gt;</span>
  </span><span class="hljs-template-tag">{% <span class="hljs-name"><span class="hljs-keyword">for</span></span> entry in site.menus.main|sort_by_weight %}</span><span class="xml">
    <span class="hljs-tag">&lt;<span class="hljs-name">li</span>&gt;</span><span class="hljs-tag">&lt;<span class="hljs-name">a</span> <span class="hljs-attr">href</span>=<span class="hljs-string">"</span></span></span><span class="hljs-template-variable">{{ url(entry.url) }}</span><span class="xml"><span class="hljs-tag"><span class="hljs-string">"</span> <span class="hljs-attr">data-weight</span>=<span class="hljs-string">"</span></span></span><span class="hljs-template-variable">{{ entry.weight }}</span><span class="xml"><span class="hljs-tag"><span class="hljs-string">"</span>&gt;</span></span><span class="hljs-template-variable">{{ entry.name }}</span><span class="xml"><span class="hljs-tag">&lt;/<span class="hljs-name">a</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">li</span>&gt;</span>
  </span><span class="hljs-template-tag">{% <span class="hljs-name"><span class="hljs-keyword">endfor</span></span> %}</span><span class="xml">
  <span class="hljs-tag">&lt;/<span class="hljs-name">ol</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">nav</span>&gt;</span></span></code></pre>
<h3 id="site-language">site.language</h3>
<p>Informations sur la langue actuelle.</p>
<table>
<thead>
<tr>
<th>Variables</th>
<th>Descriptif</th>
</tr>
</thead>
<tbody>
<tr>
<td><code translate="no">site.language</code></td>
<td>Code de langue (ex. : <code translate="no">en</code>).</td>
</tr>
<tr>
<td><code translate="no">site.language.name</code></td>
<td>Nom de la langue (par exemple : <code translate="no">English</code>).</td>
</tr>
<tr>
<td><code translate="no">site.language.locale</code></td>
<td>Langue <a href="/fr/documentation/configuration/codes-de-locale/">code local</a> (par exemple : <code translate="no">en_US</code>).</td>
</tr>
<tr>
<td><code translate="no">site.language.weight</code></td>
<td>Position de la langue dans la liste <code translate="no">languages</code>.</td>
</tr>
</tbody>
</table>
<aside class="note note-tip"><p>Vous pouvez récupérer <code translate="no">name</code>, <code translate="no">locale</code> et <code translate="no">weight</code> d'un langage spécifique en passant son code en paramètre.
par exemple : <code translate="no">site.language.name('fr')</code>.</p></aside>
<h3 id="site-static">site.static</h3>
<p>La collection de fichiers statiques est accessible via <code translate="no">site.static</code> si le <a href="/fr/documentation/configuration/donnees-et-statiques/#static-load"><em>static load</em></a> est activé.</p>
<p>Chaque fichier expose les propriétés suivantes :</p>
<ul>
<li><code translate="no">path</code> : chemin relatif (ex. : <code translate="no">/images/img-1.jpg</code>)</li>
<li><code translate="no">date</code> : date de création (<em>timestamp</em>)</li>
<li><code translate="no">updated</code> : date de modification (<em>timestamp</em>)</li>
<li><code translate="no">name</code> : nom (ex. : <code translate="no">img-1.jpg</code>)</li>
<li><code translate="no">basename</code> : nom sans extension (ex. : <code translate="no">img-1</code>)</li>
<li><code translate="no">ext</code> : poste (ex. : <code translate="no">jpg</code>)</li>
<li><code translate="no">type</code> : type de média (ex. : <code translate="no">image</code>)</li>
<li><code translate="no">subtype</code> : sous-type de média (ex. : <code translate="no">image/jpeg</code>)</li>
<li><code translate="no">exif</code> : données EXIF ​​​​de l'image (<em>array</em>)</li>
<li><code translate="no">audio</code> : <a href="https://github.com/wapmorgan/Mp3Info#audio-information" target="_blank" rel="noopener noreferrer">Mp3Info</a> objet</li>
<li><code translate="no">video</code> : tableau d'informations vidéo de base (durée en secondes, largeur et hauteur)</li>
</ul>
<h3 id="site-data">site.data</h3>
<p>Une collection de données est accessible via <code translate="no">site.data.&lt;filename&gt;</code> (sans extension de fichier).</p>
<p><em>Exemples :</em></p>
<ul>
<li><code translate="no">data/authors.yml</code> : <code translate="no">site.data.authors</code></li>
<li><code translate="no">data/authors.fr.yml</code> : <code translate="no">site.data.authors</code> (si <code translate="no">site.language</code> = "fr")</li>
<li><code translate="no">data/galleries/gallery-1.json</code> : <code translate="no">site.data.galleries['gallery-1']</code></li>
</ul>
<h2 id="page">page</h2>
<p>La variable <code translate="no">page</code> contient les variables intégrées d'une page <strong>et</strong> celles définies dans le <a href="/fr/documentation/contenu/pages/#front-matter">avant-plan</a>.</p>
<table>
<thead>
<tr>
<th>Variables</th>
<th>Descriptif</th>
<th>Exemple</th>
</tr>
</thead>
<tbody>
<tr>
<td><code translate="no">page.id</code></td>
<td>Identifiant unique.</td>
<td><code translate="no">blog/post-1</code></td>
</tr>
<tr>
<td><code translate="no">page.title</code></td>
<td>Nom du fichier (sans extension).</td>
<td><code translate="no">Post 1</code></td>
</tr>
<tr>
<td><code translate="no">page.date</code></td>
<td>Date de création du fichier.</td>
<td><em>DateHeure</em></td>
</tr>
<tr>
<td><code translate="no">page.body</code></td>
<td>Corps du fichier.</td>
<td><em>Marquage</em></td>
</tr>
<tr>
<td><code translate="no">page.content</code></td>
<td>Corps du fichier converti en HTML.</td>
<td><em>HTML</em></td>
</tr>
<tr>
<td><code translate="no">page.section</code></td>
<td>Dossier racine du fichier (<em>slugified</em>).</td>
<td><code translate="no">blog</code></td>
</tr>
<tr>
<td><code translate="no">page.path</code></td>
<td>Chemin du fichier (<em>slugified</em>).</td>
<td><code translate="no">blog/post-1</code></td>
</tr>
<tr>
<td><code translate="no">page.slug</code></td>
<td>Nom du fichier (<em>slugified</em>).</td>
<td><code translate="no">post-1</code></td>
</tr>
<tr>
<td><code translate="no">page.filepath</code></td>
<td>Chemin du système de fichiers.</td>
<td><code translate="no">Blog/Post 1.md</code></td>
</tr>
<tr>
<td><code translate="no">page.type</code></td>
<td><code translate="no">homepage</code>, <code translate="no">page</code>, <code translate="no">section</code>, <code translate="no">vocabulary</code> ou <code translate="no">term</code>.</td>
<td><code translate="no">page</code></td>
</tr>
<tr>
<td><code translate="no">page.pages</code></td>
<td>Collection de toutes les sous-pages.</td>
<td><em>Collection</em></td>
</tr>
<tr>
<td><code translate="no">page.translations</code></td>
<td>Collection de pages traduites.</td>
<td><em>Collection</em></td>
</tr>
</tbody>
</table>
<aside class="note note-important"><p>Utilisez la méthode <code translate="no">showable</code> sur la collection de pages pour renvoyer uniquement les pages publiées et non les pages <em>virtuelles/redirectes/exclues</em>.</p>
<p><em>Exemple:</em></p>
<pre><code class="language-twig hljs twig" translate="no"><span class="hljs-template-tag">{% <span class="hljs-name"><span class="hljs-keyword">for</span></span> page in page.pages.showable %}</span><span class="xml">
  <span class="hljs-tag">&lt;<span class="hljs-name">a</span> <span class="hljs-attr">href</span>=<span class="hljs-string">"</span></span></span><span class="hljs-template-variable">{{ url(page) }}</span><span class="xml"><span class="hljs-tag"><span class="hljs-string">"</span>&gt;</span></span><span class="hljs-template-variable">{{ page.title }}</span><span class="xml"><span class="hljs-tag">&lt;/<span class="hljs-name">a</span>&gt;</span>
</span><span class="hljs-template-tag">{% <span class="hljs-name"><span class="hljs-keyword">endfor</span></span> %}</span></code></pre></aside>
<h3 id="sections-imbriquees">Sections imbriquées</h3>
<p>Dans un contexte de <a href="/fr/documentation/contenu/pages/#sous-section">sections imbriquées</a>, les propriétés <code translate="no">page.parent</code>, <code translate="no">page.ancestors</code>, <code translate="no">page.sections</code> et <code translate="no">page.toplevel</code> facilitent la construction de la navigation.</p>
<table>
<thead>
<tr>
<th>Variables</th>
<th>Descriptif</th>
<th>Exemple</th>
</tr>
</thead>
<tbody>
<tr>
<td><code translate="no">page.parent</code></td>
<td>Page de la <em>section</em> parente (<code translate="no">null</code> si aucune).</td>
<td><em>Page</em></td>
</tr>
<tr>
<td><code translate="no">page.ancestors</code></td>
<td>Collection des <em>sections</em> ancêtres (la plus proche en premier).</td>
<td><em>Collection</em></td>
</tr>
<tr>
<td><code translate="no">page.sections</code></td>
<td>Collection des <em>sections</em> descendantes immédiates.</td>
<td><em>Collection</em></td>
</tr>
<tr>
<td><code translate="no">page.toplevel</code></td>
<td><code translate="no">true</code> si la page est une <em>section</em> de premier niveau.</td>
<td><em>Boolean</em></td>
</tr>
</tbody>
</table>
<p><em>Fil d'Ariane (de la page d'accueil à la page courante) :</em></p>
<pre><code class="language-twig hljs twig" translate="no"><span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">nav</span> <span class="hljs-attr">aria-label</span>=<span class="hljs-string">"breadcrumb"</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">ul</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">li</span>&gt;</span><span class="hljs-tag">&lt;<span class="hljs-name">a</span> <span class="hljs-attr">href</span>=<span class="hljs-string">"</span></span></span><span class="hljs-template-variable">{{ url(site.home) }}</span><span class="xml"><span class="hljs-tag"><span class="hljs-string">"</span>&gt;</span></span><span class="hljs-template-variable">{{ site.title }}</span><span class="xml"><span class="hljs-tag">&lt;/<span class="hljs-name">a</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">li</span>&gt;</span>
    </span><span class="hljs-template-tag">{% <span class="hljs-name"><span class="hljs-keyword">for</span></span> section in page.ancestors|<span class="hljs-keyword">reverse</span> %}</span><span class="xml">
    <span class="hljs-tag">&lt;<span class="hljs-name">li</span>&gt;</span><span class="hljs-tag">&lt;<span class="hljs-name">a</span> <span class="hljs-attr">href</span>=<span class="hljs-string">"</span></span></span><span class="hljs-template-variable">{{ url(section) }}</span><span class="xml"><span class="hljs-tag"><span class="hljs-string">"</span>&gt;</span></span><span class="hljs-template-variable">{{ section.title }}</span><span class="xml"><span class="hljs-tag">&lt;/<span class="hljs-name">a</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">li</span>&gt;</span>
    </span><span class="hljs-template-tag">{% <span class="hljs-name"><span class="hljs-keyword">endfor</span></span> %}</span><span class="xml">
    </span><span class="hljs-template-tag">{% <span class="hljs-name"><span class="hljs-keyword">if</span></span> page.id != site.home %}</span><span class="xml">
    <span class="hljs-tag">&lt;<span class="hljs-name">li</span>&gt;</span><span class="hljs-tag">&lt;<span class="hljs-name">a</span> <span class="hljs-attr">href</span>=<span class="hljs-string">"</span></span></span><span class="hljs-template-variable">{{ url(page) }}</span><span class="xml"><span class="hljs-tag"><span class="hljs-string">"</span> <span class="hljs-attr">aria-current</span>=<span class="hljs-string">"page"</span>&gt;</span></span><span class="hljs-template-variable">{{ page.title }}</span><span class="xml"><span class="hljs-tag">&lt;/<span class="hljs-name">a</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">li</span>&gt;</span>
    </span><span class="hljs-template-tag">{% <span class="hljs-name"><span class="hljs-keyword">endif</span></span> %}</span><span class="xml">
  <span class="hljs-tag">&lt;/<span class="hljs-name">ul</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">nav</span>&gt;</span></span></code></pre>
<aside class="note note-tip"><p>Un partial <a href="https://github.com/Cecilapp/Cecil/blob/main/resources/layouts/partials/breadcrumb.html.twig" target="_blank" rel="noopener noreferrer"><code translate="no">breadcrumb.html.twig</code></a> prêt à l'emploi est disponible :</p>
<pre><code class="language-twig hljs twig" translate="no"><span class="hljs-template-variable">{{ <span class="hljs-name">include</span><span class="hljs-params">('partials/breadcrumb.html.twig')</span> }}</span></code></pre></aside>
<p><em>Menu des sous-sections (sections descendantes immédiates de la section courante) :</em></p>
<pre><code class="language-twig hljs twig" translate="no"><span class="hljs-template-tag">{% <span class="hljs-name"><span class="hljs-keyword">if</span></span> page.sections|<span class="hljs-keyword">length</span> %}</span><span class="xml">
<span class="hljs-tag">&lt;<span class="hljs-name">ul</span>&gt;</span>
  </span><span class="hljs-template-tag">{% <span class="hljs-name"><span class="hljs-keyword">for</span></span> section in page.sections|sort_by_title %}</span><span class="xml">
  <span class="hljs-tag">&lt;<span class="hljs-name">li</span>&gt;</span><span class="hljs-tag">&lt;<span class="hljs-name">a</span> <span class="hljs-attr">href</span>=<span class="hljs-string">"</span></span></span><span class="hljs-template-variable">{{ url(section) }}</span><span class="xml"><span class="hljs-tag"><span class="hljs-string">"</span>&gt;</span></span><span class="hljs-template-variable">{{ section.title }}</span><span class="xml"><span class="hljs-tag">&lt;/<span class="hljs-name">a</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">li</span>&gt;</span>
  </span><span class="hljs-template-tag">{% <span class="hljs-name"><span class="hljs-keyword">endfor</span></span> %}</span><span class="xml">
<span class="hljs-tag">&lt;/<span class="hljs-name">ul</span>&gt;</span>
</span><span class="hljs-template-tag">{% <span class="hljs-name"><span class="hljs-keyword">endif</span></span> %}</span></code></pre>
<p><em>Navigation principale limitée aux sections de premier niveau (depuis n'importe quelle page) :</em></p>
<pre><code class="language-twig hljs twig" translate="no"><span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">nav</span>&gt;</span>
  </span><span class="hljs-template-tag">{% <span class="hljs-name"><span class="hljs-keyword">for</span></span> section in site.page(site.home).sections|sort_by_title %}</span><span class="xml">
  <span class="hljs-tag">&lt;<span class="hljs-name">a</span> <span class="hljs-attr">href</span>=<span class="hljs-string">"</span></span></span><span class="hljs-template-variable">{{ url(section) }}</span><span class="xml"><span class="hljs-tag"><span class="hljs-string">"</span>&gt;</span></span><span class="hljs-template-variable">{{ section.title }}</span><span class="xml"><span class="hljs-tag">&lt;/<span class="hljs-name">a</span>&gt;</span>
  </span><span class="hljs-template-tag">{% <span class="hljs-name"><span class="hljs-keyword">endfor</span></span> %}</span><span class="xml">
<span class="hljs-tag">&lt;/<span class="hljs-name">nav</span>&gt;</span></span></code></pre>
<p><em>Lien vers la section parente :</em></p>
<pre><code class="language-twig hljs twig" translate="no"><span class="hljs-template-tag">{% <span class="hljs-name"><span class="hljs-keyword">if</span></span> page.<span class="hljs-name">parent</span> %}</span><span class="xml">
<span class="hljs-tag">&lt;<span class="hljs-name">a</span> <span class="hljs-attr">href</span>=<span class="hljs-string">"</span></span></span><span class="hljs-template-variable">{{ url(page.<span class="hljs-name">parent</span>) }}</span><span class="xml"><span class="hljs-tag"><span class="hljs-string">"</span>&gt;</span>← </span><span class="hljs-template-variable">{{ page.<span class="hljs-name">parent</span>.title }}</span><span class="xml"><span class="hljs-tag">&lt;/<span class="hljs-name">a</span>&gt;</span>
</span><span class="hljs-template-tag">{% <span class="hljs-name"><span class="hljs-keyword">endif</span></span> %}</span></code></pre>
<h3 id="page-prev-next">page.&lt;prev/next&gt;</h3>
<p>Navigation entre les pages d'une même <em>Section</em>, triées selon le <code translate="no">sortby</code> de la section (ordre chronologique pour les dates).</p>
<p>Avec des <a href="/fr/documentation/contenu/pages/#sous-section">sous-sections</a>, la navigation suit l'arbre des sections : les pages d'une <em>Section</em> de premier niveau et de toutes ses sous-sections sont enchaînées, chaque sous-section (sa page d'index) étant placée parmi les pages de sa <em>Section</em> parente et suivie de ses propres pages.</p>
<table>
<thead>
<tr>
<th>Variables</th>
<th>Descriptif</th>
<th>Exemple</th>
</tr>
</thead>
<tbody>
<tr>
<td><code translate="no">page.prev</code></td>
<td>Page précédente.</td>
<td><em>Page</em></td>
</tr>
<tr>
<td><code translate="no">page.next</code></td>
<td>Page suivante.</td>
<td><em>Page</em></td>
</tr>
</tbody>
</table>
<p><em>Exemple:</em></p>
<pre><code class="language-twig hljs twig" translate="no"><span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">a</span> <span class="hljs-attr">href</span>=<span class="hljs-string">"</span></span></span><span class="hljs-template-variable">{{ url(page.prev) }}</span><span class="xml"><span class="hljs-tag"><span class="hljs-string">"</span>&gt;</span></span><span class="hljs-template-variable">{{ page.prev.title }}</span><span class="xml"><span class="hljs-tag">&lt;/<span class="hljs-name">a</span>&gt;</span></span></code></pre>
<h3 id="page-paginator">page.paginator</h3>
<p><em>Paginator</em> vous aide à créer une navigation pour les pages de la liste : page d'accueil, sections et taxonomies.</p>
<table>
<thead>
<tr>
<th>Variables</th>
<th>Descriptif</th>
</tr>
</thead>
<tbody>
<tr>
<td><code translate="no">page.paginator.pages</code></td>
<td>Collection de pages.</td>
</tr>
<tr>
<td><code translate="no">page.paginator.pages_total</code></td>
<td>Nombre total de pages.</td>
</tr>
<tr>
<td><code translate="no">page.paginator.count</code></td>
<td>Nombre de pages du paginateur.</td>
</tr>
<tr>
<td><code translate="no">page.paginator.current</code></td>
<td>Index de position de la page actuelle.</td>
</tr>
<tr>
<td><code translate="no">page.paginator.links.first</code></td>
<td>ID de page de la première page.</td>
</tr>
<tr>
<td><code translate="no">page.paginator.links.prev</code></td>
<td>ID de page de la page précédente.</td>
</tr>
<tr>
<td><code translate="no">page.paginator.links.self</code></td>
<td>ID de page de la page actuelle.</td>
</tr>
<tr>
<td><code translate="no">page.paginator.links.next</code></td>
<td>ID de page de la page suivante.</td>
</tr>
<tr>
<td><code translate="no">page.paginator.links.last</code></td>
<td>ID de page de la dernière page.</td>
</tr>
<tr>
<td><code translate="no">page.paginator.links.path</code></td>
<td>ID de page sans l'index de position.</td>
</tr>
</tbody>
</table>
<aside class="note note-important"><p>Étant donné que les entrées de liens sont des ID de page, vous devez utiliser la fonction <code translate="no">url()</code> pour créer des liens fonctionnels.
par exemple : <code translate="no">{{ url(page.paginator.links.next) }}</code></p></aside>
<p><em>Exemple:</em></p>
<pre><code class="language-twig hljs twig" translate="no"><span class="hljs-template-tag">{% <span class="hljs-name"><span class="hljs-keyword">if</span></span> page.paginator %}</span><span class="xml">
<span class="hljs-tag">&lt;<span class="hljs-name">div</span>&gt;</span>
  </span><span class="hljs-template-tag">{% <span class="hljs-name"><span class="hljs-keyword">if</span></span> page.paginator.links.prev is defined %}</span><span class="xml">
  <span class="hljs-tag">&lt;<span class="hljs-name">a</span> <span class="hljs-attr">href</span>=<span class="hljs-string">"</span></span></span><span class="hljs-template-variable">{{ url(page.paginator.links.prev) }}</span><span class="xml"><span class="hljs-tag"><span class="hljs-string">"</span>&gt;</span>Previous<span class="hljs-tag">&lt;/<span class="hljs-name">a</span>&gt;</span>
  </span><span class="hljs-template-tag">{% <span class="hljs-name"><span class="hljs-keyword">endif</span></span> %}</span><span class="xml">
  </span><span class="hljs-template-tag">{% <span class="hljs-name"><span class="hljs-keyword">if</span></span> page.paginator.links.next is defined %}</span><span class="xml">
  <span class="hljs-tag">&lt;<span class="hljs-name">a</span> <span class="hljs-attr">href</span>=<span class="hljs-string">"</span></span></span><span class="hljs-template-variable">{{ url(page.paginator.links.next) }}</span><span class="xml"><span class="hljs-tag"><span class="hljs-string">"</span>&gt;</span>Next<span class="hljs-tag">&lt;/<span class="hljs-name">a</span>&gt;</span>
  </span><span class="hljs-template-tag">{% <span class="hljs-name"><span class="hljs-keyword">endif</span></span> %}</span><span class="xml">
<span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
</span><span class="hljs-template-tag">{% <span class="hljs-name"><span class="hljs-keyword">endif</span></span> %}</span></code></pre>
<p><em>Exemple:</em></p>
<pre><code class="language-twig hljs twig" translate="no"><span class="hljs-template-tag">{% <span class="hljs-name"><span class="hljs-keyword">if</span></span> page.paginator %}</span><span class="xml">
<span class="hljs-tag">&lt;<span class="hljs-name">div</span>&gt;</span>
  </span><span class="hljs-template-tag">{% <span class="hljs-name"><span class="hljs-keyword">for</span></span> paginator_index in 1..page.paginator.count %}</span><span class="xml">
    </span><span class="hljs-template-tag">{% <span class="hljs-name"><span class="hljs-keyword">if</span></span> paginator_index != page.paginator.current %}</span><span class="xml">
      </span><span class="hljs-template-tag">{% <span class="hljs-name"><span class="hljs-keyword">if</span></span> paginator_index == 1 %}</span><span class="xml">
  <span class="hljs-tag">&lt;<span class="hljs-name">a</span> <span class="hljs-attr">href</span>=<span class="hljs-string">"</span></span></span><span class="hljs-template-variable">{{ url(page.paginator.links.first) }}</span><span class="xml"><span class="hljs-tag"><span class="hljs-string">"</span>&gt;</span></span><span class="hljs-template-variable">{{ paginator_index }}</span><span class="xml"><span class="hljs-tag">&lt;/<span class="hljs-name">a</span>&gt;</span>
      </span><span class="hljs-template-tag">{% <span class="hljs-name">else</span> %}</span><span class="xml">
  <span class="hljs-tag">&lt;<span class="hljs-name">a</span> <span class="hljs-attr">href</span>=<span class="hljs-string">"</span></span></span><span class="hljs-template-variable">{{ url(page.paginator.links.path ~ '/' ~ paginator_index) }}</span><span class="xml"><span class="hljs-tag"><span class="hljs-string">"</span>&gt;</span></span><span class="hljs-template-variable">{{ paginator_index }}</span><span class="xml"><span class="hljs-tag">&lt;/<span class="hljs-name">a</span>&gt;</span>
      </span><span class="hljs-template-tag">{% <span class="hljs-name"><span class="hljs-keyword">endif</span></span> %}</span><span class="xml">
    </span><span class="hljs-template-tag">{% <span class="hljs-name">else</span> %}</span><span class="xml">
  </span><span class="hljs-template-variable">{{ paginator_index }}</span><span class="xml">
    </span><span class="hljs-template-tag">{% <span class="hljs-name"><span class="hljs-keyword">endif</span></span> %}</span><span class="xml">
  </span><span class="hljs-template-tag">{% <span class="hljs-name"><span class="hljs-keyword">endfor</span></span> %}</span><span class="xml">
<span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
</span><span class="hljs-template-tag">{% <span class="hljs-name"><span class="hljs-keyword">endif</span></span> %}</span></code></pre>
<h3 id="taxonomie">Taxonomie</h3>
<p>Variables disponibles dans les templates <em>vocabulary</em> et <em>term</em>.</p>
<h4>Vocabulaire</h4>
<p>Page <code translate="no">/&lt;plural&gt;/</code> (ex. : <code translate="no">/categories/</code>).</p>
<table>
<thead>
<tr>
<th>Variables</th>
<th>Descriptif</th>
</tr>
</thead>
<tbody>
<tr>
<td><code translate="no">page.plural</code></td>
<td>Nom de vocabulaire au pluriel.</td>
</tr>
<tr>
<td><code translate="no">page.singular</code></td>
<td>Nom de vocabulaire au singulier.</td>
</tr>
<tr>
<td><code translate="no">page.terms</code></td>
<td>Liste de termes (<em>Collection</em>).</td>
</tr>
</tbody>
</table>
<p>Chaque terme de <code translate="no">page.terms</code> fournit <code translate="no">term.id</code> (identifiant du terme, ex. : <code translate="no">categories/php</code>), <code translate="no">term.name</code> (nom du terme, ex. : <code translate="no">PHP</code>) et le nombre de ses pages avec <code translate="no">term|length</code>.</p>
<h4>Terme</h4>
<p>Page <code translate="no">/&lt;plural&gt;/&lt;term&gt;/</code> (ex. : <code translate="no">/categories/php/</code>).</p>
<table>
<thead>
<tr>
<th>Variables</th>
<th>Descriptif</th>
</tr>
</thead>
<tbody>
<tr>
<td><code translate="no">page.title</code></td>
<td>Nom du terme.</td>
</tr>
<tr>
<td><code translate="no">page.term</code></td>
<td>Identifiant du terme (ex. : <code translate="no">categories/php</code>).</td>
</tr>
<tr>
<td><code translate="no">page.plural</code></td>
<td>Nom de vocabulaire au pluriel.</td>
</tr>
<tr>
<td><code translate="no">page.singular</code></td>
<td>Nom de vocabulaire au singulier.</td>
</tr>
<tr>
<td><code translate="no">page.pages</code></td>
<td>Liste des pages dans ce terme, triées par date (<em>Collection</em>).</td>
</tr>
</tbody>
</table>
<h4>Exemple de taxonomie</h4>
<p>Configuration :</p>
<pre><code class="language-yaml hljs yaml" translate="no"><span class="hljs-attr">taxonomies:</span>
  <span class="hljs-attr">categories:</span> <span class="hljs-string">category</span></code></pre>
<p>Front matter d’une page :</p>
<pre><code class="language-yaml hljs yaml" translate="no"><span class="hljs-meta">---</span>
<span class="hljs-attr">categories:</span> <span class="hljs-string">["Data</span> <span class="hljs-string">Sovereignty"]</span>
<span class="hljs-meta">---</span></code></pre>
<p>Liste des termes (<code translate="no">/categories/</code>), dans <code translate="no">layouts/taxonomy/categories.html.twig</code> :</p>
<pre><code class="language-twig hljs twig" translate="no"><span class="hljs-template-tag">{% <span class="hljs-name"><span class="hljs-keyword">extends</span></span> 'page.html.twig' %}</span><span class="xml">

</span><span class="hljs-template-tag">{% <span class="hljs-name"><span class="hljs-keyword">block</span></span> content %}</span><span class="xml">
  <span class="hljs-tag">&lt;<span class="hljs-name">h1</span>&gt;</span></span><span class="hljs-template-variable">{{ page.title }}</span><span class="xml"><span class="hljs-tag">&lt;/<span class="hljs-name">h1</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">ul</span>&gt;</span>
  </span><span class="hljs-template-tag">{% <span class="hljs-name"><span class="hljs-keyword">for</span></span> term in page.terms %}</span><span class="xml">
    <span class="hljs-tag">&lt;<span class="hljs-name">li</span>&gt;</span><span class="hljs-tag">&lt;<span class="hljs-name">a</span> <span class="hljs-attr">href</span>=<span class="hljs-string">"</span></span></span><span class="hljs-template-variable">{{ url(term.id) }}</span><span class="xml"><span class="hljs-tag"><span class="hljs-string">"</span>&gt;</span></span><span class="hljs-template-variable">{{ term.name }}</span><span class="xml"><span class="hljs-tag">&lt;/<span class="hljs-name">a</span>&gt;</span> (</span><span class="hljs-template-variable">{{ term|<span class="hljs-keyword">length</span> }}</span><span class="xml">)<span class="hljs-tag">&lt;/<span class="hljs-name">li</span>&gt;</span>
  </span><span class="hljs-template-tag">{% <span class="hljs-name"><span class="hljs-keyword">endfor</span></span> %}</span><span class="xml">
  <span class="hljs-tag">&lt;/<span class="hljs-name">ul</span>&gt;</span>
</span><span class="hljs-template-tag">{% <span class="hljs-name"><span class="hljs-keyword">endblock</span></span> %}</span></code></pre>
<p>Liste des pages d’un terme (<code translate="no">/categories/data-sovereignty/</code>), dans <code translate="no">layouts/taxonomy/category.html.twig</code> :</p>
<pre><code class="language-twig hljs twig" translate="no"><span class="hljs-template-tag">{% <span class="hljs-name"><span class="hljs-keyword">extends</span></span> 'page.html.twig' %}</span><span class="xml">

</span><span class="hljs-template-tag">{% <span class="hljs-name"><span class="hljs-keyword">block</span></span> content %}</span><span class="xml">
  <span class="hljs-tag">&lt;<span class="hljs-name">h1</span>&gt;</span></span><span class="hljs-template-variable">{{ page.title }}</span><span class="xml"><span class="hljs-tag">&lt;/<span class="hljs-name">h1</span>&gt;</span>
  </span><span class="hljs-template-tag">{% <span class="hljs-name"><span class="hljs-keyword">for</span></span> p in page.paginator.pages ?? page.pages %}</span><span class="xml">
    <span class="hljs-tag">&lt;<span class="hljs-name">article</span>&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">h2</span>&gt;</span><span class="hljs-tag">&lt;<span class="hljs-name">a</span> <span class="hljs-attr">href</span>=<span class="hljs-string">"</span></span></span><span class="hljs-template-variable">{{ url(p) }}</span><span class="xml"><span class="hljs-tag"><span class="hljs-string">"</span>&gt;</span></span><span class="hljs-template-variable">{{ p.title }}</span><span class="xml"><span class="hljs-tag">&lt;/<span class="hljs-name">a</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">h2</span>&gt;</span>
    <span class="hljs-tag">&lt;/<span class="hljs-name">article</span>&gt;</span>
  </span><span class="hljs-template-tag">{% <span class="hljs-name"><span class="hljs-keyword">endfor</span></span> %}</span><span class="xml">
  <span class="hljs-tag">&lt;<span class="hljs-name">a</span> <span class="hljs-attr">href</span>=<span class="hljs-string">"</span></span></span><span class="hljs-template-variable">{{ url(page.plural) }}</span><span class="xml"><span class="hljs-tag"><span class="hljs-string">"</span>&gt;</span>Toutes les </span><span class="hljs-template-variable">{{ page.plural }}</span><span class="xml"><span class="hljs-tag">&lt;/<span class="hljs-name">a</span>&gt;</span>
</span><span class="hljs-template-tag">{% <span class="hljs-name"><span class="hljs-keyword">endblock</span></span> %}</span></code></pre>
<p>Liens vers les termes de la page courante, dans un template de page :</p>
<pre><code class="language-twig hljs twig" translate="no"><span class="hljs-template-tag">{% <span class="hljs-name"><span class="hljs-keyword">for</span></span> category in page.categories ?? [] %}</span><span class="xml">
  <span class="hljs-tag">&lt;<span class="hljs-name">a</span> <span class="hljs-attr">href</span>=<span class="hljs-string">"</span></span></span><span class="hljs-template-variable">{{ url('categories/' ~ category) }}</span><span class="xml"><span class="hljs-tag"><span class="hljs-string">"</span>&gt;</span></span><span class="hljs-template-variable">{{ category }}</span><span class="xml"><span class="hljs-tag">&lt;/<span class="hljs-name">a</span>&gt;</span>
</span><span class="hljs-template-tag">{% <span class="hljs-name"><span class="hljs-keyword">endfor</span></span> %}</span></code></pre>
<aside class="note note-tip"><p>La fonction <a href="/fr/documentation/templates/reference/fonctions/#url"><code translate="no">url()</code></a> « slugifie » la chaîne fournie pour trouver la page correspondante : <code translate="no">url('categories/Data Sovereignty')</code> retourne <code translate="no">/categories/data-sovereignty/</code>.</p>
<p>Vous pouvez aussi utiliser le partial intégré <code translate="no">{{ include('partials/terms-list.html.twig', {vocabulary: 'categories'}) }}</code>.</p></aside>
<h2 id="cecil">cecil</h2>
<table>
<thead>
<tr>
<th>Variables</th>
<th>Descriptif</th>
</tr>
</thead>
<tbody>
<tr>
<td><code translate="no">cecil.url</code></td>
<td>URL du site Cecil.</td>
</tr>
<tr>
<td><code translate="no">cecil.version</code></td>
<td>Version actuelle de Cecil.</td>
</tr>
<tr>
<td><code translate="no">cecil.poweredby</code></td>
<td>Imprimez <code translate="no">Cecil v%s</code>, avec <code translate="no">%s</code> est la version actuelle.</td>
</tr>
</tbody>
</table>]]>
    </content>
  </entry>
  <entry xml:lang="fr">
    <id>https://cecil.app/fr/documentation/templates/reference/tris/</id>
    <title>Tris</title>
    <published>2026-05-26T00:00:00+00:00</published>
    <updated>2026-10-05T00:00:00+00:00</updated>
    <link href="https://cecil.app/fr/documentation/templates/reference/tris/" rel="alternate" type="text/html" />
    <content type="html">
      <![CDATA[<h1>Tris</h1>
<p>Tri des collections (de pages, menus ou taxonomies).</p>
<h2 id="sort-by-title">sort_by_title</h2>
<p>Trie une collection par titre (avec <a href="https://en.wikipedia.org/wiki/Natural_sort_order" target="_blank" rel="noopener noreferrer">tri naturel</a>).</p>
<pre><code class="language-twig hljs twig" translate="no"><span class="hljs-template-variable">{{ collection|sort_by_title }}</span></code></pre>
<p><em>Exemple:</em></p>
<pre><code class="language-twig hljs twig" translate="no"><span class="hljs-template-variable">{{ site.pages|sort_by_title }}</span></code></pre>
<h2 id="sort-by-date">sort_by_date</h2>
<p>Trie une collection par date (la plus récente en premier).</p>
<pre><code class="language-twig hljs twig" translate="no"><span class="hljs-template-variable">{{ collection|sort_by_date(variable='<span class="hljs-name">date</span>', desc_title=false) }}</span></code></pre>
<p><em>Exemple:</em></p>
<pre><code class="language-twig hljs twig" translate="no"><span class="hljs-comment">{# sort by date #}</span><span class="xml">
</span><span class="hljs-template-variable">{{ site.pages|sort_by_date }}</span><span class="xml">
</span><span class="hljs-comment">{# sort by updated variable instead of date #}</span><span class="xml">
</span><span class="hljs-template-variable">{{ site.pages|sort_by_date(variable='updated') }}</span><span class="xml">
</span><span class="hljs-comment">{# sort items with the same date by desc title #}</span><span class="xml">
</span><span class="hljs-template-variable">{{ site.pages|sort_by_date(desc_title=true) }}</span><span class="xml">
</span><span class="hljs-comment">{# reverse sort #}</span><span class="xml">
</span><span class="hljs-template-variable">{{ site.pages|sort_by_date|<span class="hljs-keyword">reverse</span> }}</span></code></pre>
<h2 id="sort-by-weight">sort_by_weight</h2>
<p>Trie une collection par poids (le plus léger en premier).</p>
<pre><code class="language-twig hljs twig" translate="no"><span class="hljs-template-variable">{{ collection|sort_by_weight }}</span></code></pre>
<p><em>Exemple:</em></p>
<pre><code class="language-twig hljs twig" translate="no"><span class="hljs-template-variable">{{ site.menus.main|sort_by_weight }}</span></code></pre>
<h2 id="sort">sort</h2>
<p>Pour les cas plus complexes, vous devez utiliser <a href="https://twig.symfony.com/doc/filters/sort.html" target="_blank" rel="noopener noreferrer">le <code translate="no">sort</code></a> natif de Twig.</p>
<p><em>Exemple:</em></p>
<pre><code class="language-twig hljs twig" translate="no"><span class="hljs-template-tag">{% <span class="hljs-name"><span class="hljs-keyword">set</span></span> files = site.static|<span class="hljs-keyword">sort</span>((a, b) =&gt; a.<span class="hljs-name">date</span>|<span class="hljs-keyword">date</span>('U') &lt; b.<span class="hljs-name">date</span>|<span class="hljs-keyword">date</span>('U')) %}</span></code></pre>]]>
    </content>
  </entry>
  <entry xml:lang="fr">
    <id>https://cecil.app/fr/documentation/templates/reference/filtres/</id>
    <title>Filtres</title>
    <published>2026-05-26T00:00:00+00:00</published>
    <updated>2026-10-05T00:00:00+00:00</updated>
    <link href="https://cecil.app/fr/documentation/templates/reference/filtres/" rel="alternate" type="text/html" />
    <content type="html">
      <![CDATA[<h1>Filtres</h1>
<p>Les variables peuvent être modifiées par <a href="https://twig.symfony.com/doc/filters/index.html" target="_blank" rel="noopener noreferrer">filtres</a>. Les filtres sont séparés de la variable par un symbole de barre verticale (<code translate="no">|</code>). Plusieurs filtres peuvent être chaînés. La sortie d’un filtre est appliquée au suivant.</p>
<pre><code class="language-twig hljs twig" translate="no"><span class="hljs-template-variable">{{ page.title|truncate(25)|<span class="hljs-keyword">capitalize</span> }}</span></code></pre>
<h2 id="filter-by">filter_by</h2>
<p>Filtre une collection de pages par nom/valeur de variable.</p>
<pre><code class="language-twig hljs twig" translate="no"><span class="hljs-template-variable">{{ collection|filter_by(variable, value) }}</span></code></pre>
<p><em>Exemple:</em></p>
<pre><code class="language-twig hljs twig" translate="no"><span class="hljs-template-variable">{{ pages|filter_by('section', 'blog') }}</span></code></pre>
<h2 id="filter">filter</h2>
<p>Pour les cas plus complexes, vous devez utiliser <a href="https://twig.symfony.com/doc/filters/filter.html" target="_blank" rel="noopener noreferrer">le <code translate="no">filter</code></a> natif de Twig.</p>
<p><em>Exemple:</em></p>
<pre><code class="language-twig hljs twig" translate="no"><span class="hljs-template-tag">{% <span class="hljs-name">pages</span>|<span class="hljs-keyword">filter</span>(p =&gt; p.virtual == false and p.id not in ['page-1', 'page-2']) %}</span></code></pre>
<h2 id="markdown-to-html">markdown_to_html</h2>
<p>Convertit une chaîne Markdown en HTML.</p>
<pre><code class="language-twig hljs twig" translate="no"><span class="hljs-template-variable">{{ markdown|markdown_to_html }}</span></code></pre>
<pre><code class="language-twig hljs twig" translate="no"><span class="hljs-template-tag">{% <span class="hljs-name"><span class="hljs-keyword">apply</span></span> markdown_to_html %}</span><span class="xml">
</span><span class="hljs-comment">{# Markdown here #}</span><span class="xml">
</span><span class="hljs-template-tag">{% <span class="hljs-name"><span class="hljs-keyword">endapply</span></span> %}</span></code></pre>
<p><em>Exemples :</em></p>
<pre><code class="language-twig hljs twig" translate="no"><span class="hljs-template-tag">{% <span class="hljs-name"><span class="hljs-keyword">set</span></span> markdown = '**This is bold text**' %}</span><span class="xml">
</span><span class="hljs-template-variable">{{ markdown|markdown_to_html }}</span></code></pre>
<pre><code class="language-twig hljs twig" translate="no"><span class="hljs-template-tag">{% <span class="hljs-name"><span class="hljs-keyword">apply</span></span> markdown_to_html %}</span><span class="xml">
**This is bold text**
</span><span class="hljs-template-tag">{% <span class="hljs-name"><span class="hljs-keyword">endapply</span></span> %}</span></code></pre>
<h2 id="toc">toc</h2>
<p>Extrait uniquement les en-têtes correspondant au <code translate="no">selectors</code> donné (h2, h3, etc.), ou à ceux définis dans la configuration <code translate="no">pages.body.toc</code> s'ils ne sont pas spécifiés.
Le paramètre <code translate="no">format</code> définit le format de sortie : <code translate="no">html</code> ou <code translate="no">json</code>.
Le paramètre <code translate="no">url</code> est utilisé pour créer des liens vers des titres.</p>
<pre><code class="language-twig hljs twig" translate="no"><span class="hljs-template-variable">{{ markdown|toc(format, selectors, url) }}</span></code></pre>
<p><em>Exemples :</em></p>
<pre><code class="language-twig hljs twig" translate="no"><span class="hljs-template-variable">{{ page.body|toc }}</span><span class="xml">
</span><span class="hljs-template-variable">{{ page.body|toc('html') }}</span><span class="xml">
</span><span class="hljs-template-variable">{{ page.body|toc(selectors=['h2']) }}</span><span class="xml">
</span><span class="hljs-template-variable">{{ page.body|toc(url=url(page)) }}</span></code></pre>
<h2 id="json-decode">json_decode</h2>
<p>Convertit une chaîne JSON en tableau.</p>
<pre><code class="language-twig hljs twig" translate="no"><span class="hljs-template-variable">{{ json|json_decode }}</span></code></pre>
<p><em>Exemple:</em></p>
<pre><code class="language-twig hljs twig" translate="no"><span class="hljs-template-tag">{% <span class="hljs-name"><span class="hljs-keyword">set</span></span> json = '{"foo": "bar"}' %}</span><span class="xml">
</span><span class="hljs-template-tag">{% <span class="hljs-name"><span class="hljs-keyword">set</span></span> array = json|json_decode %}</span><span class="xml">
</span><span class="hljs-template-variable">{{ array.foo }}</span></code></pre>
<h2 id="yaml-parse">yaml_parse</h2>
<p>Convertit une chaîne YAML en tableau.</p>
<pre><code class="language-twig hljs twig" translate="no"><span class="hljs-template-variable">{{ yaml|yaml_parse }}</span></code></pre>
<p><em>Exemple:</em></p>
<pre><code class="language-twig hljs twig" translate="no"><span class="hljs-template-tag">{% <span class="hljs-name"><span class="hljs-keyword">set</span></span> yaml = 'key: value' %}</span><span class="xml">
</span><span class="hljs-template-tag">{% <span class="hljs-name"><span class="hljs-keyword">set</span></span> array = yaml|yaml_parse %}</span><span class="xml">
</span><span class="hljs-template-variable">{{ array.key }}</span></code></pre>
<h2 id="slugify">slugify</h2>
<p>Convertit une chaîne en slug.</p>
<pre><code class="language-twig hljs twig" translate="no"><span class="hljs-template-variable">{{ string|slugify }}</span></code></pre>
<h2 id="u">u</h2>
<p>Le filtre <code translate="no">u</code> enveloppe un texte dans un objet Unicode (une <a href="https://symfony.com/doc/current/components/string.html" target="_blank" rel="noopener noreferrer">instance Symfony UnicodeString</a>) qui expose des méthodes pour « manipuler » la chaîne.</p>
<p><em>Exemple:</em></p>
<pre><code class="language-twig hljs twig" translate="no"><span class="hljs-template-variable">{{ 'cecil_string with twig'|u.camel.title }}</span></code></pre>
<blockquote>
<p>CecilStringAvecTwig</p>
</blockquote>
<h2 id="singular">singular</h2>
<p>Le filtre <code translate="no">singular</code> transforme un nom donné au pluriel en sa version singulière.</p>
<pre><code class="language-twig hljs twig" translate="no"><span class="hljs-template-variable">{{ string|singular(locale)}}</span></code></pre>
<p><em>Exemple:</em></p>
<pre><code class="language-twig hljs twig" translate="no"><span class="hljs-comment">{# English (en) rules are used by default #}</span><span class="xml">
</span><span class="hljs-template-variable">{{ 'partitions'|singular }}</span></code></pre>
<blockquote>
<p>partition</p>
</blockquote>
<pre><code class="language-twig hljs twig" translate="no"><span class="hljs-template-variable">{{ 'partitions'|singular('fr') }}</span></code></pre>
<blockquote>
<p>partition</p>
</blockquote>
<h2 id="plural">plural</h2>
<p>Le filtre <code translate="no">plural</code> transforme un nom donné au singulier en sa version plurielle.</p>
<pre><code class="language-twig hljs twig" translate="no"><span class="hljs-template-variable">{{ string|plural(locale)}}</span></code></pre>
<p><em>Exemple:</em></p>
<pre><code class="language-twig hljs twig" translate="no"><span class="hljs-comment">{# English (en) rules are used by default #}</span><span class="xml">
</span><span class="hljs-template-variable">{{ 'animal'|plural }}</span></code></pre>
<blockquote>
<p>animaux</p>
</blockquote>
<pre><code class="language-twig hljs twig" translate="no"><span class="hljs-template-variable">{{ 'animal'|plural('fr') }}</span></code></pre>
<blockquote>
<p>animaux</p>
</blockquote>
<h2 id="excerpt">excerpt</h2>
<p>Tronque une chaîne et ajoute un suffixe.</p>
<pre><code class="language-twig hljs twig" translate="no"><span class="hljs-template-variable">{{ string|excerpt(length, suffix) }}</span></code></pre>
<table>
<thead>
<tr>
<th>Options</th>
<th>Descriptif</th>
<th>Tapez</th>
<th>Par défaut</th>
</tr>
</thead>
<tbody>
<tr>
<td>longueur</td>
<td>Tronque après ce nombre de caractères.</td>
<td>entier</td>
<td>450</td>
</tr>
<tr>
<td>suffixe</td>
<td>Ajoute des caractères.</td>
<td>chaîne</td>
<td><code translate="no">…</code></td>
</tr>
</tbody>
</table>
<p><em>Exemples :</em></p>
<pre><code class="language-twig hljs twig" translate="no"><span class="hljs-template-variable">{{ variable|excerpt }}</span><span class="xml">
</span><span class="hljs-template-variable">{{ variable|excerpt(250, '...') }}</span></code></pre>
<h2 id="excerpt-html">excerpt_html</h2>
<p>Lit les caractères avant ou après la balise <code translate="no">&lt;!-- excerpt --&gt;</code> ou <code translate="no">&lt;!-- break --&gt;</code>.
Voir <a href="/fr/content/markdown/#extrait">Documentation de contenu</a> pour plus de détails.</p>
<pre><code class="language-twig hljs twig" translate="no"><span class="hljs-template-variable">{{ string|excerpt_html({separator, capture}) }}</span></code></pre>
<table>
<thead>
<tr>
<th>Options</th>
<th>Descriptif</th>
<th>Tapez</th>
<th>Par défaut</th>
</tr>
</thead>
<tbody>
<tr>
<td>séparateur</td>
<td>Chaîne à utiliser comme séparateur.</td>
<td>chaîne</td>
<td><code translate="no">excerpt|break</code></td>
</tr>
<tr>
<td>capturer</td>
<td>Pièce à capturer, <code translate="no">before</code> ou <code translate="no">after</code> le séparateur.</td>
<td>chaîne</td>
<td><code translate="no">before</code></td>
</tr>
</tbody>
</table>
<p><em>Exemples :</em></p>
<pre><code class="language-twig hljs twig" translate="no"><span class="hljs-template-variable">{{ variable|excerpt_html }}</span><span class="xml">
</span><span class="hljs-template-variable">{{ variable|excerpt_html({separator: 'excerpt|break', capture: 'before'}) }}</span><span class="xml">
</span><span class="hljs-template-variable">{{ variable|excerpt_html({capture: 'after'}) }}</span></code></pre>
<h2 id="highlight">highlight</h2>
<p>Met en surbrillance une chaîne de code avec <a href="https://github.com/scrivo/highlight.php" target="_blank" rel="noopener noreferrer">highlight.php</a>.</p>
<pre><code class="language-twig hljs twig" translate="no"><span class="hljs-template-variable">{{ code|highlight(language) }}</span></code></pre>
<p><em>Exemples :</em></p>
<pre><code class="language-twig hljs twig" translate="no"><span class="hljs-template-variable">{{ '&lt;?php echo $highlighted-&gt;value; ?&gt;'|highlight('php') }}</span></code></pre>
<h2 id="preg-split">preg_split</h2>
<p>Divise une chaîne en un tableau à l'aide d'une expression régulière.</p>
<pre><code class="language-twig hljs twig" translate="no"><span class="hljs-template-variable">{{ string|preg_split(pattern, limit) }}</span></code></pre>
<p><em>Exemple:</em></p>
<pre><code class="language-twig hljs twig" translate="no"><span class="hljs-template-tag">{% <span class="hljs-name"><span class="hljs-keyword">set</span></span> headers = page.content|preg_split('/&lt;br[^&gt;]*&gt;/') %}</span></code></pre>
<h2 id="preg-match-all">preg_match_all</h2>
<p>Effectue une correspondance d'expression régulière et renvoie le groupe pour toutes les correspondances.</p>
<pre><code class="language-twig hljs twig" translate="no"><span class="hljs-template-variable">{{ string|preg_match_all(pattern, group) }}</span></code></pre>
<p><em>Exemple:</em></p>
<pre><code class="language-twig hljs twig" translate="no"><span class="hljs-template-tag">{% <span class="hljs-name"><span class="hljs-keyword">set</span></span> tags = page.content|preg_match_all('/&lt;[^&gt;]+&gt;(.*)&lt;\/[^&gt;]+&gt;/') %}</span></code></pre>
<h2 id="hex-to-rgb">hex_to_rgb</h2>
<p>Convertit une couleur hexadécimale en RVB.</p>
<pre><code class="language-twig hljs twig" translate="no"><span class="hljs-template-variable">{{ color|hex_to_rgb }}</span></code></pre>]]>
    </content>
  </entry>
  <entry xml:lang="fr">
    <id>https://cecil.app/fr/documentation/templates/composants/</id>
    <title>Composants</title>
    <published>2026-05-26T00:00:00+00:00</published>
    <updated>2026-10-05T00:00:00+00:00</updated>
    <link href="https://cecil.app/fr/documentation/templates/composants/" rel="alternate" type="text/html" />
    <content type="html">
      <![CDATA[<h1>Composants</h1>
<p>Cecil fournit une logique de composants pour vous donner le pouvoir de créer des "unités" de templates réutilisables.</p>
<aside class="note note-info"><p>La fonctionnalité des composants est fournie par l'<a href="https://github.com/giorgiopogliani/twig-components" target="_blank" rel="noopener noreferrer"><em>extension de composants Twig</em></a> créée par Giorgio Pogliani.</p></aside>
<h2 id="syntaxe-des-composants">Syntaxe des composants</h2>
<p>Les composants ne sont que des templates Twig stockés dans le sous-répertoire <code translate="no">components/</code> et peuvent être utilisés n'importe où dans vos templates :</p>
<pre><code class="language-twig hljs twig" translate="no"><span class="hljs-comment">{# /components/button.twig #}</span><span class="xml">
<span class="hljs-tag">&lt;<span class="hljs-name">button</span> </span></span><span class="hljs-template-variable">{{ attributes.merge({class: 'rounded px-4'}) }}</span><span class="xml"><span class="hljs-tag">&gt;</span>
    </span><span class="hljs-template-variable">{{ slot }}</span><span class="xml">
<span class="hljs-tag">&lt;/<span class="hljs-name">button</span>&gt;</span></span></code></pre>
<blockquote>
<p>La variable slot correspond à tout contenu que vous ajouterez entre la balise d'ouverture et la balise de fermeture.</p>
</blockquote>
<p>Pour accéder à un composant vous devez utiliser la balise dédiée <code translate="no">x</code> suivie de <code translate="no">:</code> et du nom de fichier de votre composant sans extension :</p>
<pre><code class="language-twig hljs twig" translate="no"><span class="hljs-comment">{# /index.twig #}</span><span class="xml">
</span><span class="hljs-template-tag">{% <span class="hljs-name">x</span>:button with {class: 'text-white'} %}</span><span class="xml">
    <span class="hljs-tag">&lt;<span class="hljs-name">strong</span>&gt;</span>Click me<span class="hljs-tag">&lt;/<span class="hljs-name">strong</span>&gt;</span>
</span><span class="hljs-template-tag">{% <span class="hljs-name">endx</span> %}</span></code></pre>
<p>Il rendra :</p>
<pre><code class="language-twig hljs twig" translate="no"><span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">button</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"text-white rounded px-4"</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">strong</span>&gt;</span>Click me<span class="hljs-tag">&lt;/<span class="hljs-name">strong</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">button</span>&gt;</span></span></code></pre>]]>
    </content>
  </entry>
  <entry xml:lang="fr">
    <id>https://cecil.app/fr/documentation/templates/localisation/</id>
    <title>Localisation</title>
    <published>2026-05-26T00:00:00+00:00</published>
    <updated>2026-10-05T00:00:00+00:00</updated>
    <link href="https://cecil.app/fr/documentation/templates/localisation/" rel="alternate" type="text/html" />
    <content type="html">
      <![CDATA[<h1>Localisation</h1>
<p>Cecil prend en charge <a href="#traduction-de-texte">traduction du texte</a> et <a href="#localisation-de-la-date">localisation de la date</a>.</p>
<h2 id="traduction-de-texte">Traduction de texte</h2>
<p>Utilise le <code translate="no">trans</code> <em>tag</em> ou <em>filter</em> pour traduire des textes dans des templates.</p>
<pre><code class="language-twig hljs twig" translate="no"><span class="hljs-template-tag">{% <span class="hljs-name">trans</span> with variables into locale %}</span><span class="hljs-template-tag">{% <span class="hljs-name">endtrans</span> %}</span></code></pre>
<pre><code class="language-twig hljs twig" translate="no"><span class="hljs-template-variable">{{ message|trans(variables = []) }}</span></code></pre>
<h3 id="exemples">Exemples</h3>
<pre><code class="language-twig hljs twig" translate="no"><span class="hljs-template-tag">{% <span class="hljs-name">trans</span> %}</span><span class="xml">Hello World!</span><span class="hljs-template-tag">{% <span class="hljs-name">endtrans</span> %}</span></code></pre>
<pre><code class="language-twig hljs twig" translate="no"><span class="hljs-template-variable">{{ message|trans }}</span></code></pre>
<p>Inclure des variables :</p>
<pre><code class="language-twig hljs twig" translate="no"><span class="hljs-template-tag">{% <span class="hljs-name">trans</span> with {'%name%': 'Arnaud'} %}</span><span class="xml">Hello %name%!</span><span class="hljs-template-tag">{% <span class="hljs-name">endtrans</span> %}</span></code></pre>
<pre><code class="language-twig hljs twig" translate="no"><span class="hljs-template-variable">{{ message|trans({'%name%': 'Arnaud'}) }}</span></code></pre>
<p>Forcer les paramètres régionaux :</p>
<pre><code class="language-twig hljs twig" translate="no"><span class="hljs-template-tag">{% <span class="hljs-name">trans</span> into 'fr_FR' %}</span><span class="xml">Hello World!</span><span class="hljs-template-tag">{% <span class="hljs-name">endtrans</span> %}</span></code></pre>
<p>Pluraliser :</p>
<pre><code class="language-twig hljs twig" translate="no"><span class="hljs-template-tag">{% <span class="hljs-name">trans</span> with {'%count%': 42}%}</span><span class="xml">{0}I don't have apples|{1}I have one apple|]1,Inf[I have %count% apples</span><span class="hljs-template-tag">{% <span class="hljs-name">endtrans</span> %}</span></code></pre>
<h2 id="fichiers-de-traduction">Fichiers de traduction</h2>
<p>Les fichiers de traduction doivent être nommés <code translate="no">messages.&lt;locale&gt;.&lt;extension&gt;</code> et stockés dans le répertoire <a href="/fr/documentation/configuration/layouts/"><code translate="no">translations</code></a>.
Les extensions prises en charge sont définies pour chaque format de traduction dans <a href="/fr/documentation/configuration/layouts/#layouts-translations"><code translate="no">layouts.translations.formats</code></a>.</p>
<p>Le code locale (ex. : <code translate="no">fr_FR</code>) d'une langue est défini dans les entrées <a href="/fr/documentation/configuration/langues/#languages"><code translate="no">languages</code></a> de la configuration.</p>
<p><em>Exemple:</em></p>
<pre><code class="language-plaintext hljs plaintext" translate="no">&lt;mywebsite&gt;
└─ translations
   ├─ messages.fr_FR.mo   &lt;- Machine Object format
   └─ messages.fr_FR.yaml &lt;- Yaml format</code></pre>
<aside class="note note-info"><p>Vous pouvez facilement extraire les traductions de vos templates avec la commande suivante :</p>
<pre><code class="language-bash hljs bash" translate="no">php cecil.phar util:translations:extract --locale=&lt;code&gt; --show</code></pre>
<p>Utilisez <code translate="no">--save</code> à la place (ou en plus) de <code translate="no">--show</code> pour enregistrer les traductions dans un fichier. L'option <code translate="no">--locale</code> est obligatoire. Le format de sortie par défaut est <code translate="no">yaml</code> (utilisez <code translate="no">--format=po</code> pour le format gettext PO).</p></aside>
<aside class="note note-tip"><p><a href="https://poedit.net" target="_blank" rel="noopener noreferrer"><em>Poedit</em></a> est un éditeur de traduction simple et multiplateforme pour gettext (PO), et <a href="https://poedit.net/pro" target="_blank" rel="noopener noreferrer"><em>Poedit Pro</em></a> prend en charge l'extraction de chaînes de traduction à partir de templates prêts à l'emploi.</p></aside>
<aside class="note note-important"><p>Faites attention au <a href="/fr/documentation/templates/cache/">cache</a> lorsque vous mettez à jour les fichiers de traduction.</p>
<p>Le cache peut être vidé avec la commande suivante :</p>
<pre><code class="language-bash hljs bash" translate="no">php cecil.phar cache:clear:translations`</code></pre></aside>
<h2 id="localisation-de-la-date">Localisation de la date</h2>
<p>Utilise le filtre Twig <a href="https://twig.symfony.com/doc/3.x/filters/format_date.html" target="_blank" rel="noopener noreferrer"><code translate="no">format_date</code></a> pour localiser une date dans les templates.</p>
<pre><code class="language-twig hljs twig" translate="no"><span class="hljs-template-variable">{{ page.<span class="hljs-name">date</span>|format_date('long') }}</span><span class="xml">
</span><span class="hljs-comment">{# September 30, 2022 #}</span></code></pre>
<p>Les valeurs prises en charge sont : <code translate="no">short</code>, <code translate="no">medium</code>, <code translate="no">long</code> et <code translate="no">full</code>.</p>
<aside class="note note-important"><p>Si vous souhaitez utiliser le filtre <code translate="no">format_date</code> <strong>avec des paramètres régionaux autres que "en"</strong>, vous devez <a href="https://php.net/intl.setup" target="_blank" rel="noopener noreferrer">installer l'extension PHP internationale</a>.</p></aside>]]>
    </content>
  </entry>
  <entry xml:lang="fr">
    <id>https://cecil.app/fr/documentation/templates/cache/</id>
    <title>Cache</title>
    <published>2026-05-26T00:00:00+00:00</published>
    <updated>2026-10-05T00:00:00+00:00</updated>
    <link href="https://cecil.app/fr/documentation/templates/cache/" rel="alternate" type="text/html" />
    <content type="html">
      <![CDATA[<h1>Cache</h1>
<p>Cecil utilise un système de cache pour accélérer le processus de génération, il peut être désactivé ou effacé.</p>
<p>Il existe trois types de cache dans le cas du rendu des templates : les templates eux-mêmes, <a href="/fr/documentation/assets/#asset">assets</a> et <a href="/fr/documentation/templates/localisation/#fichiers-de-traduction">translations</a>.</p>
<h2 id="vider-le-cache">Vider le cache</h2>
<p>Vous pouvez vider le cache avec les commandes suivantes :</p>
<pre><code class="language-bash hljs bash" translate="no">php cecil.phar cache:clear               <span class="hljs-comment"># clear all caches</span>
php cecil.phar cache:clear:assets        <span class="hljs-comment"># clear assets cache</span>
php cecil.phar cache:clear:templates     <span class="hljs-comment"># clear templates cache</span>
php cecil.phar cache:clear:translations  <span class="hljs-comment"># clear translations cache</span></code></pre>
<aside class="note note-important"><p>En pratique, vous n'avez pas besoin de vider le cache manuellement, Cecil le fait pour vous en cas de besoin (par exemple lorsque des fichiers changent).</p></aside>
<h2 id="fragments-de-cache">Fragments de cache</h2>
<p>Cecil fournit un moyen de mettre en cache des parties du rendu des templates pour éviter de restituer plusieurs fois le même contenu partiel.</p>
<p>Pour utiliser les <em>fragments</em> de cache, vous devez envelopper le contenu que vous souhaitez mettre en cache avec la balise <a href="https://twig.symfony.com/doc/tags/cache.html" target="_blank" rel="noopener noreferrer"><code translate="no">cache</code></a>.</p>
<pre><code class="language-twig hljs twig" translate="no"><span class="hljs-template-tag">{% <span class="hljs-name">cache</span> 'unique-key' %}</span><span class="xml">
  </span><span class="hljs-comment">{# cacheable content #}</span><span class="xml">
</span><span class="hljs-template-tag">{% <span class="hljs-name">endcache</span> %}</span></code></pre>
<aside class="note note-tip"><p>Vous devez utiliser la fonction <a href="/fr/documentation/templates/reference/fonctions/#cache-key"><code translate="no">cache_key</code></a> pour être sûr d'avoir une clé de cache unique pour chaque contenu que vous souhaitez mettre en cache.</p></aside>
<aside class="note note-warning"><p>Les <em>fragments</em> de cache sont persistants, donc si la clé de cache est trop générique, vous risquez de vous retrouver avec un mauvais contenu affiché.</p></aside>
<p>Pour vider uniquement le cache des fragments, vous pouvez utiliser la commande suivante :</p>
<pre><code class="language-bash hljs bash" translate="no">php cecil.phar cache:clear:templates --fragments</code></pre>
<h2 id="desactiver-le-cache">Désactiver le cache</h2>
<p>Vous pouvez désactiver le cache avec la <a href="/fr/documentation/configuration/cache/">configuration</a>.</p>
<aside class="note note-warning"><p>La désactivation du cache peut ralentir le processus de génération, ce n'est donc pas recommandé.</p>
<p>Lors du développement local, si vous devez vider le cache avant chaque génération, vous pouvez utiliser l'option suivante :</p>
<pre><code class="language-bash hljs bash" translate="no">php cecil.phar serve --clear-cache          <span class="hljs-comment"># clear all caches</span>
php cecil.phar serve --clear-cache=&lt;regex&gt;  <span class="hljs-comment"># clear cache for cache key matches with the regular expression &lt;regex&gt;</span></code></pre>
<p>Exemple:</p>
<pre><code class="language-bash hljs bash" translate="no">php cecil.phar serve --clear-cache=css  <span class="hljs-comment"># clear cache for all CSS files</span></code></pre></aside>]]>
    </content>
  </entry>
  <entry xml:lang="fr">
    <id>https://cecil.app/fr/documentation/templates/etendre/</id>
    <title>Étendre</title>
    <published>2026-05-26T00:00:00+00:00</published>
    <updated>2026-10-05T00:00:00+00:00</updated>
    <link href="https://cecil.app/fr/documentation/templates/etendre/" rel="alternate" type="text/html" />
    <content type="html">
      <![CDATA[<h1>Étendre</h1>
<h2 id="fonctions-et-filtres">Fonctions et filtres</h2>
<p>Vous pouvez ajouter des <a href="/fr/documentation/templates/reference/fonctions/">fonctions</a> et des <a href="/fr/documentation/templates/reference/filtres/">filtres</a> personnalisés avec une <a href="/fr/documentation/developpeurs/etendre/#extension-twig"><strong><em>extension Twig</em></strong></a>.</p>
<h2 id="theme">Thème</h2>
<p>C'est simple de construire un thème, il suffit de créer un dossier <code translate="no">&lt;theme&gt;</code> avec la structure suivante (comme un site web mais sans pages) :</p>
<pre><code class="language-plaintext hljs plaintext" translate="no">&lt;mywebsite&gt;
└─ themes
   └─ &lt;theme&gt;
      ├─ config.yml
      ├─ assets
      ├─ layouts
      ├─ static
      └─ translations</code></pre>]]>
    </content>
  </entry>
</feed>
