<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="https://cecil.app/xsl/atom.xsl" media="all"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
  <id>https://cecil.app/documentation/content/</id>
  <title>Cecil - Content</title>
  <subtitle><![CDATA[Cecil is a command-line PHP application that merges Markdown pages, media and Twig templates to generate a static website.]]></subtitle>
  <link href="https://cecil.app/documentation/content/atom.xml" rel="self" type="application/atom+xml" />
  <link href="https://cecil.app/documentation/content/" rel="alternate" type="text/html" />
  <updated>2026-11-18T20:40:13+00:00</updated>
  <author>
    <name>Cecil</name>
    <uri>https://cecil.app</uri>
  </author>
  <entry xml:lang="en">
    <id>https://cecil.app/documentation/content/pages/</id>
    <title>Pages and sections</title>
    <published>2021-05-07T00:00:00+00:00</published>
    <updated>2026-10-16T00:00:00+00:00</updated>
    <link href="https://cecil.app/documentation/content/pages/" rel="alternate" type="text/html" />
    <content type="html">
      <![CDATA[<h1>Pages and sections</h1>
<p>A page is a file made up of a <a href="#front-matter"><strong>front matter</strong></a> and a <a href="#body"><strong>body</strong></a>.</p>
<aside class="note note-info"><p>Pages are files stored in the <code translate="no">pages/</code> directory, with one of the following extensions: <code translate="no">md</code>, <code translate="no">markdown</code>, <code translate="no">mdown</code>, <code translate="no">mkdn</code>, <code translate="no">mkd</code>, <code translate="no">text</code> or <code translate="no">txt</code> (see <a href="/documentation/configuration/pages/#pages-ext"><code translate="no">pages.ext</code></a>).</p>
<p>A <code translate="no">README.md</code> file is handled as an <code translate="no">index.md</code> file (e.g.: <code translate="no">blog/README.md</code> is the index of the <code translate="no">blog</code> <em>Section</em>).</p></aside>
<h2 id="front-matter">Front matter<a class="heading-anchor" href="#front-matter" aria-hidden="true" tabindex="-1"></a></h2>
<p>The <em>front matter</em> is a collection of <a href="/documentation/content/front-matter/">variables</a> (in <em>key/value</em> format) surrounded by <code translate="no">---</code>.</p>
<p><em>Example:</em></p>
<pre data-lang="yaml"><code class="language-yaml hljs yaml" translate="no"><span class="hljs-meta">---</span>
<span class="hljs-attr">title:</span> <span class="hljs-string">"The title"</span>
<span class="hljs-attr">date:</span> <span class="hljs-number">2019</span><span class="hljs-number">-02</span><span class="hljs-number">-21</span>
<span class="hljs-attr">tags:</span> <span class="hljs-string">[tag</span> <span class="hljs-number">1</span><span class="hljs-string">,</span> <span class="hljs-string">tag</span> <span class="hljs-number">2</span><span class="hljs-string">]</span>
<span class="hljs-attr">customvar:</span> <span class="hljs-string">"Value of customvar"</span>
<span class="hljs-meta">---</span></code></pre>
<aside class="note note-info"><p>You can also use <code translate="no">&lt;!-- --&gt;</code> or <code translate="no">+++</code> as separator.</p></aside>
<h2 id="body">Body<a class="heading-anchor" href="#body" aria-hidden="true" tabindex="-1"></a></h2>
<p>The <em>body</em> is the main content of a page; it can be written in <a href="/documentation/content/markdown/">Markdown</a> or in plain text.</p>
<p><em>Example:</em></p>
<pre data-lang="markdown"><code class="language-markdown hljs markdown" translate="no"><span class="hljs-section"># Header</span>

[toc]

<span class="hljs-section">## Sub-Header 1</span>

Lorem ipsum dolor [<span class="hljs-string">sit amet</span>](<span class="hljs-link">https://example.com</span>), consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
<span class="xml"><span class="hljs-comment">&lt;!-- excerpt --&gt;</span></span>
Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.

<span class="hljs-section">## Sub-Header 2</span>

![<span class="hljs-string">Description</span>](<span class="hljs-link">/image.jpg "Title"</span>)

<span class="hljs-section">## Sub-Header 3</span>

:::tip
This is advice.
:::</code></pre>
<h2 id="file-prefix">File prefix<a class="heading-anchor" href="#file-prefix" aria-hidden="true" tabindex="-1"></a></h2>
<p>The filename can contain a prefix to define <code translate="no">date</code> or <code translate="no">weight</code> variables of the page (used by <a href="/documentation/templates/reference/sorts/#sort-by-date"><code translate="no">sortby</code></a>).</p>
<aside class="note note-info"><p>Default prefix separators: <code translate="no">_</code> and <code translate="no">-</code>.</p>
<p>You can customize them with the <a href="/documentation/configuration/pages/#pages-prefix-separator"><code translate="no">pages.prefix.separator</code></a> option.</p></aside>
<h3 id="date">date<a class="heading-anchor" href="#date" aria-hidden="true" tabindex="-1"></a></h3>
<p>The <em>date prefix</em> is used to set the <code translate="no">date</code> of the page, and must be a valid date format (i.e.: <code translate="no">YYYY-MM-DD</code>).</p>
<p><em>Example:</em></p>
<p>In <code translate="no">2019-04-23_My blog post.md</code>:</p>
<ul>
<li>the prefix is <code translate="no">2019-04-23</code></li>
<li>the <code translate="no">date</code> of the page is <code translate="no">2019-04-23</code></li>
<li>the <code translate="no">title</code> of the page is <code translate="no">My blog post</code></li>
</ul>
<h3 id="weight">weight<a class="heading-anchor" href="#weight" aria-hidden="true" tabindex="-1"></a></h3>
<p>The <em>weight prefix</em> is used to set the sort order of the page, and must be a valid integer value.</p>
<p><em>Example:</em></p>
<p>In <code translate="no">1_The first project.md</code>:</p>
<ul>
<li>the prefix is <code translate="no">1</code></li>
<li>the <code translate="no">weight</code> of the page is <code translate="no">1</code></li>
<li>the <code translate="no">title</code> of the page is <code translate="no">The first project</code></li>
</ul>
<h2 id="section">Section<a class="heading-anchor" href="#section" aria-hidden="true" tabindex="-1"></a></h2>
<p>Some dedicated variables can be used in a custom <em>Section</em> (i.e.: <code translate="no">&lt;section&gt;/index.md</code>).</p>
<h3 id="sortby">sortby<a class="heading-anchor" href="#sortby" aria-hidden="true" tabindex="-1"></a></h3>
<p>The order of pages in a <em>Section</em> can be changed.</p>
<p>Available values are:</p>
<ul>
<li><code translate="no">date</code>: more recent first</li>
<li><code translate="no">updated</code>: more recently updated first</li>
<li><code translate="no">title</code>: alphabetic order</li>
<li><code translate="no">weight</code>: lightest first</li>
</ul>
<p><em>Example:</em></p>
<pre data-lang="yaml"><code class="language-yaml hljs yaml" translate="no"><span class="hljs-meta">---</span>
<span class="hljs-attr">sortby:</span> <span class="hljs-string">title</span>
<span class="hljs-meta">---</span></code></pre>
<p><strong>More options:</strong></p>
<pre data-lang="yaml"><code class="language-yaml hljs yaml" translate="no"><span class="hljs-meta">---</span>
<span class="hljs-attr">sortby:</span>
  <span class="hljs-attr">variable:</span> <span class="hljs-string">date</span>    <span class="hljs-comment"># "date", "updated", "title" or "weight"</span>
  <span class="hljs-attr">desc_title:</span> <span class="hljs-literal">false</span> <span class="hljs-comment"># used with "date" or "updated" variable value to sort by desc title order if items have the same date</span>
  <span class="hljs-attr">reverse:</span> <span class="hljs-literal">false</span>    <span class="hljs-comment"># reversed if true</span>
<span class="hljs-meta">---</span></code></pre>
<h3 id="pagination">pagination<a class="heading-anchor" href="#pagination" aria-hidden="true" tabindex="-1"></a></h3>
<p>The global <a href="/documentation/configuration/pages/#pages-pagination">pagination configuration</a> is used by default, but you can change it for a specific <em>Section</em>.</p>
<p><em>Example:</em></p>
<pre data-lang="yaml"><code class="language-yaml hljs yaml" translate="no"><span class="hljs-meta">---</span>
<span class="hljs-attr">pagination:</span>
  <span class="hljs-attr">max:</span> <span class="hljs-number">5</span>
  <span class="hljs-attr">path:</span> <span class="hljs-string">"page"</span>
<span class="hljs-meta">---</span></code></pre>
<p>Pagination can be disabled for a <em>Section</em>:</p>
<pre data-lang="yaml"><code class="language-yaml hljs yaml" translate="no"><span class="hljs-meta">---</span>
<span class="hljs-attr">pagination:</span> <span class="hljs-literal">false</span>
<span class="hljs-meta">---</span></code></pre>
<p>If pagination is <a href="/documentation/configuration/pages/#disable-pagination">disabled globally</a>, it can be enabled for a <em>Section</em> (<code translate="no">max</code> and <code translate="no">path</code> default to the global configuration):</p>
<pre data-lang="yaml"><code class="language-yaml hljs yaml" translate="no"><span class="hljs-meta">---</span>
<span class="hljs-attr">pagination:</span>
  <span class="hljs-attr">enabled:</span> <span class="hljs-literal">true</span>
  <span class="hljs-attr">max:</span> <span class="hljs-number">5</span>
<span class="hljs-meta">---</span></code></pre>
<h3 id="cascade">cascade<a class="heading-anchor" href="#cascade" aria-hidden="true" tabindex="-1"></a></h3>
<p>Any variables in <code translate="no">cascade</code> are added to the front matter of all pages of the <em>Section</em> (including pages of its <a href="#sub-section">sub-sections</a>).</p>
<p><em>Example:</em></p>
<pre data-lang="yaml"><code class="language-yaml hljs yaml" translate="no"><span class="hljs-meta">---</span>
<span class="hljs-attr">cascade:</span>
  <span class="hljs-attr">banner:</span> <span class="hljs-string">image.jpg</span>
<span class="hljs-meta">---</span></code></pre>
<aside class="note note-info"><p>Existing variables are not overridden.</p></aside>
<h3 id="circular">circular<a class="heading-anchor" href="#circular" aria-hidden="true" tabindex="-1"></a></h3>
<p>Set <code translate="no">circular</code> to <code translate="no">true</code> to enable circular navigation with <a href="/documentation/templates/variables/#page-prev-next"><em>page.&lt;prev/next&gt;</em></a>.</p>
<aside class="note note-info"><p>With <a href="#sub-section">sub-sections</a>, only the <code translate="no">circular</code> value of the top level <em>Section</em> is used.</p></aside>
<p><em>Example:</em></p>
<pre data-lang="yaml"><code class="language-yaml hljs yaml" translate="no"><span class="hljs-meta">---</span>
<span class="hljs-attr">circular:</span> <span class="hljs-literal">true</span>
<span class="hljs-meta">---</span></code></pre>
<h3 id="sub-section">Sub-section<a class="heading-anchor" href="#sub-section" aria-hidden="true" tabindex="-1"></a></h3>
<p>A nested folder that explicitly contains an <code translate="no">index.md</code> file is turned into a <em>sub-section</em> of its parent <em>Section</em>.</p>
<pre data-lang="plaintext"><code class="language-plaintext hljs plaintext" translate="no">&lt;mywebsite&gt;
└─ pages
   └─ blog                 &lt;- Section
      ├─ index.md
      ├─ post-1.md         &lt;- Page in Section "blog"
      └─ 2024              &lt;- Sub-section (contains an "index.md")
         ├─ index.md
         └─ post-2.md      &lt;- Page in Section "blog" *and* sub-section "blog/2024"</code></pre>
<p>A <em>sub-section</em>:</p>
<ul>
<li>is a <em>Section</em> (same type, variables and <a href="/documentation/templates/lookup-rules/#type-section">layout</a> resolution) available at its own URL (e.g.: <code translate="no">/blog/2024/</code>)</li>
<li>is rendered with the layouts of its parent <em>Sections</em> if it doesn't have its own (e.g.: <code translate="no">blog/list.html.twig</code>)</li>
<li>can be nested at any depth (e.g.: <code translate="no">blog/2024/06/</code>)</li>
<li>lists its own pages, and its pages also belong to each of their parent <em>Sections</em></li>
<li>is <strong>not</strong> listed in its parent <em>Section</em></li>
<li>is placed in the <a href="/documentation/templates/variables/#page-prev-next"><em>page.&lt;prev/next&gt;</em></a> navigation of its parent <em>Section</em> (according to its <code translate="no">sortby</code>), followed by its own pages</li>
</ul>
<aside class="note note-info"><p>A nested folder <strong>without</strong> an <code translate="no">index.md</code> file is not a <em>sub-section</em>: its pages simply belong to the parent <em>Section</em>.</p></aside>
<h2 id="home-page">Home page<a class="heading-anchor" href="#home-page" aria-hidden="true" tabindex="-1"></a></h2>
<p>The <em>Home page</em> is the <code translate="no">pages/index.md</code> file.</p>
<p>Like any other <em>Section</em>, the <em>Home page</em> supports <code translate="no">sortby</code> and <code translate="no">pagination</code> configuration.</p>
<h3 id="pagesfrom">pagesfrom<a class="heading-anchor" href="#pagesfrom" aria-hidden="true" tabindex="-1"></a></h3>
<p>Set a valid <em>Section</em> name in <code translate="no">pagesfrom</code> to use pages collection from this <em>Section</em> in <em>Home page</em>.</p>
<p><em>Example:</em></p>
<pre data-lang="yaml"><code class="language-yaml hljs yaml" translate="no"><span class="hljs-meta">---</span>
<span class="hljs-attr">pagesfrom:</span> <span class="hljs-string">blog</span>
<span class="hljs-meta">---</span></code></pre>]]>
    </content>
  </entry>
  <entry xml:lang="en">
    <id>https://cecil.app/documentation/content/front-matter/</id>
    <title>Front matter</title>
    <published>2021-05-07T00:00:00+00:00</published>
    <updated>2026-11-14T00:00:00+00:00</updated>
    <link href="https://cecil.app/documentation/content/front-matter/" rel="alternate" type="text/html" />
    <content type="html">
      <![CDATA[<h1>Front matter</h1>
<p>The <em>front matter</em> can contain custom variables applied to the current page.</p>
<p>It must be the first thing in the file and must be valid <a href="https://en.wikipedia.org/wiki/YAML" target="_blank" rel="noopener noreferrer">YAML</a>.</p>
<aside class="note note-info"><p>YAML is the default format: you can use INI, TOML or JSON instead with the <a href="/documentation/configuration/pages/#pages-frontmatter"><code translate="no">pages.frontmatter</code></a> option.</p></aside>
<aside class="note note-tip"><p>The front matter is validated: the types of predefined variables are checked, and you can declare your own rules (required variables, types, allowed values, default values, etc.) by section or by page with the <a href="/documentation/configuration/pages/#pages-schema"><code translate="no">pages.schema</code></a> option.</p></aside>
<h2 id="predefined-variables">Predefined variables<a class="heading-anchor" href="#predefined-variables" aria-hidden="true" tabindex="-1"></a></h2>
<table>
<thead>
<tr>
<th>Variable</th>
<th>Description</th>
<th>Default value</th>
<th>Example</th>
</tr>
</thead>
<tbody>
<tr>
<td><code translate="no">title</code></td>
<td>Title</td>
<td>File name without extension, prefix and language suffix.</td>
<td><code translate="no">Post 1</code></td>
</tr>
<tr>
<td><code translate="no">layout</code></td>
<td>Template</td>
<td>See <a href="/documentation/templates/lookup-rules/#lookup-rules"><em>Lookup rules</em></a>.</td>
<td><code translate="no">404</code></td>
</tr>
<tr>
<td><code translate="no">date</code></td>
<td>Creation date</td>
<td>File modification date (PHP <em>DateTime</em> object).</td>
<td><code translate="no">2019-04-15</code></td>
</tr>
<tr>
<td><code translate="no">section</code></td>
<td>Section</td>
<td>Page's <em>Section</em>.</td>
<td><code translate="no">blog</code></td>
</tr>
<tr>
<td><code translate="no">path</code></td>
<td>Path</td>
<td>Page's <em>path</em>.</td>
<td><code translate="no">blog/post-1</code></td>
</tr>
<tr>
<td><code translate="no">slug</code></td>
<td>Slug</td>
<td>Page's <em>slug</em>.</td>
<td><code translate="no">post-1</code></td>
</tr>
<tr>
<td><code translate="no">weight</code></td>
<td>Sort order</td>
<td>File <a href="/documentation/content/pages/#weight">weight prefix</a>, if any.</td>
<td><code translate="no">10</code></td>
</tr>
<tr>
<td><code translate="no">language</code></td>
<td>Language code</td>
<td>File language suffix, or the main <a href="/documentation/configuration/languages/#language">language</a>.</td>
<td><code translate="no">fr</code></td>
</tr>
<tr>
<td><code translate="no">langref</code></td>
<td>Translations reference</td>
<td>Page's <em>path</em> (without language).</td>
<td><code translate="no">blog/post-1</code></td>
</tr>
<tr>
<td><code translate="no">published</code></td>
<td>Published or not</td>
<td><code translate="no">true</code>.</td>
<td><code translate="no">false</code></td>
</tr>
<tr>
<td><code translate="no">draft</code></td>
<td>Draft or not</td>
<td><code translate="no">false</code>.</td>
<td><code translate="no">true</code></td>
</tr>
</tbody>
</table>
<aside class="note note-info"><p>All the predefined variables can be overridden except <code translate="no">section</code>.</p></aside>
<aside class="note note-important"><p>The values of <code translate="no">path</code> and <code translate="no">slug</code> must already be slugified (e.g.: <code translate="no">my-post</code>, not <code translate="no">My Post</code>), otherwise the build fails.</p></aside>
<aside class="note note-tip"><p><code translate="no">draft: true</code> is the same as <code translate="no">published: false</code>. Unpublished pages can be previewed with the <code translate="no">--drafts</code> option of the <a href="/documentation/commands/build/"><code translate="no">build</code></a> and <a href="/documentation/commands/serve/"><code translate="no">serve</code></a> commands.</p></aside>
<h2 id="updated">updated<a class="heading-anchor" href="#updated" aria-hidden="true" tabindex="-1"></a></h2>
<p>The <code translate="no">updated</code> variable is used to define the last modification date of a page.</p>
<p><em>Example:</em></p>
<pre data-lang="yaml"><code class="language-yaml hljs yaml" translate="no"><span class="hljs-meta">---</span>
<span class="hljs-attr">updated:</span> <span class="hljs-number">2026</span><span class="hljs-number">-02</span><span class="hljs-number">-02</span>
<span class="hljs-meta">---</span></code></pre>
<aside class="note note-info"><p><code translate="no">lastmod</code> is an alias of <code translate="no">updated</code>.</p></aside>
<aside class="note note-warning"><p>Before version 8.80.1, the <code translate="no">updated</code> variable was a predefined variable. It is now an optional variable (and must be defined in the front matter to be used).</p></aside>
<h2 id="menu">menu<a class="heading-anchor" href="#menu" aria-hidden="true" tabindex="-1"></a></h2>
<p>A page can be added to a <a href="/documentation/configuration/site/#menus">menu</a>.</p>
<p>The entry name is the page <code translate="no">title</code> and the URL is the page <code translate="no">path</code>.</p>
<p>The same page can be added to multiple menus, and each entry's position can be set with the <code translate="no">weight</code> key (lowest first). The <code translate="no">name</code> key can be used to override the default entry name per menu.</p>
<p><em>Examples:</em></p>
<pre data-lang="yaml"><code class="language-yaml hljs yaml" translate="no"><span class="hljs-meta">---</span>
<span class="hljs-attr">menu:</span> <span class="hljs-string">main</span>
<span class="hljs-meta">---</span></code></pre>
<pre data-lang="yaml"><code class="language-yaml hljs yaml" translate="no"><span class="hljs-meta">---</span>
<span class="hljs-attr">menu:</span> <span class="hljs-string">[main,</span> <span class="hljs-string">navigation]</span> <span class="hljs-comment"># same page in multiple menus</span>
<span class="hljs-meta">---</span></code></pre>
<pre data-lang="yaml"><code class="language-yaml hljs yaml" translate="no"><span class="hljs-meta">---</span>
<span class="hljs-attr">menu:</span>
  <span class="hljs-attr">main:</span>
    <span class="hljs-attr">weight:</span> <span class="hljs-number">10</span>
  <span class="hljs-attr">navigation:</span>
    <span class="hljs-attr">weight:</span> <span class="hljs-number">20</span>
<span class="hljs-meta">---</span></code></pre>
<pre data-lang="yaml"><code class="language-yaml hljs yaml" translate="no"><span class="hljs-meta">---</span>
<span class="hljs-attr">title:</span> <span class="hljs-string">'Our Expertise'</span>
<span class="hljs-attr">menu:</span>
  <span class="hljs-attr">main:</span>
    <span class="hljs-attr">weight:</span> <span class="hljs-number">15</span>
  <span class="hljs-attr">footer:</span>
    <span class="hljs-attr">weight:</span> <span class="hljs-number">15</span>
    <span class="hljs-attr">name:</span> <span class="hljs-string">"Expertise"</span> <span class="hljs-comment"># override the entry name in this menu</span>
<span class="hljs-meta">---</span></code></pre>
<h2 id="taxonomy">Taxonomy<a class="heading-anchor" href="#taxonomy" aria-hidden="true" tabindex="-1"></a></h2>
<p>Taxonomy allows you to connect, relate and classify your website’s content.<br>
In Cecil, these terms are gathered within vocabularies.</p>
<p>Vocabularies are declared in the <a href="/documentation/configuration/site/#taxonomies"><em>Configuration</em></a>.</p>
<dl>
<dt>Vocabulary</dt>
<dd>A categorization of content (e.g.: <code translate="no">tags</code>, <code translate="no">categories</code>, etc.).</dd>
<dt>Term</dt>
<dd>A term is an item of a vocabulary (e.g.: <code translate="no">Development</code>, <code translate="no">PHP</code>, etc.).</dd>
</dl>
<p><em>Example:</em></p>
<pre data-lang="yaml"><code class="language-yaml hljs yaml" translate="no"><span class="hljs-meta">---</span>
<span class="hljs-attr">tags:</span> <span class="hljs-string">["Development",</span> <span class="hljs-string">"PHP"</span><span class="hljs-string">]</span>
<span class="hljs-meta">---</span></code></pre>
<p>Cecil then generates, for each vocabulary:</p>
<ul>
<li>a page listing its terms, e.g.: <code translate="no">/tags/</code></li>
<li>a page per term listing its pages, e.g.: <code translate="no">/tags/development/</code> and <code translate="no">/tags/php/</code></li>
</ul>
<p>See <a href="/documentation/templates/lookup-rules/#type-vocabulary">templates lookup rules</a> and <a href="/documentation/templates/variables/#taxonomy">taxonomy variables</a> to customize those pages.</p>
<h2 id="schedule">Schedule<a class="heading-anchor" href="#schedule" aria-hidden="true" tabindex="-1"></a></h2>
<p>Schedules pages’ publication.</p>
<p><em>Example:</em></p>
<p>The page is published from 2023-02-07 (if the current date is &gt;= 2023-02-07):</p>
<pre data-lang="yaml"><code class="language-yaml hljs yaml" translate="no"><span class="hljs-meta">---</span>
<span class="hljs-attr">schedule:</span>
  <span class="hljs-attr">publish:</span> <span class="hljs-number">2023</span><span class="hljs-number">-02</span><span class="hljs-number">-07</span>
<span class="hljs-meta">---</span></code></pre>
<p>The page is published until 2022-04-28 (if the current date is &lt; 2022-04-28, i.e. before midnight):</p>
<pre data-lang="yaml"><code class="language-yaml hljs yaml" translate="no"><span class="hljs-meta">---</span>
<span class="hljs-attr">schedule:</span>
  <span class="hljs-attr">expiry:</span> <span class="hljs-number">2022</span><span class="hljs-number">-04</span><span class="hljs-number">-28</span>
<span class="hljs-meta">---</span></code></pre>
<p>Both can be combined: the page is published if the <code translate="no">publish</code> date is reached <strong>and</strong> the <code translate="no">expiry</code> date is not passed.</p>
<h2 id="redirect">redirect<a class="heading-anchor" href="#redirect" aria-hidden="true" tabindex="-1"></a></h2>
<p>As indicated by its name, the <code translate="no">redirect</code> variable is used to redirect a page to a dedicated URL.</p>
<p><em>Example:</em></p>
<pre data-lang="yaml"><code class="language-yaml hljs yaml" translate="no"><span class="hljs-meta">---</span>
<span class="hljs-attr">redirect:</span> <span class="hljs-string">"https://arnaudligny.fr"</span>
<span class="hljs-meta">---</span></code></pre>
<aside class="note note-info"><p>Redirect works with the <a href="https://github.com/Cecilapp/Cecil/blob/main/resources/layouts/_default/redirect.html.twig" target="_blank" rel="noopener noreferrer"><code translate="no">redirect.html.twig</code></a> template.</p></aside>
<h2 id="alias">alias<a class="heading-anchor" href="#alias" aria-hidden="true" tabindex="-1"></a></h2>
<p>An alias is a redirection to the current page.</p>
<p><em>Example:</em></p>
<pre data-lang="yaml"><code class="language-yaml hljs yaml" translate="no"><span class="hljs-meta">---</span>
<span class="hljs-attr">title:</span> <span class="hljs-string">"About"</span>
<span class="hljs-attr">alias:</span>
  <span class="hljs-bullet">-</span> <span class="hljs-string">contact</span>
<span class="hljs-meta">---</span></code></pre>
<p>In the previous example <code translate="no">contact/</code> redirects to <code translate="no">about/</code>.</p>
<aside class="note note-info"><p><code translate="no">aliases</code> is still supported for backward compatibility.</p></aside>
<h2 id="output">output<a class="heading-anchor" href="#output" aria-hidden="true" tabindex="-1"></a></h2>
<p>Defines the output format of the page.</p>
<p>Available formats are: <code translate="no">html</code>, <code translate="no">atom</code>, <code translate="no">rss</code>, <code translate="no">json</code>, <code translate="no">xml</code>, etc.<br>
You can define one or more formats in an array.</p>
<p>It’s not required to define an output format, but if you do, it must be one of the available formats defined in the <a href="/documentation/configuration/output/#output-formats"><em>Configuration</em></a>.</p>
<p><em>Example:</em></p>
<pre data-lang="yaml"><code class="language-yaml hljs yaml" translate="no"><span class="hljs-meta">---</span>
<span class="hljs-attr">output:</span> <span class="hljs-string">[html,</span> <span class="hljs-string">atom]</span>
<span class="hljs-meta">---</span></code></pre>
<h2 id="uglyurl">uglyurl<a class="heading-anchor" href="#uglyurl" aria-hidden="true" tabindex="-1"></a></h2>
<p>Set <code translate="no">uglyurl</code> to <code translate="no">true</code> to publish the page as a file named after its path (e.g.: <code translate="no">blog/post-1.html</code>) instead of an <code translate="no">index.html</code> file in a folder (e.g.: <code translate="no">blog/post-1/index.html</code>).</p>
<p><em>Example:</em></p>
<pre data-lang="yaml"><code class="language-yaml hljs yaml" translate="no"><span class="hljs-meta">---</span>
<span class="hljs-attr">uglyurl:</span> <span class="hljs-literal">true</span>
<span class="hljs-meta">---</span></code></pre>
<h2 id="external">external<a class="heading-anchor" href="#external" aria-hidden="true" tabindex="-1"></a></h2>
<p>A page with an <code translate="no">external</code> variable tries to fetch the content of the pointed resource, and uses it as the page body.</p>
<p><em>Example:</em></p>
<pre data-lang="yaml"><code class="language-yaml hljs yaml" translate="no"><span class="hljs-meta">---</span>
<span class="hljs-attr">external:</span> <span class="hljs-string">"https://raw.githubusercontent.com/Cecilapp/Cecil/main/README.md"</span>
<span class="hljs-meta">---</span></code></pre>
<h2 id="excluded">excluded<a class="heading-anchor" href="#excluded" aria-hidden="true" tabindex="-1"></a></h2>
<p>Set <code translate="no">excluded</code> to <code translate="no">true</code> to hide a page from list pages (e.g.: <em>Home page</em>, <em>Section</em>, <em>Sitemap</em>, etc.).</p>
<p><em>Example:</em></p>
<pre data-lang="yaml"><code class="language-yaml hljs yaml" translate="no"><span class="hljs-meta">---</span>
<span class="hljs-attr">excluded:</span> <span class="hljs-literal">true</span>
<span class="hljs-meta">---</span></code></pre>
<aside class="note note-info"><p><code translate="no">excluded</code> is different from <a href="#predefined-variables"><code translate="no">published</code></a>: an excluded page is published but hidden from list pages.</p></aside>
<aside class="note note-warning"><p>Since version 8.49.0, the previous <code translate="no">exclude</code> variable has been renamed <code translate="no">excluded</code> (<code translate="no">exclude</code> is still supported for backward compatibility).</p></aside>]]>
    </content>
  </entry>
  <entry xml:lang="en">
    <id>https://cecil.app/documentation/content/markdown/</id>
    <title>Markdown</title>
    <published>2021-05-07T00:00:00+00:00</published>
    <updated>2026-10-24T00:00:00+00:00</updated>
    <link href="https://cecil.app/documentation/content/markdown/" rel="alternate" type="text/html" />
    <content type="html">
      <![CDATA[<h1>Markdown</h1>
<p>Cecil supports <a href="https://daringfireball.net/projects/markdown/syntax" target="_blank" rel="noopener noreferrer">Markdown</a> format, but also <a href="https://michelf.ca/projects/php-markdown/extra/" target="_blank" rel="noopener noreferrer">Markdown Extra</a>.</p>
<p>Cecil also provides <strong>extra features</strong> to enhance your content, see below.</p>
<h2 id="attributes">Attributes<a class="heading-anchor" href="#attributes" aria-hidden="true" tabindex="-1"></a></h2>
<p>With <a href="https://michelf.ca/projects/php-markdown/extra/" target="_blank" rel="noopener noreferrer">Markdown Extra</a> you can set an id, class and custom attributes on certain elements using an attribute block.<br>
For instance, put the desired attribute(s) after a heading, a fenced code block, a link or an image at the end of the line inside curly brackets, like this:</p>
<pre data-lang="markdown"><code class="language-markdown hljs markdown" translate="no"><span class="hljs-section">## Header {#id .class attribute=value}</span></code></pre>
<aside class="note note-warning"><p>For an inline element, like a link, you must use a line break after the closing brace:</p>
<pre data-lang="markdown"><code class="language-markdown hljs markdown" translate="no">Lorem ipsum [<span class="hljs-string">dolor</span>](<span class="hljs-link">url</span>){attribute=value} 
sit amet.</code></pre></aside>
<h2 id="links">Links<a class="heading-anchor" href="#links" aria-hidden="true" tabindex="-1"></a></h2>
<p>You can create a link with the syntax <code translate="no">[Text](url)</code>, where <code translate="no">url</code> can be a path, a relative path to a Markdown file, an external URL, etc.</p>
<p><em>Example:</em></p>
<pre data-lang="markdown"><code class="language-markdown hljs markdown" translate="no">[<span class="hljs-string">Link to a path</span>](<span class="hljs-link">/about/</span>)
[<span class="hljs-string">Link to a Markdown file</span>](<span class="hljs-link">about.md</span>)
[<span class="hljs-string">Link to Cecil website</span>](<span class="hljs-link">https://cecil.app</span>)</code></pre>
<aside class="note note-info"><p>A relative link to a Markdown file is resolved from the folder of the current file (as on GitHub), then replaced by the URL of the targeted page.</p></aside>
<h3 id="link-to-a-page">Link to a page<a class="heading-anchor" href="#link-to-a-page" aria-hidden="true" tabindex="-1"></a></h3>
<p>You can easily create a link to a page with the syntax <code translate="no">[Page title](page:page-id)</code>.</p>
<p><em>Example:</em></p>
<pre data-lang="markdown"><code class="language-markdown hljs markdown" translate="no">[<span class="hljs-string">Link to a blog post</span>](<span class="hljs-link">page:blog/post-1</span>)</code></pre>
<h3 id="external">External<a class="heading-anchor" href="#external" aria-hidden="true" tabindex="-1"></a></h3>
<p>By default external links have the following value for <code translate="no">rel</code> attribute: <code translate="no">noopener noreferrer</code>.</p>
<aside class="note note-info"><p>A link is considered external if its URL starts with <code translate="no">http</code> but not with the <a href="/documentation/configuration/site/#baseurl"><code translate="no">baseurl</code></a>: <code translate="no">baseurl</code> must be defined.</p></aside>
<p><em>Example:</em></p>
<pre data-lang="html"><code class="language-html hljs xml" translate="no"><span class="hljs-tag">&lt;<span class="hljs-name">a</span> <span class="hljs-attr">href</span>=<span class="hljs-string">"&lt;url&gt;"</span> <span class="hljs-attr">rel</span>=<span class="hljs-string">"noopener noreferrer"</span>&gt;</span>Link to another website<span class="hljs-tag">&lt;/<span class="hljs-name">a</span>&gt;</span></code></pre>
<p>You can change this behavior with <a href="/documentation/configuration/pages/#pages-body-links"><code translate="no">pages.body.links.external</code> options</a>.</p>
<h3 id="embedded-links">Embedded links<a class="heading-anchor" href="#embedded-links" aria-hidden="true" tabindex="-1"></a></h3>
<p>Cecil can try to turn a link into embedded content by using the <code translate="no">{embed}</code> attribute or by setting the global configuration option <code translate="no">pages.body.links.embed.enabled</code> to <code translate="no">true</code>.</p>
<aside class="note note-important"><p>Only <strong>YouTube</strong>, <strong>Vimeo</strong>, <strong>Dailymotion</strong>, and <strong>GitHub Gists</strong> links are supported.</p></aside>
<p><em>Example:</em></p>
<pre data-lang="markdown"><code class="language-markdown hljs markdown" translate="no">[<span class="hljs-string">CECIL : LE générateur de SITES STATIQUES en PHP</span>](<span class="hljs-link">https://www.youtube.com/watch?v=ur8koU0iYvc</span>){embed}</code></pre>
<p><div style="position:relative;padding-bottom:56.25%;height:0;overflow:hidden;">
<iframe src="https://www.youtube-nocookie.com/embed/ur8koU0iYvc" loading="lazy" width="640" height="360" title="CECIL : LE générateur de SITES STATIQUES en PHP" frameborder="0" allow="accelerometer;autoplay;encrypted-media;gyroscope;picture-in-picture;fullscreen;web-share;" allowfullscreen="" style="position:absolute;top:0;left:0;width:100%;height:100%;border:0;background-color:#d8d8d8;"></iframe>
</div></p>
<h4 id="local-video-audio-files">Local video/audio files</h4>
<p>Cecil can also create <code translate="no">&lt;video&gt;</code> and <code translate="no">&lt;audio&gt;</code> HTML elements, based on the file extension (<code translate="no">mp4</code> and <code translate="no">webm</code> for video, <code translate="no">mp3</code>, <code translate="no">ogg</code> and <code translate="no">wav</code> for audio, see <a href="/documentation/configuration/pages/#pages-body-links"><code translate="no">pages.body.links.embed</code></a>).</p>
<p><em>Example:</em></p>
<pre data-lang="markdown"><code class="language-markdown hljs markdown" translate="no">[<span class="hljs-string">Video file</span>](<span class="hljs-link">video.mp4</span>){embed controls poster=/images/video-test.png}
[<span class="hljs-string">Audio file</span>](<span class="hljs-link">song.mp3</span>){embed controls}</code></pre>
<p>Is converted to:</p>
<pre data-lang="html"><code class="language-html hljs xml" translate="no"><span class="hljs-tag">&lt;<span class="hljs-name">video</span> <span class="hljs-attr">src</span>=<span class="hljs-string">"/video.mp4"</span> <span class="hljs-attr">controls</span> <span class="hljs-attr">poster</span>=<span class="hljs-string">"/images/video-test.png"</span> <span class="hljs-attr">style</span>=<span class="hljs-string">"max-width:100%;height:auto;background-color:#d8d8d8;"</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">video</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">audio</span> <span class="hljs-attr">src</span>=<span class="hljs-string">"/song.mp3"</span> <span class="hljs-attr">controls</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">audio</span>&gt;</span></code></pre>
<aside class="note note-info"><p>Without the <code translate="no">controls</code> attribute, a video gets the <code translate="no">autoplay</code>, <code translate="no">loop</code>, <code translate="no">muted</code> and <code translate="no">playsinline</code> attributes.</p></aside>
<p>With <code translate="no">{embed=false}</code> (or when embedding is disabled), a local video/audio file stays a link, but its URL points to the published file (fingerprinted if <a href="/documentation/configuration/assets/"><code translate="no">assets.fingerprint</code></a> is enabled).</p>
<h2 id="images">Images<a class="heading-anchor" href="#images" aria-hidden="true" tabindex="-1"></a></h2>
<p>To add an image, use an exclamation mark (<code translate="no">!</code>) followed by an alternative description in brackets (<code translate="no">[]</code>), and the path or URL to the image in parentheses (<code translate="no">()</code>).<br>
You can optionally add a title in quotation marks.</p>
<pre data-lang="markdown"><code class="language-markdown hljs markdown" translate="no">![<span class="hljs-string">Alternative description</span>](<span class="hljs-link">/image.jpg "Image title"</span>)</code></pre>
<aside class="note note-info"><p>The path should be relative to the root of your website (e.g.: <code translate="no">/image.jpg</code>), however Cecil is able to normalize a path relative to <em>assets</em> and <em>static</em> directories (e.g.: <code translate="no">../../assets/image.jpg</code>).</p></aside>
<aside class="note note-info"><p>Remote images (e.g.: <code translate="no">https://example.com/image.jpg</code>) are downloaded and handled as <em>Assets</em>, so they can be resized and converted. You can disable this behavior, or define a fallback image, with the <a href="/documentation/configuration/pages/#pages-body-images"><code translate="no">remote</code> option</a>.</p></aside>
<h3 id="lazy-loading">Lazy loading<a class="heading-anchor" href="#lazy-loading" aria-hidden="true" tabindex="-1"></a></h3>
<p>Cecil adds the attribute <code translate="no">loading="lazy"</code> to each image.</p>
<p><em>Example:</em></p>
<pre data-lang="markdown"><code class="language-markdown hljs markdown" translate="no">![](/image.jpg)</code></pre>
<p>Is converted to:</p>
<pre data-lang="html"><code class="language-html hljs xml" translate="no"><span class="hljs-tag">&lt;<span class="hljs-name">img</span> <span class="hljs-attr">src</span>=<span class="hljs-string">"/image.jpg"</span> <span class="hljs-attr">loading</span>=<span class="hljs-string">"lazy"</span>&gt;</span></code></pre>
<aside class="note note-info"><p>You can disable this behavior with the attribute <code translate="no">{loading=eager}</code> or with the <a href="/documentation/configuration/pages/#pages-body-images"><code translate="no">lazy</code> option</a>.</p></aside>
<h3 id="decoding">Decoding<a class="heading-anchor" href="#decoding" aria-hidden="true" tabindex="-1"></a></h3>
<p>Cecil adds the attribute <code translate="no">decoding="async"</code> to each image.</p>
<p><em>Example:</em></p>
<pre data-lang="markdown"><code class="language-markdown hljs markdown" translate="no">![](/image.jpg)</code></pre>
<p>Is converted to:</p>
<pre data-lang="html"><code class="language-html hljs xml" translate="no"><span class="hljs-tag">&lt;<span class="hljs-name">img</span> <span class="hljs-attr">src</span>=<span class="hljs-string">"/image.jpg"</span> <span class="hljs-attr">decoding</span>=<span class="hljs-string">"async"</span>&gt;</span></code></pre>
<aside class="note note-info"><p>You can disable this behavior with the attribute <code translate="no">{decoding=auto}</code> or with the <a href="/documentation/configuration/pages/#pages-body-images"><code translate="no">decoding</code> option</a>.</p></aside>
<h3 id="resize">Resize<a class="heading-anchor" href="#resize" aria-hidden="true" tabindex="-1"></a></h3>
<p>Each image in the <em>body</em> can be resized automatically by setting a smaller width than the original one, with the extra attribute <code translate="no">{width=X}</code>.</p>
<p><em>Example:</em></p>
<pre data-lang="markdown"><code class="language-markdown hljs markdown" translate="no">![](/image.jpg){width=800}</code></pre>
<p>Is converted to:</p>
<pre data-lang="html"><code class="language-html hljs xml" translate="no"><span class="hljs-tag">&lt;<span class="hljs-name">img</span> <span class="hljs-attr">src</span>=<span class="hljs-string">"/thumbnails/800/image.jpg"</span> <span class="hljs-attr">width</span>=<span class="hljs-string">"800"</span> <span class="hljs-attr">height</span>=<span class="hljs-string">"600"</span>&gt;</span></code></pre>
<aside class="note note-info"><p>Ratio is preserved (<code translate="no">height</code> attribute is calculated automatically), the original file is not altered and the resized version is stored in <code translate="no">/thumbnails/&lt;width&gt;/</code>.</p></aside>
<aside class="note note-tip"><p>You can also resize all images to a maximum width with the <a href="/documentation/configuration/pages/#pages-body-images"><code translate="no">resize</code> option</a>.</p></aside>
<aside class="note note-important"><p>This feature requires an image processing library: <a href="https://www.php.net/manual/book.imagick.php" target="_blank" rel="noopener noreferrer">Imagick</a> is used first if available (and able to read JPEG and PNG), then <a href="https://www.libvips.org/" target="_blank" rel="noopener noreferrer">libvips</a> (through the PHP <a href="https://www.php.net/manual/book.ffi.php" target="_blank" rel="noopener noreferrer">FFI</a> extension), and finally <a href="https://www.php.net/manual/book.image.php" target="_blank" rel="noopener noreferrer">GD</a> as fallback; otherwise it only adds a <code translate="no">width</code> HTML attribute to the <code translate="no">img</code> tag.</p></aside>
<aside class="note note-info"><p>libvips support is optional and is not bundled with <code translate="no">cecil.phar</code>. To use it, Cecil must be installed with <a href="https://getcomposer.org" target="_blank" rel="noopener noreferrer">Composer</a>, and you need:</p>
<ol>
<li><a href="https://www.libvips.org/install.html" target="_blank" rel="noopener noreferrer">libvips</a> installed on your system</li>
<li>the PHP <a href="https://www.php.net/manual/book.ffi.php" target="_blank" rel="noopener noreferrer">FFI</a> extension enabled</li>
<li>the <code translate="no">intervention/image-driver-vips</code> package installed alongside Cecil</li>
</ol>
<p>If Cecil is a dependency of your project (see <a href="/documentation/developers/library/#libvips-support">Library</a>):</p>
<pre data-lang="bash"><code class="language-bash hljs bash" translate="no">composer require intervention/image-driver-vips</code></pre>
<p>If Cecil is installed globally:</p>
<pre data-lang="bash"><code class="language-bash hljs bash" translate="no">composer global require cecil/cecil intervention/image-driver-vips</code></pre></aside>
<h3 id="formats">Formats<a class="heading-anchor" href="#formats" aria-hidden="true" tabindex="-1"></a></h3>
<p>If the <a href="/documentation/configuration/pages/#pages-body-images"><code translate="no">formats</code> option</a> is defined, alternative images are created and added.</p>
<p><em>Example:</em></p>
<pre data-lang="markdown"><code class="language-markdown hljs markdown" translate="no">![](/image.jpg)</code></pre>
<p>Could be converted to:</p>
<pre data-lang="html"><code class="language-html hljs xml" translate="no"><span class="hljs-tag">&lt;<span class="hljs-name">picture</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">source</span> <span class="hljs-attr">srcset</span>=<span class="hljs-string">"/image.avif"</span> <span class="hljs-attr">type</span>=<span class="hljs-string">"image/avif"</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">source</span> <span class="hljs-attr">srcset</span>=<span class="hljs-string">"/image.webp"</span> <span class="hljs-attr">type</span>=<span class="hljs-string">"image/webp"</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">img</span> <span class="hljs-attr">src</span>=<span class="hljs-string">"/image.jpg"</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">picture</span>&gt;</span></code></pre>
<aside class="note note-important"><p>Please note that <strong>not all image formats</strong> are always included in the PHP image extensions.</p></aside>
<h3 id="responsive">Responsive<a class="heading-anchor" href="#responsive" aria-hidden="true" tabindex="-1"></a></h3>
<p>If the <a href="/documentation/configuration/pages/#pages-body-images"><code translate="no">responsive</code> option</a> is enabled, then all images in the <em>body</em> will be made responsive automatically.</p>
<p><em>Example:</em></p>
<pre data-lang="markdown"><code class="language-markdown hljs markdown" translate="no">![](/image.jpg){width=800}</code></pre>
<p>will be converted to:</p>
<pre data-lang="html"><code class="language-html hljs xml" translate="no"><span class="hljs-tag">&lt;<span class="hljs-name">img</span> <span class="hljs-attr">src</span>=<span class="hljs-string">"/thumbnails/800/image.jpg"</span> <span class="hljs-attr">width</span>=<span class="hljs-string">"800"</span> <span class="hljs-attr">height</span>=<span class="hljs-string">"600"</span>
  <span class="hljs-attr">srcset</span>=<span class="hljs-string">"/thumbnails/480/image.jpg 480w,
          /thumbnails/640/image.jpg 640w,
          /thumbnails/768/image.jpg 768w,
          /thumbnails/800/image.jpg 800w"</span>
  <span class="hljs-attr">sizes</span>=<span class="hljs-string">"100vw"</span>
&gt;</span></code></pre>
<aside class="note note-info"><p>Because a body image is converted into an <a href="/documentation/assets/#asset">Asset</a>, the different widths are defined (and can be changed) in the <code translate="no">assets.images.responsive.widths</code> option of the <a href="/documentation/configuration/assets/">assets configuration</a>.</p></aside>
<p>The <code translate="no">sizes</code> attribute takes the value of the <code translate="no">assets.images.responsive.sizes.default</code> configuration option, but it can be changed by creating a new entry named after a <em>class</em> added to the image.</p>
<p><em>Example:</em></p>
<pre data-lang="yaml"><code class="language-yaml hljs yaml" translate="no"><span class="hljs-attr">assets:</span>
  <span class="hljs-attr">images:</span>
    <span class="hljs-attr">responsive:</span>
      <span class="hljs-attr">sizes:</span>
        <span class="hljs-attr">default:</span> <span class="hljs-string">100vw</span>
        <span class="hljs-attr">my_class:</span> <span class="hljs-string">"(max-width: 800px) 768px, 1024px"</span></code></pre>
<pre data-lang="markdown"><code class="language-markdown hljs markdown" translate="no">![](/image.jpg){.my_class}</code></pre>
<aside class="note note-info"><p>You can combine <code translate="no">formats</code> and <code translate="no">responsive</code> options.</p></aside>
<h3 id="css-class">CSS class<a class="heading-anchor" href="#css-class" aria-hidden="true" tabindex="-1"></a></h3>
<p>You can set a default value to the <code translate="no">class</code> attribute of each image with the <a href="/documentation/configuration/pages/#pages-body-images"><code translate="no">class</code> option</a>.</p>
<h3 id="caption">Caption<a class="heading-anchor" href="#caption" aria-hidden="true" tabindex="-1"></a></h3>
<p>The optional title can be used to create a caption (<code translate="no">figcaption</code>) automatically by enabling the <a href="/documentation/configuration/pages/#pages-body-images"><code translate="no">caption</code> option</a>.</p>
<p><em>Example:</em></p>
<pre data-lang="markdown"><code class="language-markdown hljs markdown" translate="no">![](/image.jpg "Title")</code></pre>
<p>Is converted to:</p>
<pre data-lang="html"><code class="language-html hljs xml" translate="no"><span class="hljs-tag">&lt;<span class="hljs-name">figure</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">img</span> <span class="hljs-attr">src</span>=<span class="hljs-string">"/image.jpg"</span> <span class="hljs-attr">title</span>=<span class="hljs-string">"Title"</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">figcaption</span>&gt;</span>Title<span class="hljs-tag">&lt;/<span class="hljs-name">figcaption</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">figure</span>&gt;</span></code></pre>
<aside class="note note-info"><p>Caption supports Markdown content.</p></aside>
<h3 id="localized-image">Localized image<a class="heading-anchor" href="#localized-image" aria-hidden="true" tabindex="-1"></a></h3>
<p>For translated pages, Cecil first looks for a language-suffixed file when resolving Markdown image paths.</p>
<p><em>Example:</em></p>
<pre data-lang="markdown"><code class="language-markdown hljs markdown" translate="no">![](/images/cecil-logo.png)</code></pre>
<p>With a French page (<code translate="no">fr</code>), Cecil tries <code translate="no">/images/cecil-logo.fr.png</code> first, then falls back to <code translate="no">/images/cecil-logo.png</code>.</p>
<h3 id="dark-and-mobile-variants">Dark and mobile variants<a class="heading-anchor" href="#dark-and-mobile-variants" aria-hidden="true" tabindex="-1"></a></h3>
<p>If the <a href="/documentation/configuration/pages/#pages-body-images"><code translate="no">dark_suffix</code> option</a> is defined (e.g.: <code translate="no">.dark</code>), Cecil looks for a dark variant of each image (e.g.: <code translate="no">image.dark.jpg</code> alongside <code translate="no">image.jpg</code>) and adds it as a <code translate="no">&lt;source media="(prefers-color-scheme: dark)"&gt;</code> in a <code translate="no">&lt;picture&gt;</code> element.</p>
<p>In the same way, if the <a href="/documentation/configuration/pages/#pages-body-images"><code translate="no">mobile_suffix</code> option</a> is defined (e.g.: <code translate="no">.mobile</code>), Cecil looks for a mobile variant of each image (e.g.: <code translate="no">image.mobile.jpg</code>) and adds it as a <code translate="no">&lt;source&gt;</code> with the <code translate="no">mobile_media_query</code> media query.</p>
<h3 id="placeholder">Placeholder<a class="heading-anchor" href="#placeholder" aria-hidden="true" tabindex="-1"></a></h3>
<p>As images are typically heavier and slower resources, and they don’t block rendering, we should attempt to give users something to look at while they wait for the image to arrive.</p>
<p>The <code translate="no">placeholder</code> attribute accepts two options:</p>
<ol>
<li><code translate="no">color</code>: display a colored background (based on image dominant color)</li>
<li><code translate="no">lqip</code>: <a href="https://www.guypo.com/introducing-lqip-low-quality-image-placeholders" target="_blank" rel="noopener noreferrer">Low-Quality Image Placeholder</a></li>
</ol>
<p><em>Examples:</em></p>
<pre data-lang="markdown"><code class="language-markdown hljs markdown" translate="no">![](/images/img.jpg){placeholder=color}
![](/images/img.jpg){placeholder=lqip}</code></pre>
<aside class="note note-tip"><p>You can set a value to the <code translate="no">placeholder</code> attribute for each image with the <a href="/documentation/configuration/pages/#pages-body-images"><code translate="no">placeholder</code> option</a>.</p></aside>
<aside class="note note-warning"><p>Placeholders are only applied to JPEG, PNG and GIF images, and the <code translate="no">lqip</code> option is not compatible with animated GIF.</p></aside>
<h2 id="heading-anchors">Heading anchors<a class="heading-anchor" href="#heading-anchors" aria-hidden="true" tabindex="-1"></a></h2>
<p>An anchor link is added at the end of <code translate="no">h2</code> and <code translate="no">h3</code> headings (see the <a href="/documentation/configuration/pages/#pages-body-anchors"><code translate="no">pages.body.anchors</code></a> option), to link to a heading of a page:</p>
<pre data-lang="html"><code class="language-html hljs xml" translate="no"><span class="hljs-tag">&lt;<span class="hljs-name">h2</span> <span class="hljs-attr">id</span>=<span class="hljs-string">"heading"</span>&gt;</span>Heading<span class="hljs-tag">&lt;<span class="hljs-name">a</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"heading-anchor"</span> <span class="hljs-attr">href</span>=<span class="hljs-string">"#heading"</span> <span class="hljs-attr">aria-hidden</span>=<span class="hljs-string">"true"</span> <span class="hljs-attr">tabindex</span>=<span class="hljs-string">"-1"</span>&gt;</span><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></code></pre>
<p>The link is empty: the default templates display a <code translate="no">#</code> on hover.</p>
<h2 id="table-of-contents">Table of contents<a class="heading-anchor" href="#table-of-contents" aria-hidden="true" tabindex="-1"></a></h2>
<p>You can add a table of contents with the following Markdown syntax:</p>
<pre data-lang="markdown"><code class="language-markdown hljs markdown" translate="no">[toc]</code></pre>
<aside class="note note-info"><p>By default, the ToC extracts H2 and H3 headings. You can change this behavior with <a href="/documentation/configuration/pages/#pages-body">body options</a>.</p></aside>
<h2 id="excerpt">Excerpt<a class="heading-anchor" href="#excerpt" aria-hidden="true" tabindex="-1"></a></h2>
<p>An excerpt can be defined in the <em>body</em> with one of the following HTML comments: <code translate="no">&lt;!-- excerpt --&gt;</code> or <code translate="no">&lt;!-- break --&gt;</code> (see the <a href="/documentation/configuration/pages/#pages-body-excerpt"><code translate="no">pages.body.excerpt</code> option</a>).</p>
<p><em>Example:</em></p>
<pre data-lang="html"><code class="language-html hljs xml" translate="no">Introduction.
<span class="hljs-comment">&lt;!-- excerpt --&gt;</span>
Main content.</code></pre>
<p>Then use the <a href="/documentation/templates/reference/filters/#excerpt-html"><code translate="no">excerpt_html</code> filter</a> in your template.</p>
<h2 id="notes">Notes<a class="heading-anchor" href="#notes" aria-hidden="true" tabindex="-1"></a></h2>
<p>Create a <em>Note</em> block (info, tip, important, etc.).</p>
<p><em>Example:</em></p>
<pre data-lang="markdown"><code class="language-markdown hljs markdown" translate="no">:::tip
<span class="hljs-strong">**Tip:**</span> This is advice.
:::</code></pre>
<p>Is converted to:</p>
<pre data-lang="html"><code class="language-html hljs xml" translate="no"><span class="hljs-tag">&lt;<span class="hljs-name">aside</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"note note-tip"</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">p</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">strong</span>&gt;</span>Tip:<span class="hljs-tag">&lt;/<span class="hljs-name">strong</span>&gt;</span> This is advice.
  <span class="hljs-tag">&lt;/<span class="hljs-name">p</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">aside</span>&gt;</span></code></pre>
<aside class="note note-tip"><p><strong>Tip:</strong> This is advice.</p></aside>
<aside class="note note-info"><p>Any type name can be used: it is added to the <code translate="no">class</code> attribute as <code translate="no">note-&lt;type&gt;</code> (e.g.: <code translate="no">:::danger</code> gives <code translate="no">class="note note-danger"</code>).</p></aside>
<p><em>Other examples:</em></p>
<aside class="note"><p>empty</p></aside>
<aside class="note note-info"><p>info</p></aside>
<aside class="note note-tip"><p>tip</p></aside>
<aside class="note note-important"><p>important</p></aside>
<aside class="note note-warning"><p>warning</p></aside>
<aside class="note note-caution"><p>caution</p></aside>
<h3 id="nested-notes">Nested notes<a class="heading-anchor" href="#nested-notes" aria-hidden="true" tabindex="-1"></a></h3>
<p>A note is closed by a line made of at least as many <code translate="no">:</code> as its opening line: to nest notes, use a longer fence for the parent note (<code translate="no">::::</code>, then <code translate="no">:::::</code> for a third level, etc.).</p>
<pre data-lang="markdown"><code class="language-markdown hljs markdown" translate="no">::::info
Before.

:::tip
<span class="hljs-strong">**Tip:**</span> This is advice.
:::

After.
::::</code></pre>
<aside class="note note-info"><p>Before.</p>
<aside class="note note-tip"><p><strong>Tip:</strong> This is advice.</p></aside>
<p>After.</p></aside>
<p>A longer fence also lets you show the note syntax in a code block, inside a note.</p>
<h3 id="templates">Templates<a class="heading-anchor" href="#templates" aria-hidden="true" tabindex="-1"></a></h3>
<p>A note is rendered with the <code translate="no">partials/notes/&lt;type&gt;.html.twig</code> template, if it exists (in the site <code translate="no">layouts/</code>, in a theme or built-in), instead of the <code translate="no">&lt;aside&gt;</code> element.</p>
<p>Cecil provides templates for the following types, rendered without JavaScript: a theme can style them, override them and add interactivity. Unlike other notes, their root element is a <code translate="no">&lt;div class="note note-&lt;type&gt;"&gt;</code> (not an <code translate="no">&lt;aside&gt;</code>), as their content is part of the main content.</p>
<table>
<thead>
<tr>
<th>Type</th>
<th>Items</th>
<th>Rendering</th>
</tr>
</thead>
<tbody>
<tr>
<td><code translate="no">tabs</code></td>
<td>one per <code translate="no">####</code> heading</td>
<td>stacked panels (<code translate="no">&lt;section class="note-tab"&gt;</code>)</td>
</tr>
<tr>
<td><code translate="no">code-group</code></td>
<td>one per <code translate="no">####</code> heading, or one per code block (titled with its language)</td>
<td>same as <code translate="no">tabs</code></td>
</tr>
<tr>
<td><code translate="no">steps</code></td>
<td>one per <code translate="no">####</code> heading</td>
<td>ordered list (<code translate="no">&lt;ol class="note-steps-list"&gt;</code>)</td>
</tr>
<tr>
<td><code translate="no">accordion</code></td>
<td>one per <code translate="no">####</code> heading</td>
<td><code translate="no">&lt;details class="note-accordion-item"&gt;</code></td>
</tr>
<tr>
<td><code translate="no">cards</code></td>
<td>one per list entry (a leading link is the card title), or per <code translate="no">####</code> heading</td>
<td>list (<code translate="no">&lt;ul class="note-cards-list"&gt;</code>)</td>
</tr>
</tbody>
</table>
<p>The examples below are themselves nested notes: a <code translate="no">tabs</code> note (with a <code translate="no">::::</code> fence) shows the Markdown source and its rendering.</p>
<h4 id="tabs">Tabs</h4>
<p>Alternative contents, one per <code translate="no">####</code> heading (e.g.: per operating system).</p>
<div class="note note-tabs" id="note-tabs-1">
  <section class="note-tab" id="note-tabs-1-1">
    <h4 id="markdown">Markdown</h4>
    <pre data-lang="markdown"><code class="language-markdown hljs markdown" translate="no">:::tabs
<span class="hljs-section">#### macOS and Linux</span>

<span class="hljs-code">```bash
brew install cecilapp/tap/cecil
```</span>

<span class="hljs-section">#### Windows</span>

<span class="hljs-code">```bash
scoop install https://cecil.app/scoop/cecil.json
```</span>
:::</code></pre>
  </section>
  <section class="note-tab" id="note-tabs-1-2">
    <h4 id="result">Result</h4>
    <div class="note note-tabs" id="note-tabs-2">
  <section class="note-tab" id="note-tabs-2-1">
    <h4 id="macos-and-linux">macOS and Linux</h4>
    <pre data-lang="bash"><code class="language-bash hljs bash" translate="no">brew install cecilapp/tap/cecil</code></pre>
  </section>
  <section class="note-tab" id="note-tabs-2-2">
    <h4 id="windows">Windows</h4>
    <pre data-lang="bash"><code class="language-bash hljs bash" translate="no">scoop install https://cecil.app/scoop/cecil.json</code></pre>
  </section>
</div>
  </section>
</div>
<h4 id="code-group">Code group</h4>
<p>Like <code translate="no">tabs</code>, with code blocks only: without heading, each code block is titled with its language.</p>
<div class="note note-tabs" id="note-tabs-3">
  <section class="note-tab" id="note-tabs-3-1">
    <h4 id="markdown-1">Markdown</h4>
    <pre data-lang="markdown"><code class="language-markdown hljs markdown" translate="no">:::code-group
<span class="hljs-code">```bash
curl -LO https://cecil.app/cecil.phar
```</span>

<span class="hljs-code">```powershell
Invoke-WebRequest https://cecil.app/cecil.phar -OutFile cecil.phar
```</span>
:::</code></pre>
  </section>
  <section class="note-tab" id="note-tabs-3-2">
    <h4 id="result-1">Result</h4>
    <div class="note note-code-group" id="note-code-group-4">
  <section class="note-tab" id="note-code-group-4-1">
    <p class="note-tab-title">bash</p>
    <pre data-lang="bash"><code class="language-bash hljs bash" translate="no">curl -LO https://cecil.app/cecil.phar</code></pre>
  </section>
  <section class="note-tab" id="note-code-group-4-2">
    <p class="note-tab-title">powershell</p>
    <pre data-lang="powershell"><code class="language-powershell hljs powershell" translate="no"><span class="hljs-built_in">Invoke-WebRequest</span> https://cecil.app/cecil.phar <span class="hljs-literal">-OutFile</span> cecil.phar</code></pre>
  </section>
</div>
  </section>
</div>
<h4 id="steps">Steps</h4>
<p>A numbered procedure, one step per <code translate="no">####</code> heading.</p>
<div class="note note-tabs" id="note-tabs-5">
  <section class="note-tab" id="note-tabs-5-1">
    <h4 id="markdown-2">Markdown</h4>
    <pre data-lang="markdown"><code class="language-markdown hljs markdown" translate="no">:::steps
<span class="hljs-section">#### Create a site</span>

<span class="hljs-code">```bash
php cecil.phar new:site
```</span>

<span class="hljs-section">#### Preview it</span>

<span class="hljs-code">```bash
php cecil.phar serve
```</span>
:::</code></pre>
  </section>
  <section class="note-tab" id="note-tabs-5-2">
    <h4 id="result-2">Result</h4>
    <div class="note note-steps" id="note-steps-6">
  <ol class="note-steps-list">
    <li class="note-step">
      <h4 id="create-a-site">Create a site</h4>
      <pre data-lang="bash"><code class="language-bash hljs bash" translate="no">php cecil.phar new:site</code></pre>
    </li>
    <li class="note-step">
      <h4 id="preview-it">Preview it</h4>
      <pre data-lang="bash"><code class="language-bash hljs bash" translate="no">php cecil.phar serve</code></pre>
    </li>
  </ol>
</div>
  </section>
</div>
<h4 id="accordion">Accordion</h4>
<p>Collapsible items, one per <code translate="no">####</code> heading (e.g.: a FAQ).</p>
<div class="note note-tabs" id="note-tabs-7">
  <section class="note-tab" id="note-tabs-7-1">
    <h4 id="markdown-3">Markdown</h4>
    <pre data-lang="markdown"><code class="language-markdown hljs markdown" translate="no">:::accordion
<span class="hljs-section">#### Is PHP required?</span>

No: the standalone binary embeds PHP.

<span class="hljs-section">#### Where is the generated site?</span>

In the <span class="hljs-code">`_site`</span> directory.
:::</code></pre>
  </section>
  <section class="note-tab" id="note-tabs-7-2">
    <h4 id="result-3">Result</h4>
    <div class="note note-accordion" id="note-accordion-8">
  <details class="note-accordion-item" id="is-php-required">
    <summary>Is PHP required?</summary>
    <div class="note-accordion-content">
      <p>No: the standalone binary embeds PHP.</p>
    </div>
  </details>
  <details class="note-accordion-item" id="where-is-the-generated-site">
    <summary>Where is the generated site?</summary>
    <div class="note-accordion-content">
      <p>In the <code translate="no">_site</code> directory.</p>
    </div>
  </details>
</div>
  </section>
</div>
<h4 id="cards">Cards</h4>
<p>Links to other pages, one card per list entry: a leading link is the card title.</p>
<div class="note note-tabs" id="note-tabs-9">
  <section class="note-tab" id="note-tabs-9-1">
    <h4 id="markdown-4">Markdown</h4>
    <pre data-lang="markdown"><code class="language-markdown hljs markdown" translate="no">:::cards
<span class="hljs-bullet">- </span>[<span class="hljs-string">Installation</span>](<span class="hljs-link">../getting-started/2-installation.md</span>): download and install Cecil.
<span class="hljs-bullet">- </span>[<span class="hljs-string">Configuration</span>](<span class="hljs-link">../configuration/index.md</span>): configure your site.
:::</code></pre>
  </section>
  <section class="note-tab" id="note-tabs-9-2">
    <h4 id="result-4">Result</h4>
    <div class="note note-cards" id="note-cards-10">
  <ul class="note-cards-list">
    <li class="note-card">
      <p class="note-card-title"><a href="/documentation/getting-started/installation/">Installation</a></p>
      <div class="note-card-content">download and install Cecil.</div>
    </li>
    <li class="note-card">
      <p class="note-card-title"><a href="/documentation/configuration/">Configuration</a></p>
      <div class="note-card-content">configure your site.</div>
    </li>
  </ul>
</div>
  </section>
</div>
<h4 id="custom-template">Custom template</h4>
<p>The template receives a <code translate="no">note</code> variable:</p>
<ul>
<li><code translate="no">note.type</code>: note type (e.g.: <code translate="no">tabs</code>)</li>
<li><code translate="no">note.id</code>: unique ID in the page (e.g.: <code translate="no">note-tabs-1</code>)</li>
<li><code translate="no">note.content</code>: HTML of the whole note</li>
<li><code translate="no">note.intro</code>: HTML of the content before the first <code translate="no">####</code> heading</li>
<li><code translate="no">note.items</code>: list of items, each with:<ul>
<li><code translate="no">title</code>: title (HTML)</li>
<li><code translate="no">heading</code>: heading element (HTML), with its <code translate="no">id</code> attribute</li>
<li><code translate="no">id</code>: heading ID, if any</li>
<li><code translate="no">link</code>: leading link element (HTML) of a list entry</li>
<li><code translate="no">url</code>: leading link URL of a list entry</li>
<li><code translate="no">language</code>: language of a code block</li>
<li><code translate="no">content</code>: content (HTML)</li>
</ul>
</li>
</ul>
<p>To override the rendering of a note type, create the template in your site (or theme), for example <code translate="no">layouts/partials/notes/tip.html.twig</code>:</p>
<pre data-lang="twig"><code class="language-twig hljs twig" translate="no"><span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"callout callout-</span></span></span><span class="hljs-template-variable">{{ note.type }}</span><span class="xml"><span class="hljs-tag"><span class="hljs-string">"</span>&gt;</span>
  </span><span class="hljs-template-variable">{{ note.content|<span class="hljs-keyword">raw</span> }}</span><span class="xml">
<span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span></span></code></pre>
<aside class="note note-info"><p>Notes are rendered when Markdown is converted, before pages rendering: a note template has access to the <code translate="no">note</code> variable and to translations (in the page language), but not to <code translate="no">page</code> or <code translate="no">site</code>.</p></aside>
<h2 id="syntax-highlight">Syntax highlight<a class="heading-anchor" href="#syntax-highlight" aria-hidden="true" tabindex="-1"></a></h2>
<p>Code block syntax highlighting is enabled by default with the <a href="/documentation/configuration/pages/#pages-body-highlight"><code translate="no">pages.body.highlight</code></a> option.</p>
<p>If needed, you can disable it with:</p>
<pre data-lang="yaml"><code class="language-yaml hljs yaml" translate="no"><span class="hljs-attr">pages:</span>
  <span class="hljs-attr">body:</span>
    <span class="hljs-attr">highlight:</span> <span class="hljs-literal">false</span></code></pre>
<p><em>Example:</em></p>
<pre>
```php
echo "Hello world";
```
</pre>
<p>Is rendered to:</p>
<pre data-lang="php"><code class="language-php hljs php" translate="no"><span class="hljs-keyword">echo</span> <span class="hljs-string">"Hello world"</span>;</code></pre>
<aside class="note note-info"><p>You can customize the syntax highlighting style by creating your own theme. See the <a href="https://highlightjs.readthedocs.io/en/latest/theme-guide.html" target="_blank" rel="noopener noreferrer">Highlight.js Theme Guide</a>.</p></aside>
<aside class="note note-tip"><p>You can also use <a href="https://github.com/tempestphp/highlight" target="_blank" rel="noopener noreferrer">tempest/highlight</a> instead of highlight.js with the <a href="/documentation/configuration/pages/#pages-body-highlight"><code translate="no">pages.body.highlight.engine</code></a> option. It's faster, but supports fewer languages. It uses <code translate="no">hl-*</code> CSS classes: see the <a href="https://github.com/tempestphp/highlight/tree/main/src/Themes/Css" target="_blank" rel="noopener noreferrer">tempest/highlight themes</a>.</p></aside>
<p>The language of a code block is added to the <code translate="no">data-lang</code> attribute of the <code translate="no">&lt;pre&gt;</code> element (e.g.: <code translate="no">&lt;pre data-lang="php"&gt;</code>): the default templates display it as a label.</p>
<h2 id="inserted-text">Inserted text<a class="heading-anchor" href="#inserted-text" aria-hidden="true" tabindex="-1"></a></h2>
<p>Represents a range of text that has been added.</p>
<pre data-lang="markdown"><code class="language-markdown hljs markdown" translate="no">++text++</code></pre>
<p>Is converted to:</p>
<pre data-lang="html"><code class="language-html hljs xml" translate="no"><span class="hljs-tag">&lt;<span class="hljs-name">ins</span>&gt;</span>text<span class="hljs-tag">&lt;/<span class="hljs-name">ins</span>&gt;</span></code></pre>]]>
    </content>
  </entry>
  <entry xml:lang="en">
    <id>https://cecil.app/documentation/content/multilingual/</id>
    <title>Multilingual</title>
    <published>2021-05-07T00:00:00+00:00</published>
    <updated>2026-10-24T00:00:00+00:00</updated>
    <link href="https://cecil.app/documentation/content/multilingual/" rel="alternate" type="text/html" />
    <content type="html">
      <![CDATA[<h1>Multilingual</h1>
<p>If your pages are available in multiple <a href="/documentation/configuration/languages/#languages">languages</a>, there are two ways to define them:</p>
<h2 id="through-file-name">Through file name<a class="heading-anchor" href="#through-file-name" aria-hidden="true" tabindex="-1"></a></h2>
<p>This is the most common way to translate a page from the main <a href="/documentation/configuration/languages/#language">language</a> to another language.</p>
<p>You just need to duplicate the reference page and add the target language <code translate="no">code</code> as a suffix, before the extension (e.g.: <code translate="no">about.fr.md</code>). The code must be one of the declared <a href="/documentation/configuration/languages/#languages">languages</a> (format <code translate="no">fr</code> or <code translate="no">fr-FR</code>).</p>
<p><em>Example:</em></p>
<pre data-lang="plaintext"><code class="language-plaintext hljs plaintext" translate="no">├─ about.md    # the reference page
└─ about.fr.md # the French version (`fr`)</code></pre>
<aside class="note note-tip"><p>You can change the URL of the translated page with the <code translate="no">slug</code> variable in its front matter. For example, in <code translate="no">about.fr.md</code>:</p>
<pre data-lang="yaml"><code class="language-yaml hljs yaml" translate="no"><span class="hljs-meta">---</span>
<span class="hljs-attr">slug:</span> <span class="hljs-string">a-propos</span>
<span class="hljs-meta">---</span>
<span class="hljs-comment"># about.md    -&gt; /about/</span>
<span class="hljs-comment"># about.fr.md -&gt; /fr/a-propos/</span></code></pre></aside>
<h2 id="through-front-matter">Through front matter<a class="heading-anchor" href="#through-front-matter" aria-hidden="true" tabindex="-1"></a></h2>
<p>If you want to create a page in a language other than the main language, without it being a translation of an existing page, you can use the <code translate="no">language</code> variable in its front matter.</p>
<p><em>Example:</em></p>
<pre data-lang="yaml"><code class="language-yaml hljs yaml" translate="no"><span class="hljs-meta">---</span>
<span class="hljs-attr">language:</span> <span class="hljs-string">fr</span>
<span class="hljs-meta">---</span></code></pre>
<h2 id="link-translated-pages">Link translated pages<a class="heading-anchor" href="#link-translated-pages" aria-hidden="true" tabindex="-1"></a></h2>
<p>Each translated page references its versions in other languages.</p>
<p>This collection of pages is available in <a href="/documentation/templates/variables/#page">templates</a> with the following variable:</p>
<pre data-lang="twig"><code class="language-twig hljs twig" translate="no"><span class="hljs-template-variable">{{ page.translations }}</span></code></pre>
<aside class="note note-info"><p>Translations are linked by their <code translate="no">langref</code> variable: by default, the page path without language (e.g.: <code translate="no">about</code> for <code translate="no">about.md</code> and <code translate="no">about.fr.md</code>).</p>
<p>You can change it in the front matter, for example to link translated pages with different file names:</p>
<pre data-lang="yaml"><code class="language-yaml hljs yaml" translate="no"><span class="hljs-meta">---</span>
<span class="hljs-attr">langref:</span> <span class="hljs-string">my-page-ref</span>
<span class="hljs-meta">---</span></code></pre></aside>
<h2 id="search-engines">Search engines<a class="heading-anchor" href="#search-engines" aria-hidden="true" tabindex="-1"></a></h2>
<p>The built-in templates declare translated pages to search engines with <code translate="no">hreflang</code> alternates, in the HTML <code translate="no">&lt;head&gt;</code> and in the XML sitemap:</p>
<ul>
<li>each page lists itself and its translations</li>
<li><code translate="no">x-default</code> points to the version in the default language, and is omitted when the page has no version in the default language</li>
</ul>
<p>The XML sitemap lists the pages of all languages, including pages that are not translated into the default language.</p>]]>
    </content>
  </entry>
  <entry xml:lang="en">
    <id>https://cecil.app/documentation/content/dynamic-content/</id>
    <title>Dynamic content</title>
    <published>2021-05-07T00:00:00+00:00</published>
    <updated>2026-10-16T00:00:00+00:00</updated>
    <link href="https://cecil.app/documentation/content/dynamic-content/" rel="alternate" type="text/html" />
    <content type="html">
      <![CDATA[<h1>Dynamic content</h1>
<p>By default, the body of a page is static: Twig syntax written in a Markdown file is output as is.</p>
<p>You can create dynamic content in a page by using the <a href="https://twig.symfony.com/doc/3.x/functions/template_from_string.html" target="_blank" rel="noopener noreferrer"><code translate="no">template_from_string</code></a> Twig function, which renders the page content as a Twig template.</p>
<pre data-lang="twig"><code class="language-twig hljs twig" translate="no"><span class="hljs-template-variable">{{ <span class="hljs-name">include</span><span class="hljs-params">(template_from_string(page.content, "dynamic content for page " ~ page.id)</span>) }}</span></code></pre>
<p>With this, you can use any page variable in the <em>body</em> of the page.</p>
<pre data-lang="markdown"><code class="language-markdown hljs markdown" translate="no">---
<span class="hljs-section">var: 'value'
---</span>
The value of <span class="hljs-code">`var`</span> is {{ page.var }}.</code></pre>
<h2 id="enable-dynamic-content">Enable dynamic content<a class="heading-anchor" href="#enable-dynamic-content" aria-hidden="true" tabindex="-1"></a></h2>
<p>The recommended way is to create a dedicated layout that overrides the <code translate="no">content</code> block, and to use it only for pages that need it.</p>
<pre data-lang="twig"><code class="language-twig hljs twig" translate="no"><span class="hljs-comment">{# layouts/dynamic.html.twig #}</span><span class="xml">
</span><span class="hljs-template-tag">{% <span class="hljs-name"><span class="hljs-keyword">extends</span></span> '_default/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><span class="hljs-template-variable">{{ <span class="hljs-name">include</span><span class="hljs-params">(template_from_string(page.content, "dynamic content for page " ~ page.id)</span>) }}</span><span class="xml">
</span><span class="hljs-template-tag">{% <span class="hljs-name"><span class="hljs-keyword">endblock</span></span> content %}</span></code></pre>
<p>Then set the <a href="/documentation/content/front-matter/#predefined-variables"><code translate="no">layout</code></a> variable in the front matter of the page:</p>
<pre data-lang="yaml"><code class="language-yaml hljs yaml" translate="no"><span class="hljs-meta">---</span>
<span class="hljs-attr">title:</span> <span class="hljs-string">"My dynamic page"</span>
<span class="hljs-attr">layout:</span> <span class="hljs-string">dynamic</span>
<span class="hljs-meta">---</span></code></pre>
<aside class="note note-tip"><p>The second argument of <code translate="no">template_from_string</code> is the name of the template: it is displayed in error messages, so including <code translate="no">page.id</code> helps to find the page in error.</p></aside>
<h2 id="available-variables">Available variables<a class="heading-anchor" href="#available-variables" aria-hidden="true" tabindex="-1"></a></h2>
<p>The page content is rendered with the same context as the layout, so you can use:</p>
<ul>
<li>page variables: <code translate="no">page.title</code>, <code translate="no">page.date</code>, <code translate="no">page.&lt;custom variable&gt;</code>, etc.</li>
<li>site variables: <code translate="no">site.title</code>, <code translate="no">site.pages</code>, <a href="/documentation/templates/variables/#site-data"><code translate="no">site.data</code></a>, etc.</li>
<li>all <a href="/documentation/templates/reference/functions/">functions</a>, <a href="/documentation/templates/reference/filters/">filters</a> and <a href="/documentation/templates/reference/sorts/">sorts</a> available in templates</li>
<li>Twig tags: <code translate="no">{% set %}</code>, <code translate="no">{% if %}</code>, <code translate="no">{% for %}</code>, <code translate="no">{% include %}</code>, etc.</li>
</ul>
<h2 id="how-it-works">How it works<a class="heading-anchor" href="#how-it-works" aria-hidden="true" tabindex="-1"></a></h2>
<p>The Markdown body is <strong>converted to HTML first</strong>, then the result (<code translate="no">page.content</code>) is rendered by Twig. This order has some consequences:</p>
<ul>
<li>Markdown escapes the <code translate="no">&lt;</code> and <code translate="no">&gt;</code> characters, so comparison operators (<code translate="no">&gt;</code>, <code translate="no">&lt;=</code>) and arrow functions (<code translate="no">=&gt;</code>) can’t be used in the body: the build fails with an <code translate="no">Unexpected character "&amp;"</code> error.</li>
<li>A Twig expression used in an HTML attribute (e.g.: <code translate="no">href="{{ url(post) }}"</code>) is URL encoded by the Markdown converter and won’t be evaluated.</li>
<li>A Twig expression alone on its own line is wrapped in a <code translate="no">&lt;p&gt;</code> element.</li>
<li>Twig syntax written inside a code span or a code block <strong>is</strong> evaluated too.</li>
</ul>
<aside class="note note-tip"><p>Keep the body simple (variables, filters, short conditions) and move complex markup and logic into a <a href="#example-include-a-partial-template">partial template</a> or a <a href="#example-shortcodes-with-macros">macro</a>.</p></aside>
<p>To display Twig syntax as is, wrap it in a <code translate="no">verbatim</code> tag:</p>
<pre data-lang="twig"><code class="language-twig hljs twig" translate="no"><span class="hljs-template-tag">{% <span class="hljs-name"><span class="hljs-keyword">verbatim</span></span> %}</span><span class="xml">`</span><span class="hljs-template-variable">{{ page.title }}</span><span class="xml">`</span><span class="hljs-template-tag">{% <span class="hljs-name"><span class="hljs-keyword">endverbatim</span></span> %}</span></code></pre>
<p>To avoid an extra <code translate="no">&lt;p&gt;</code> element around a block of HTML, wrap the expression in an HTML element, separated by line breaks:</p>
<pre data-lang="twig"><code class="language-twig hljs twig" translate="no"><span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">div</span>&gt;</span>
</span><span class="hljs-template-variable">{{ <span class="hljs-name">include</span><span class="hljs-params">('partials/latest-posts.html.twig')</span> }}</span><span class="xml">
<span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span></span></code></pre>
<h2 id="example-include-a-partial-template">Example: variables, data and partial template<a class="heading-anchor" href="#example-include-a-partial-template" aria-hidden="true" tabindex="-1"></a></h2>
<p>This example shows a page displaying site and page variables, data from a <a href="/documentation/templates/variables/#site-data">data file</a>, and the latest blog posts through a reusable partial template.</p>
<p>Data file:</p>
<pre data-lang="yaml"><code class="language-yaml hljs yaml" translate="no"><span class="hljs-comment"># data/team.yml</span>
<span class="hljs-bullet">-</span> <span class="hljs-attr">name:</span> <span class="hljs-string">Alice</span>
  <span class="hljs-attr">role:</span> <span class="hljs-string">Developer</span>
<span class="hljs-bullet">-</span> <span class="hljs-attr">name:</span> <span class="hljs-string">Bob</span>
  <span class="hljs-attr">role:</span> <span class="hljs-string">Designer</span></code></pre>
<p>Partial template, which receives <code translate="no">section</code> and <code translate="no">limit</code> as parameters:</p>
<pre data-lang="twig"><code class="language-twig hljs twig" translate="no"><span class="hljs-comment">{# layouts/partials/latest-posts.html.twig #}</span><span class="xml">
</span><span class="hljs-template-tag">{% <span class="hljs-name"><span class="hljs-keyword">set</span></span> posts = site.pages.showable|filter_by('section', section|<span class="hljs-keyword">default</span>('blog'))|sort_by_date|<span class="hljs-keyword">slice</span>(0, limit|<span class="hljs-keyword">default</span>(5)) %}</span><span class="xml">
</span><span class="hljs-template-tag">{% <span class="hljs-name"><span class="hljs-keyword">if</span></span> posts|<span class="hljs-keyword">length</span> &gt; 0 %}</span><span class="xml">
<span class="hljs-tag">&lt;<span class="hljs-name">ul</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"latest-posts"</span>&gt;</span>
  </span><span class="hljs-template-tag">{% <span class="hljs-name"><span class="hljs-keyword">for</span></span> post in posts %}</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(post) }}</span><span class="xml"><span class="hljs-tag"><span class="hljs-string">"</span>&gt;</span></span><span class="hljs-template-variable">{{ post.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">time</span> <span class="hljs-attr">datetime</span>=<span class="hljs-string">"</span></span></span><span class="hljs-template-variable">{{ post.<span class="hljs-name">date</span>|<span class="hljs-keyword">date</span>('Y-m-d') }}</span><span class="xml"><span class="hljs-tag"><span class="hljs-string">"</span>&gt;</span></span><span class="hljs-template-variable">{{ post.<span class="hljs-name">date</span>|format_date('long') }}</span><span class="xml"><span class="hljs-tag">&lt;/<span class="hljs-name">time</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">else</span> %}</span><span class="xml">
<span class="hljs-tag">&lt;<span class="hljs-name">p</span>&gt;</span>No posts yet.<span class="hljs-tag">&lt;/<span class="hljs-name">p</span>&gt;</span>
</span><span class="hljs-template-tag">{% <span class="hljs-name"><span class="hljs-keyword">endif</span></span> %}</span></code></pre>
<p>Page:</p>
<pre data-lang="markdown"><code class="language-markdown hljs markdown" translate="no">---
title: About
<span class="hljs-section">layout: dynamic
---</span>
Welcome to <span class="hljs-strong">**{{ site.title }}**</span>! This page was published on {{ page.date|format_date('long') }}.

Our team has {{ site.data.team|length }} members: {{ site.data.team|column('name')|join(', ') }}.

<span class="hljs-section">## Latest posts</span>

<span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">div</span>&gt;</span></span>
{{ include('partials/latest-posts.html.twig', {section: 'blog', limit: 3}) }}
<span class="xml"><span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span></span></code></pre>
<p>Output:</p>
<pre data-lang="html"><code class="language-html hljs xml" translate="no"><span class="hljs-tag">&lt;<span class="hljs-name">p</span>&gt;</span>Welcome to <span class="hljs-tag">&lt;<span class="hljs-name">strong</span>&gt;</span>My site<span class="hljs-tag">&lt;/<span class="hljs-name">strong</span>&gt;</span>! This page was published on October 9, 2026.<span class="hljs-tag">&lt;/<span class="hljs-name">p</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">p</span>&gt;</span>Our team has 2 members: Alice, Bob.<span class="hljs-tag">&lt;/<span class="hljs-name">p</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">h2</span> <span class="hljs-attr">id</span>=<span class="hljs-string">"latest-posts"</span>&gt;</span>Latest posts<span class="hljs-tag">&lt;/<span class="hljs-name">h2</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">div</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">ul</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"latest-posts"</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">"/blog/post-3/"</span>&gt;</span>Post 3<span class="hljs-tag">&lt;/<span class="hljs-name">a</span>&gt;</span> <span class="hljs-tag">&lt;<span class="hljs-name">time</span> <span class="hljs-attr">datetime</span>=<span class="hljs-string">"2026-03-01"</span>&gt;</span>March 1, 2026<span class="hljs-tag">&lt;/<span class="hljs-name">time</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">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">"/blog/post-2/"</span>&gt;</span>Post 2<span class="hljs-tag">&lt;/<span class="hljs-name">a</span>&gt;</span> <span class="hljs-tag">&lt;<span class="hljs-name">time</span> <span class="hljs-attr">datetime</span>=<span class="hljs-string">"2026-02-01"</span>&gt;</span>February 1, 2026<span class="hljs-tag">&lt;/<span class="hljs-name">time</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">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">"/blog/post-1/"</span>&gt;</span>Post 1<span class="hljs-tag">&lt;/<span class="hljs-name">a</span>&gt;</span> <span class="hljs-tag">&lt;<span class="hljs-name">time</span> <span class="hljs-attr">datetime</span>=<span class="hljs-string">"2026-01-01"</span>&gt;</span>January 1, 2026<span class="hljs-tag">&lt;/<span class="hljs-name">time</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">ul</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span></code></pre>
<aside class="note note-info"><p>The <code translate="no">&gt;</code> operator and the <code translate="no">href="{{ … }}"</code> attribute work here because they are written in the partial template, not in the Markdown body.</p></aside>
<h2 id="example-shortcodes-with-macros">Example: shortcodes with macros<a class="heading-anchor" href="#example-shortcodes-with-macros" aria-hidden="true" tabindex="-1"></a></h2>
<p><a href="https://twig.symfony.com/doc/3.x/tags/macro.html" target="_blank" rel="noopener noreferrer">Twig macros</a> can be used as <em>shortcodes</em> to insert rich HTML snippets in the body of a page.</p>
<p>Create the macros:</p>
<pre data-lang="twig"><code class="language-twig hljs twig" translate="no"><span class="hljs-comment">{# layouts/macros/shortcodes.html.twig #}</span><span class="xml">
</span><span class="hljs-template-tag">{% <span class="hljs-name"><span class="hljs-keyword">macro</span></span> youtube(id, title = 'YouTube video') %}</span><span class="xml">
<span class="hljs-tag">&lt;<span class="hljs-name">iframe</span> <span class="hljs-attr">src</span>=<span class="hljs-string">"https://www.youtube-nocookie.com/embed/</span></span></span><span class="hljs-template-variable">{{ id }}</span><span class="xml"><span class="hljs-tag"><span class="hljs-string">"</span> <span class="hljs-attr">title</span>=<span class="hljs-string">"</span></span></span><span class="hljs-template-variable">{{ title }}</span><span class="xml"><span class="hljs-tag"><span class="hljs-string">"</span> <span class="hljs-attr">width</span>=<span class="hljs-string">"560"</span> <span class="hljs-attr">height</span>=<span class="hljs-string">"315"</span> <span class="hljs-attr">loading</span>=<span class="hljs-string">"lazy"</span> <span class="hljs-attr">allowfullscreen</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">iframe</span>&gt;</span>
</span><span class="hljs-template-tag">{% <span class="hljs-name"><span class="hljs-keyword">endmacro</span></span> %}</span><span class="xml">

</span><span class="hljs-template-tag">{% <span class="hljs-name"><span class="hljs-keyword">macro</span></span> alert(message, type = 'info') %}</span><span class="xml">
<span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"alert alert-</span></span></span><span class="hljs-template-variable">{{ type }}</span><span class="xml"><span class="hljs-tag"><span class="hljs-string">"</span> <span class="hljs-attr">role</span>=<span class="hljs-string">"alert"</span>&gt;</span></span><span class="hljs-template-variable">{{ message }}</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">endmacro</span></span> %}</span></code></pre>
<p>Create a layout that imports the macros before rendering the content:</p>
<pre data-lang="twig"><code class="language-twig hljs twig" translate="no"><span class="hljs-comment">{# layouts/shortcodes.html.twig #}</span><span class="xml">
</span><span class="hljs-template-tag">{% <span class="hljs-name"><span class="hljs-keyword">extends</span></span> '_default/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><span class="hljs-template-tag">{% <span class="hljs-name"><span class="hljs-keyword">set</span></span> imports = "{% import 'macros/shortcodes.html.twig' as sc %}</span><span class="xml">" %}
</span><span class="hljs-template-variable">{{ <span class="hljs-name">include</span><span class="hljs-params">(template_from_string(imports ~ page.content, "dynamic content for page " ~ page.id)</span>) }}</span><span class="xml">
</span><span class="hljs-template-tag">{% <span class="hljs-name"><span class="hljs-keyword">endblock</span></span> content %}</span></code></pre>
<p>Use the shortcodes in a page:</p>
<pre data-lang="markdown"><code class="language-markdown hljs markdown" translate="no">---
title: "Demo video"
<span class="hljs-section">layout: shortcodes
---</span>
<span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">div</span>&gt;</span></span>
  {{ sc.alert('This video is in English.', 'warning') }}
<span class="xml"><span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span></span>

<span class="hljs-section">## Demo</span>

<span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">div</span>&gt;</span></span>
  {{ sc.youtube('NaB8JBfE7DY', 'Cecil demo') }}
<span class="xml"><span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span></span></code></pre>
<p>Output:</p>
<pre data-lang="html"><code class="language-html hljs xml" translate="no"><span class="hljs-tag">&lt;<span class="hljs-name">div</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"alert alert-warning"</span> <span class="hljs-attr">role</span>=<span class="hljs-string">"alert"</span>&gt;</span>This video is in English.<span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">h2</span> <span class="hljs-attr">id</span>=<span class="hljs-string">"demo"</span>&gt;</span>Demo<span class="hljs-tag">&lt;/<span class="hljs-name">h2</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">div</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">iframe</span> <span class="hljs-attr">src</span>=<span class="hljs-string">"https://www.youtube-nocookie.com/embed/NaB8JBfE7DY"</span> <span class="hljs-attr">title</span>=<span class="hljs-string">"Cecil demo"</span> <span class="hljs-attr">width</span>=<span class="hljs-string">"560"</span> <span class="hljs-attr">height</span>=<span class="hljs-string">"315"</span> <span class="hljs-attr">loading</span>=<span class="hljs-string">"lazy"</span> <span class="hljs-attr">allowfullscreen</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">iframe</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span></code></pre>
<aside class="note note-tip"><p>To reuse UI elements across templates and pages, see also <a href="/documentation/templates/components/">components</a>.</p></aside>]]>
    </content>
  </entry>
</feed>
