<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>11ty | 🃏 slides.nauda.dev 🃏</title><link>https://slides.nauda.dev/tag/11ty/</link><atom:link href="https://slides.nauda.dev/tag/11ty/index.xml" rel="self" type="application/rss+xml"/><description>11ty</description><generator>Wowchemy (https://wowchemy.com)</generator><language>en-us</language><lastBuildDate>Wed, 29 Nov 2023 15:35:31 +0700</lastBuildDate><image><url>https://slides.nauda.dev/media/icon_hube4dce13482f81b54a523f0927f755ce_23287_512x512_fill_lanczos_center_3.png</url><title>11ty</title><link>https://slides.nauda.dev/tag/11ty/</link></image><item><title>JAM Stack with 11ty</title><link>https://slides.nauda.dev/slides/jamstack-11ty/</link><pubDate>Wed, 29 Nov 2023 15:35:31 +0700</pubDate><guid>https://slides.nauda.dev/slides/jamstack-11ty/</guid><description>
&lt;section data-noprocess data-shortcode-slide
data-background-image="11ty-bg.png"
>
&lt;h1 id="jam-stack-with-11ty">JAM Stack with 11ty&lt;/h1>
&lt;p>Trung Pham Duy - November 2023&lt;/p>
&lt;hr>
&lt;h2 id="11ty">11ty&lt;/h2>
&lt;ul>
&lt;li>11ty - &lt;em>Eleventy&lt;/em> is a Node.js static site generator (SSG).&lt;/li>
&lt;li>Simple to start, incremental adoption.&lt;/li>
&lt;li>Fast build.&lt;/li>
&lt;li>Not require a JS framework: zero client-side JS by default.&lt;/li>
&lt;li>&lt;a href="https://www.11ty.dev/docs/" target="_blank" rel="noopener">Official docs&lt;/a>&lt;/li>
&lt;li>&lt;a href="https://github.com/11ty/eleventy/" target="_blank" rel="noopener">Github&lt;/a>&lt;/li>
&lt;/ul>
&lt;hr>
&lt;h3 id="template-languages">Template languages&lt;/h3>
&lt;p>HTML, &lt;a href="https://www.markdownguide.org/" target="_blank" rel="noopener">Markdown&lt;/a>, &lt;a href="https://github.com/11ty/webc" target="_blank" rel="noopener">WebC&lt;/a>, JavaScript, &lt;a href="https://mozilla.github.io/nunjucks/" target="_blank" rel="noopener">Nunjucks&lt;/a>, &lt;a href="https://shopify.github.io/liquid/" target="_blank" rel="noopener">Liquid&lt;/a>, &lt;a href="https://handlebarsjs.com/" target="_blank" rel="noopener">Handlebars&lt;/a>, &lt;a href="https://mustache.github.io/" target="_blank" rel="noopener">Mustache&lt;/a>, &lt;a href="https://ejs.co/" target="_blank" rel="noopener">EJS&lt;/a>, &lt;a href="https://haml.info/" target="_blank" rel="noopener">HAML&lt;/a>, &lt;a href="https://pugjs.org/api/getting-started.html" target="_blank" rel="noopener">Pug&lt;/a>, &lt;a href="https://www.11ty.dev/docs/languages/custom/" target="_blank" rel="noopener">&lt;em>Custom&lt;/em>&lt;/a>&lt;/p>
&lt;hr>
&lt;section data-noprocess data-shortcode-slide
data-background-image="11ty-bg.png"
>
&lt;h2 id="starter-project-create-a-blog-with-11ty">Starter project: Create a blog with 11ty&lt;/h2>
&lt;hr>
&lt;h3 id="system-requirements">System Requirements&lt;/h3>
&lt;ul>
&lt;li>Node.js &amp;gt;= 14&lt;/li>
&lt;/ul>
&lt;hr>
&lt;h3 id="site-structure">Site structure&lt;/h3>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-txt" data-lang="txt">&lt;span style="display:flex;">&lt;span>/ -&amp;gt; Home page
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>/about -&amp;gt; About page
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>/blog -&amp;gt; List of posts page
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>/blog/:id -&amp;gt; A single post page
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;hr>
&lt;h3 id="0-init-project">0. Init project&lt;/h3>
&lt;p>In terminal:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-sh" data-lang="sh">&lt;span style="display:flex;">&lt;span>mkdir 11ty-blog &lt;span style="color:#f92672">&amp;amp;&amp;amp;&lt;/span> cd 11ty-blog
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>npm init -y
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>npm install @11ty/eleventy
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>Add scripts to &lt;code>package.json&lt;/code>:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-json" data-lang="json">&lt;span style="display:flex;">&lt;span>{
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#f92672">&amp;#34;scripts&amp;#34;&lt;/span>: {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#f92672">&amp;#34;build&amp;#34;&lt;/span>: &lt;span style="color:#e6db74">&amp;#34;npx @11ty/eleventy&amp;#34;&lt;/span>,
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#f92672">&amp;#34;dev&amp;#34;&lt;/span>: &lt;span style="color:#e6db74">&amp;#34;npx @11ty/eleventy --serve&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>}
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;hr>
&lt;h3 id="1-home-page">1. Home page&lt;/h3>
&lt;p>At project root, add &lt;code>index.md&lt;/code>:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-md" data-lang="md">&lt;span style="display:flex;">&lt;span># My personal corner
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>Powered by 11ty.
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>In terminal, &lt;code>npm run build&lt;/code>. Output is folder &lt;code>_site&lt;/code>. In &lt;code>_site/index.html&lt;/code>:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-html" data-lang="html">&lt;span style="display:flex;">&lt;span>&amp;lt;&lt;span style="color:#f92672">h1&lt;/span>&amp;gt;My personal corner&amp;lt;/&lt;span style="color:#f92672">h1&lt;/span>&amp;gt;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&amp;lt;&lt;span style="color:#f92672">p&lt;/span>&amp;gt;Powered by 11ty&amp;lt;/&lt;span style="color:#f92672">p&lt;/span>&amp;gt;
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;hr>
&lt;h3 id="2-about-page">2. About page&lt;/h3>
&lt;p>At project root, add &lt;code>about/index.md&lt;/code>:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-md" data-lang="md">&lt;span style="display:flex;">&lt;span># About me
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>I love &lt;span style="font-weight:bold">__markdown__&lt;/span>!.
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#66d9ef">
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#66d9ef">&amp;gt; &lt;/span>&lt;span style="font-style:italic">This is a quote I said
&lt;/span>&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>Then build. Output:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-sh" data-lang="sh">&lt;span style="display:flex;">&lt;span>_site
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>│ index.html
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>└───about
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> index.html
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;hr>
&lt;h3 id="3-init-git">3. Init Git&lt;/h3>
&lt;p>In terminal:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-sh" data-lang="sh">&lt;span style="display:flex;">&lt;span>git init
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>At project root, add a &lt;code>.gitignore&lt;/code> file:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-txt" data-lang="txt">&lt;span style="display:flex;">&lt;span>node_modules
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>_site
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>Then commit.&lt;/p>
&lt;hr>
&lt;h3 id="4-layout">4. Layout&lt;/h3>
&lt;p>At project root, add &lt;code>_includes/layout.njk&lt;/code> (&lt;a href="https://mozilla.github.io/nunjucks/" target="_blank" rel="noopener">Nunjucks&lt;/a>):&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-html" data-lang="html">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#75715e">&amp;lt;!DOCTYPE html&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&amp;lt;&lt;span style="color:#f92672">html&lt;/span> &lt;span style="color:#a6e22e">lang&lt;/span>&lt;span style="color:#f92672">=&lt;/span>&lt;span style="color:#e6db74">&amp;#34;en&amp;#34;&lt;/span>&amp;gt;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&amp;lt;&lt;span style="color:#f92672">head&lt;/span>&amp;gt;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &amp;lt;&lt;span style="color:#f92672">meta&lt;/span> &lt;span style="color:#a6e22e">charset&lt;/span>&lt;span style="color:#f92672">=&lt;/span>&lt;span style="color:#e6db74">&amp;#34;UTF-8&amp;#34;&lt;/span>&amp;gt;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &amp;lt;&lt;span style="color:#f92672">meta&lt;/span> &lt;span style="color:#a6e22e">http-equiv&lt;/span>&lt;span style="color:#f92672">=&lt;/span>&lt;span style="color:#e6db74">&amp;#34;X-UA-Compatible&amp;#34;&lt;/span> &lt;span style="color:#a6e22e">content&lt;/span>&lt;span style="color:#f92672">=&lt;/span>&lt;span style="color:#e6db74">&amp;#34;IE=edge&amp;#34;&lt;/span>&amp;gt;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &amp;lt;&lt;span style="color:#f92672">meta&lt;/span> &lt;span style="color:#a6e22e">name&lt;/span>&lt;span style="color:#f92672">=&lt;/span>&lt;span style="color:#e6db74">&amp;#34;viewport&amp;#34;&lt;/span> &lt;span style="color:#a6e22e">content&lt;/span>&lt;span style="color:#f92672">=&lt;/span>&lt;span style="color:#e6db74">&amp;#34;width=device-width, initial-scale=1.0&amp;#34;&lt;/span>&amp;gt;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &amp;lt;&lt;span style="color:#f92672">link&lt;/span> &lt;span style="color:#a6e22e">rel&lt;/span>&lt;span style="color:#f92672">=&lt;/span>&lt;span style="color:#e6db74">&amp;#34;stylesheet&amp;#34;&lt;/span> &lt;span style="color:#a6e22e">href&lt;/span>&lt;span style="color:#f92672">=&lt;/span>&lt;span style="color:#e6db74">&amp;#34;https://unpkg.com/sakura.css/css/sakura.css&amp;#34;&lt;/span> &lt;span style="color:#a6e22e">type&lt;/span>&lt;span style="color:#f92672">=&lt;/span>&lt;span style="color:#e6db74">&amp;#34;text/css&amp;#34;&lt;/span>&amp;gt;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#75715e">&amp;lt;!-- Grab title from the page data and dump it here --&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &amp;lt;&lt;span style="color:#f92672">title&lt;/span>&amp;gt;{{ title }}&amp;lt;/&lt;span style="color:#f92672">title&lt;/span>&amp;gt;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&amp;lt;/&lt;span style="color:#f92672">head&lt;/span>&amp;gt;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&amp;lt;&lt;span style="color:#f92672">body&lt;/span>&amp;gt;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#75715e">&amp;lt;!-- Grab the content from the page data, dump it here, and mark it as safe --&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#75715e">&amp;lt;!-- Safe docs: https://mozilla.github.io/nunjucks/templating.html#safe --&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> {{ content | safe }}
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&amp;lt;/&lt;span style="color:#f92672">body&lt;/span>&amp;gt;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&amp;lt;/&lt;span style="color:#f92672">html&lt;/span>&amp;gt;
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;hr>
&lt;h3 id="4-layout-cont">4. Layout (cont)&lt;/h3>
&lt;p>Add &lt;a href="https://www.11ty.dev/docs/data-frontmatter/" target="_blank" rel="noopener">Frontmatter&lt;/a> to the top of markdown files.&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-yaml" data-lang="yaml">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#75715e"># index.md&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>---
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f92672">layout&lt;/span>: &lt;span style="color:#ae81ff">layout.njk&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f92672">title&lt;/span>: &lt;span style="color:#ae81ff">Homepage | My Blog&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>---
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>Now &lt;code>npm run dev&lt;/code>. Dev server hosted at &lt;a href="http://localhost:8080/" target="_blank" rel="noopener">&lt;code>http://localhost:8080/&lt;/code>&lt;/a>.&lt;/p>
&lt;hr>
&lt;h3 id="5-first-blog-post">5. First blog post&lt;/h3>
&lt;p>Add &lt;code>blog/what-is-a-cdn.md&lt;/code>:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-md" data-lang="md">&lt;span style="display:flex;">&lt;span>---
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>layout: layout.njk
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>title: What is a CDN
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>tags: [&amp;#39;blog&amp;#39;, &amp;#39;cdn&amp;#39;]
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>---
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span># What is a CDN
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>[&lt;span style="color:#f92672">Source&lt;/span>](&lt;span style="color:#a6e22e">https://www.cloudflare.com/learning/cdn/what-is-a-cdn/&lt;/span>)
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>A content delivery network (CDN) is a geographically distributed group of servers that caches content close to end users.
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>Access &lt;a href="http://localhost:8080/blog/what-is-a-cdn/" target="_blank" rel="noopener">http://localhost:8080/blog/what-is-a-cdn/&lt;/a>.&lt;/p>
&lt;hr>
&lt;h3 id="6-list-all-blog-posts">6. List all &lt;code>blog&lt;/code> posts&lt;/h3>
&lt;p>Add &lt;code>blog/index.njk&lt;/code>:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-html" data-lang="html">&lt;span style="display:flex;">&lt;span>---
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>layout: layout.njk
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>---
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&amp;lt;&lt;span style="color:#f92672">h1&lt;/span>&amp;gt;My blog&amp;lt;/&lt;span style="color:#f92672">h1&lt;/span>&amp;gt;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&amp;lt;&lt;span style="color:#f92672">ul&lt;/span>&amp;gt;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>{% for post in collections.blog %}
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &amp;lt;&lt;span style="color:#f92672">li&lt;/span>&amp;gt;&amp;lt;&lt;span style="color:#f92672">a&lt;/span> &lt;span style="color:#a6e22e">href&lt;/span>&lt;span style="color:#f92672">=&lt;/span>&lt;span style="color:#e6db74">&amp;#34;{{ post.url }}&amp;#34;&lt;/span>&amp;gt;{{ post.data.title }}&amp;lt;/&lt;span style="color:#f92672">a&lt;/span>&amp;gt;&amp;lt;/&lt;span style="color:#f92672">li&lt;/span>&amp;gt;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>{% endfor %}
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&amp;lt;/&lt;span style="color:#f92672">ul&lt;/span>&amp;gt;
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;blockquote>
&lt;p>Read: &lt;a href="https://www.11ty.dev/docs/collections/" target="_blank" rel="noopener">Collections (using tags) in 11ty&lt;/a>&lt;/p>
&lt;/blockquote>
&lt;hr>
&lt;h3 id="7-add-site-header">7. Add site header&lt;/h3>
&lt;p>At &lt;code>_includes/layout.njk&lt;/code>, after &lt;code>&amp;lt;body&amp;gt;&lt;/code>:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-html" data-lang="html">&lt;span style="display:flex;">&lt;span>&amp;lt;&lt;span style="color:#f92672">header&lt;/span>&amp;gt;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &amp;lt;&lt;span style="color:#f92672">nav&lt;/span>&amp;gt;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &amp;lt;&lt;span style="color:#f92672">ul&lt;/span>&amp;gt;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &amp;lt;&lt;span style="color:#f92672">li&lt;/span>&amp;gt;&amp;lt;&lt;span style="color:#f92672">a&lt;/span> &lt;span style="color:#a6e22e">href&lt;/span>&lt;span style="color:#f92672">=&lt;/span>&lt;span style="color:#e6db74">&amp;#34;/&amp;#34;&lt;/span>&amp;gt;Home&amp;lt;/&lt;span style="color:#f92672">a&lt;/span>&amp;gt;&amp;lt;/&lt;span style="color:#f92672">li&lt;/span>&amp;gt;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &amp;lt;&lt;span style="color:#f92672">li&lt;/span>&amp;gt;&amp;lt;&lt;span style="color:#f92672">a&lt;/span> &lt;span style="color:#a6e22e">href&lt;/span>&lt;span style="color:#f92672">=&lt;/span>&lt;span style="color:#e6db74">&amp;#34;/about&amp;#34;&lt;/span>&amp;gt;About&amp;lt;/&lt;span style="color:#f92672">a&lt;/span>&amp;gt;&amp;lt;/&lt;span style="color:#f92672">li&lt;/span>&amp;gt;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &amp;lt;&lt;span style="color:#f92672">li&lt;/span>&amp;gt;&amp;lt;&lt;span style="color:#f92672">a&lt;/span> &lt;span style="color:#a6e22e">href&lt;/span>&lt;span style="color:#f92672">=&lt;/span>&lt;span style="color:#e6db74">&amp;#34;/blog&amp;#34;&lt;/span>&amp;gt;Blog&amp;lt;/&lt;span style="color:#f92672">a&lt;/span>&amp;gt;&amp;lt;/&lt;span style="color:#f92672">li&lt;/span>&amp;gt;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &amp;lt;/&lt;span style="color:#f92672">ul&lt;/span>&amp;gt;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &amp;lt;/&lt;span style="color:#f92672">nav&lt;/span>&amp;gt;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&amp;lt;/&lt;span style="color:#f92672">header&lt;/span>&amp;gt;
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;blockquote>
&lt;p>Read: &lt;a href="https://www.11ty.dev/docs/collections/" target="_blank" rel="noopener">Collections (using tags) in 11ty&lt;/a>&lt;/p>
&lt;/blockquote>
&lt;hr>
&lt;h3 id="8-second-blog-post">8. Second blog post&lt;/h3>
&lt;p>Add &lt;code>blog/webdev/css-intro.md&lt;/code>:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-md" data-lang="md">&lt;span style="display:flex;">&lt;span>---
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>layout: layout.njk
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>title: &amp;#34;CSS: Cascading Style Sheets&amp;#34;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>tags: [&amp;#39;blog&amp;#39;, &amp;#39;css&amp;#39;]
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>---
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span># CSS: Cascading Style Sheets
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>[&lt;span style="color:#f92672">Source&lt;/span>](&lt;span style="color:#a6e22e">https://developer.mozilla.org/en-US/docs/Web/CSS&lt;/span>)
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>Cascading Style Sheets (CSS) is a stylesheet language used to describe the presentation of a document written in HTML or XML (including XML dialects such as SVG, MathML or XHTML).
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>CSS describes how elements should be rendered on screen, on paper, in speech, or on other media.
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>Access &lt;a href="http://localhost:8080/blog/webdev/css-intro/" target="_blank" rel="noopener">http://localhost:8080/blog/webdev/css-intro/&lt;/a>.&lt;/p>
&lt;hr>
&lt;h3 id="9-add-css-file">9. Add CSS file&lt;/h3>
&lt;p>At root, create &lt;code>css/styles.css&lt;/code>:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-css" data-lang="css">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f92672">nav&lt;/span> &lt;span style="color:#f92672">&amp;gt;&lt;/span> &lt;span style="color:#f92672">ul&lt;/span> {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#66d9ef">margin&lt;/span>: &lt;span style="color:#ae81ff">0&lt;/span>;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#66d9ef">padding&lt;/span>: &lt;span style="color:#ae81ff">0&lt;/span>;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#66d9ef">list-style&lt;/span>: &lt;span style="color:#66d9ef">none&lt;/span>;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#66d9ef">display&lt;/span>: &lt;span style="color:#66d9ef">flex&lt;/span>;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> gap: &lt;span style="color:#ae81ff">1&lt;/span>&lt;span style="color:#66d9ef">rem&lt;/span>;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>}
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;span class="fragment " >
&lt;p>Add to &lt;code>_includes/layout.njk&lt;/code>&amp;rsquo;s &lt;code>&amp;lt;head&amp;gt;&lt;/code>&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-html" data-lang="html">&lt;span style="display:flex;">&lt;span>&amp;lt;&lt;span style="color:#f92672">link&lt;/span> &lt;span style="color:#a6e22e">rel&lt;/span>&lt;span style="color:#f92672">=&lt;/span>&lt;span style="color:#e6db74">&amp;#34;stylesheet&amp;#34;&lt;/span> &lt;span style="color:#a6e22e">href&lt;/span>&lt;span style="color:#f92672">=&lt;/span>&lt;span style="color:#e6db74">&amp;#34;/css/styles.css&amp;#34;&lt;/span> &lt;span style="color:#a6e22e">type&lt;/span>&lt;span style="color:#f92672">=&lt;/span>&lt;span style="color:#e6db74">&amp;#34;text/css&amp;#34;&lt;/span>&amp;gt;
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>
&lt;/span>
&lt;hr>
&lt;h3 id="9-add-css-file-cont">9. Add CSS file (cont)&lt;/h3>
&lt;p>At root, add &lt;code>.eleventy.js&lt;/code>:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-js" data-lang="js">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#a6e22e">module&lt;/span>.&lt;span style="color:#a6e22e">exports&lt;/span> &lt;span style="color:#f92672">=&lt;/span> &lt;span style="color:#66d9ef">function&lt;/span> (&lt;span style="color:#a6e22e">eleventyConfig&lt;/span>) {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#a6e22e">eleventyConfig&lt;/span>.&lt;span style="color:#a6e22e">addPassthroughCopy&lt;/span>(&lt;span style="color:#e6db74">&amp;#39;css/styles.css&amp;#39;&lt;/span>);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#66d9ef">return&lt;/span> {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#a6e22e">passthroughFileCopy&lt;/span>&lt;span style="color:#f92672">:&lt;/span> &lt;span style="color:#66d9ef">true&lt;/span>,
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> };
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>};
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>Restart dev server.&lt;/p>
&lt;hr>
&lt;h3 id="tools">Tools&lt;/h3>
&lt;ul>
&lt;li>&lt;a href="https://urltomarkdown.com/" target="_blank" rel="noopener">URL to markdown&lt;/a>&lt;/li>
&lt;/ul>
&lt;hr>
&lt;section data-noprocess data-shortcode-slide
data-background-image="11ty-bg.png"
>
&lt;h2 id="front-matter">Front Matter&lt;/h2>
&lt;hr>
&lt;h3 id="front-matter-format">Front Matter Format&lt;/h3>
&lt;p>Metadata normally at the top of template files.&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-yaml" data-lang="yaml">&lt;span style="display:flex;">&lt;span>---
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f92672">title&lt;/span>: &lt;span style="color:#ae81ff">My page title&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>---
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>The above is using YAML syntax.&lt;/p>
&lt;p>As 11ty uses &lt;a href="https://github.com/jonschlinkert/gray-matter" target="_blank" rel="noopener">&lt;code>gray-matter&lt;/code>&lt;/a> to parse Front Matter, use can use other formats like &lt;code>json&lt;/code> and JS Objects as well.&lt;/p>
&lt;blockquote>
&lt;p>&lt;a href="https://www.11ty.dev/docs/data-frontmatter-customize/" target="_blank" rel="noopener">Custom Front Matter Options&lt;/a>&lt;/p>
&lt;/blockquote>
&lt;hr>
&lt;h3 id="front-matter-in-json">Front Matter in JSON&lt;/h3>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-html" data-lang="html">&lt;span style="display:flex;">&lt;span>---json
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>{
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &amp;#34;title&amp;#34;: &amp;#34;My page title&amp;#34;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>}
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>---
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#75715e">&amp;lt;!doctype html&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&amp;lt;&lt;span style="color:#f92672">html&lt;/span>&amp;gt;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>...
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;hr>
&lt;h3 id="front-matter-in-js-object">Front Matter in JS Object&lt;/h3>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-html" data-lang="html">&lt;span style="display:flex;">&lt;span>---js
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>{
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> title: &amp;#34;My page title&amp;#34;,
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> currentDate: function() {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> // You can have a JavaScript function here!
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> return (new Date()).toLocaleString();
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>}
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>---
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&amp;lt;&lt;span style="color:#f92672">h1&lt;/span>&amp;gt;{{ title }}&amp;lt;/&lt;span style="color:#f92672">h1&lt;/span>&amp;gt;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&amp;lt;&lt;span style="color:#f92672">p&lt;/span>&amp;gt;Published on {{ currentDate() }}&amp;lt;/&lt;span style="color:#f92672">p&lt;/span>&amp;gt;
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;hr>
&lt;h3 id="front-matter---permalink">Front Matter - &lt;code>permalink&lt;/code>&lt;/h3>
&lt;ul>
&lt;li>&lt;a href="https://www.11ty.dev/docs/permalinks/" target="_blank" rel="noopener">&lt;code>permalink&lt;/code>&lt;/a>: Change the output target of the current template.&lt;/li>
&lt;/ul>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-yaml" data-lang="yaml">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#75715e"># Map to new path&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f92672">permalink&lt;/span>: &lt;span style="color:#e6db74">&amp;#34;this-is-a-new-path/subdirectory/testing/index.html&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#75715e"># skip writing file&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f92672">permalink&lt;/span>: &lt;span style="color:#66d9ef">false&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#75715e"># with template syntax&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f92672">permalink&lt;/span>: &lt;span style="color:#e6db74">&amp;#34;subdir/{{ title | slugify }}/index.html&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;hr>
&lt;h3 id="front-matter---layout">Front Matter - &lt;code>layout&lt;/code>&lt;/h3>
&lt;ul>
&lt;li>&lt;a href="https://www.11ty.dev/docs/layouts/" target="_blank" rel="noopener">&lt;code>layout&lt;/code>&lt;/a>: Wrap current template with a layout template found in the &lt;code>_includes&lt;/code> folder.&lt;/li>
&lt;/ul>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-yaml" data-lang="yaml">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#75715e"># _includes/layout.njk&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f92672">layout&lt;/span>: &lt;span style="color:#ae81ff">layout.njk&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#75715e"># _includes/default/layout.njk&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f92672">layout&lt;/span>: &lt;span style="color:#ae81ff">default/layout.njk&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;hr>
&lt;h3 id="front-matter---pagination">Front Matter - &lt;code>pagination&lt;/code>&lt;/h3>
&lt;ul>
&lt;li>&lt;a href="https://www.11ty.dev/docs/pagination/" target="_blank" rel="noopener">&lt;code>pagination&lt;/code>&lt;/a>: Enable to iterate over data. Output multiple HTML files from a single template.&lt;/li>
&lt;/ul>
&lt;hr>
&lt;h3 id="front-matter---tags">Front Matter - &lt;code>tags&lt;/code>&lt;/h3>
&lt;ul>
&lt;li>&lt;a href="https://www.11ty.dev/docs/collections/" target="_blank" rel="noopener">&lt;code>tags&lt;/code>&lt;/a>: A single string or array that identifies that a piece of content is part of a collection. Collections can be reused in any other template.&lt;/li>
&lt;/ul>
&lt;hr>
&lt;h3 id="front-matter---date">Front Matter - &lt;code>date&lt;/code>&lt;/h3>
&lt;ul>
&lt;li>&lt;a href="https://www.11ty.dev/docs/dates/" target="_blank" rel="noopener">&lt;code>date&lt;/code>&lt;/a>: Override the default date (file creation) to customize how the file is sorted in a collection.&lt;/li>
&lt;/ul>
&lt;hr>
&lt;h3 id="front-matter---eleventycomputed">Front Matter - &lt;code>eleventyComputed&lt;/code>&lt;/h3>
&lt;ul>
&lt;li>&lt;a href="https://www.11ty.dev/docs/data-computed/" target="_blank" rel="noopener">&lt;code>eleventyComputed&lt;/code>&lt;/a>: Programmatically set data values based on other values in your &lt;a href="https://www.11ty.dev/docs/data-cascade/" target="_blank" rel="noopener">data cascade&lt;/a>.&lt;/li>
&lt;/ul>
&lt;hr>
&lt;h3 id="front-matter---all-special-keys">Front Matter - All special keys&lt;/h3>
&lt;p>&lt;a href="https://www.11ty.dev/docs/data-configuration/" target="_blank" rel="noopener">Configure Your Templates&lt;/a>&lt;/p>
&lt;hr>
&lt;section data-noprocess data-shortcode-slide
data-background-image="11ty-bg.png"
>
&lt;h2 id="global-data">Global Data&lt;/h2>
&lt;hr>
&lt;h2 id="what-is-global-data">What is Global Data&lt;/h2>
&lt;p>Global data is exposed to every template in an Eleventy project, can be either:&lt;/p>
&lt;ul>
&lt;li>&lt;em>Global data files&lt;/em>: JSON and JavaScript files placed inside of the &lt;em>global data folder&lt;/em>.&lt;/li>
&lt;li>Declared in 11ty config file (from v1.0.0).&lt;/li>
&lt;/ul>
&lt;hr>
&lt;h2 id="global-data-files">Global Data files&lt;/h2>
&lt;ul>
&lt;li>&lt;em>Global data folder&lt;/em> is placed inside &lt;a href="https://www.11ty.dev/docs/config/#input-directory" target="_blank" rel="noopener">dir.input configuration option&lt;/a> (&lt;code>.&lt;/code> by default), and the name of the global data folder is &lt;a href="https://www.11ty.dev/docs/config/#directory-for-global-data-files" target="_blank" rel="noopener">dir.data configuration option&lt;/a> (&lt;code>_data&lt;/code> by default).&lt;/li>
&lt;li>All &lt;code>*.json&lt;/code> and &lt;code>module.exports&lt;/code> values from &lt;code>*.js&lt;/code> files in this folder will be added into a global data object available to all templates.&lt;/li>
&lt;/ul>
&lt;hr>
&lt;h2 id="practice-header-as-global-data">Practice: Header as Global data&lt;/h2>
&lt;hr>
&lt;h3 id="use-global-data-file">Use global data file&lt;/h3>
&lt;p>Create &lt;code>_data/header.json&lt;/code>:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-json" data-lang="json">&lt;span style="display:flex;">&lt;span>[
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#f92672">&amp;#34;url&amp;#34;&lt;/span>: &lt;span style="color:#e6db74">&amp;#34;/&amp;#34;&lt;/span>,
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#f92672">&amp;#34;label&amp;#34;&lt;/span>: &lt;span style="color:#e6db74">&amp;#34;Home&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> },
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#f92672">&amp;#34;url&amp;#34;&lt;/span>: &lt;span style="color:#e6db74">&amp;#34;/about&amp;#34;&lt;/span>,
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#f92672">&amp;#34;label&amp;#34;&lt;/span>: &lt;span style="color:#e6db74">&amp;#34;About&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> },
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#f92672">&amp;#34;url&amp;#34;&lt;/span>: &lt;span style="color:#e6db74">&amp;#34;/blog&amp;#34;&lt;/span>,
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#f92672">&amp;#34;label&amp;#34;&lt;/span>: &lt;span style="color:#e6db74">&amp;#34;Blog&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>]
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;hr>
&lt;h3 id="use-global-json-data-file-cont">Use global JSON data file (cont)&lt;/h3>
&lt;p>In &lt;code>_includes/layout.njk&lt;/code>, replace &lt;code>header&amp;gt;nav&amp;gt;ul&lt;/code>&amp;rsquo;s content with:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-html" data-lang="html">&lt;span style="display:flex;">&lt;span>{% for item in header %}
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &amp;lt;&lt;span style="color:#f92672">li&lt;/span>&amp;gt;&amp;lt;&lt;span style="color:#f92672">a&lt;/span> &lt;span style="color:#a6e22e">href&lt;/span>&lt;span style="color:#f92672">=&lt;/span>&lt;span style="color:#e6db74">&amp;#34;{{item.url}}&amp;#34;&lt;/span>&amp;gt;{{item.label}}&amp;lt;/&lt;span style="color:#f92672">a&lt;/span>&amp;gt;&amp;lt;/&lt;span style="color:#f92672">li&lt;/span>&amp;gt;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>{% endfor %}
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>As you can see, &lt;code>header&lt;/code> magically appears as global variable inside template files.&lt;/p>
&lt;hr>
&lt;h3 id="use-11ty-config-file">Use 11ty config file&lt;/h3>
&lt;p>In &lt;code>.eleventy.js&lt;/code>:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-js" data-lang="js">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#a6e22e">module&lt;/span>.&lt;span style="color:#a6e22e">exports&lt;/span> &lt;span style="color:#f92672">=&lt;/span> &lt;span style="color:#66d9ef">function&lt;/span> (&lt;span style="color:#a6e22e">eleventyConfig&lt;/span>) {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#75715e">//...other code
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#75715e">&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#a6e22e">eleventyConfig&lt;/span>.&lt;span style="color:#a6e22e">addGlobalData&lt;/span>(&lt;span style="color:#e6db74">&amp;#34;header&amp;#34;&lt;/span>, [
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#e6db74">&amp;#34;url&amp;#34;&lt;/span>&lt;span style="color:#f92672">:&lt;/span> &lt;span style="color:#e6db74">&amp;#34;/&amp;#34;&lt;/span>,
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#e6db74">&amp;#34;label&amp;#34;&lt;/span>&lt;span style="color:#f92672">:&lt;/span> &lt;span style="color:#e6db74">&amp;#34;Home&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> },
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#e6db74">&amp;#34;url&amp;#34;&lt;/span>&lt;span style="color:#f92672">:&lt;/span> &lt;span style="color:#e6db74">&amp;#34;/about&amp;#34;&lt;/span>,
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#e6db74">&amp;#34;label&amp;#34;&lt;/span>&lt;span style="color:#f92672">:&lt;/span> &lt;span style="color:#e6db74">&amp;#34;About&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> },
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#e6db74">&amp;#34;url&amp;#34;&lt;/span>&lt;span style="color:#f92672">:&lt;/span> &lt;span style="color:#e6db74">&amp;#34;/blog&amp;#34;&lt;/span>,
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#e6db74">&amp;#34;label&amp;#34;&lt;/span>&lt;span style="color:#f92672">:&lt;/span> &lt;span style="color:#e6db74">&amp;#34;Blog&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> ]);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#75715e">//...other code
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#75715e">&lt;/span>};
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;hr>
&lt;h3 id="remote-global-data">Remote global data&lt;/h3>
&lt;p>Global data can come from &lt;a href="https://jsonplaceholder.typicode.com/posts" target="_blank" rel="noopener">other services&lt;/a>. Add &lt;code>_data/posts.js&lt;/code>.&lt;/p>
&lt;blockquote>
&lt;p>npm install ofetch&lt;/p>
&lt;/blockquote>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-js" data-lang="js">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#66d9ef">const&lt;/span> { &lt;span style="color:#a6e22e">ofetch&lt;/span> } &lt;span style="color:#f92672">=&lt;/span> &lt;span style="color:#a6e22e">require&lt;/span>(&lt;span style="color:#e6db74">&amp;#39;ofetch&amp;#39;&lt;/span>);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#a6e22e">module&lt;/span>.&lt;span style="color:#a6e22e">exports&lt;/span> &lt;span style="color:#f92672">=&lt;/span> &lt;span style="color:#66d9ef">async&lt;/span> &lt;span style="color:#66d9ef">function&lt;/span> () {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#66d9ef">const&lt;/span> &lt;span style="color:#a6e22e">url&lt;/span> &lt;span style="color:#f92672">=&lt;/span> &lt;span style="color:#e6db74">&amp;#39;https://jsonplaceholder.typicode.com/posts&amp;#39;&lt;/span>;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#66d9ef">return&lt;/span> &lt;span style="color:#a6e22e">ofetch&lt;/span>(&lt;span style="color:#a6e22e">url&lt;/span>);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>};
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;span class="fragment " >
&lt;blockquote>
&lt;p>Of course, you can use any HTTP client: axios, ky, node-fetch&amp;hellip;&lt;/p>
&lt;/blockquote>
&lt;/span>
&lt;hr>
&lt;h3 id="remote-global-data-cont">Remote global data (cont)&lt;/h3>
&lt;p>Add &lt;code>posts/index.njk&lt;/code>.&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-html" data-lang="html">&lt;span style="display:flex;">&lt;span>---
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>title: Homepage | My blog
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>layout: layout.njk
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>---
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&amp;lt;&lt;span style="color:#f92672">h1&lt;/span>&amp;gt;My blog&amp;lt;/&lt;span style="color:#f92672">h1&lt;/span>&amp;gt;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&amp;lt;&lt;span style="color:#f92672">p&lt;/span>&amp;gt;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>Powered by 11ty.
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&amp;lt;/&lt;span style="color:#f92672">p&lt;/span>&amp;gt;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&amp;lt;&lt;span style="color:#f92672">ul&lt;/span>&amp;gt;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>{% for post in posts %}
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &amp;lt;&lt;span style="color:#f92672">li&lt;/span>&amp;gt;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> {{ post.title }}
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &amp;lt;/&lt;span style="color:#f92672">li&lt;/span>&amp;gt;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>{% endfor %}
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&amp;lt;/&lt;span style="color:#f92672">ul&lt;/span>&amp;gt;
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;hr>
&lt;h3 id="remote-global-data-cont-1">Remote global data (cont)&lt;/h3>
&lt;p>In dev, every time you hit save, API is called 😭.&lt;/p>
&lt;p>
&lt;figure >
&lt;div class="d-flex justify-content-center">
&lt;div class="w-100" >&lt;img alt=""
src="https://slides.nauda.dev/slides/jamstack-11ty/11ty-global-fetch.gif"
loading="lazy" data-zoomable />&lt;/div>
&lt;/div>&lt;/figure>
&lt;/p>
&lt;hr>
&lt;h3 id="remote-global-data-cont-2">Remote global data (cont)&lt;/h3>
&lt;p>API quota will run out soon 💀.&lt;/p>
&lt;p>
&lt;figure >
&lt;div class="d-flex justify-content-center">
&lt;div class="w-100" >&lt;img alt="" srcset="
/slides/jamstack-11ty/api-limit_hu0ea55141e4b4484895b18e77a64f4787_119762_eb5a957405534044566fe58c8eff1e98.webp 400w,
/slides/jamstack-11ty/api-limit_hu0ea55141e4b4484895b18e77a64f4787_119762_14175077784c5dd00aae8b4b184a920d.webp 760w,
/slides/jamstack-11ty/api-limit_hu0ea55141e4b4484895b18e77a64f4787_119762_1200x1200_fit_q75_h2_lanczos_3.webp 1200w"
src="https://slides.nauda.dev/slides/jamstack-11ty/api-limit_hu0ea55141e4b4484895b18e77a64f4787_119762_eb5a957405534044566fe58c8eff1e98.webp"
width="760"
height="476"
loading="lazy" data-zoomable />&lt;/div>
&lt;/div>&lt;/figure>
&lt;/p>
&lt;hr>
&lt;section data-noprocess data-shortcode-slide
data-background-image="11ty-bg.png"
>
&lt;h2 id="plugins">Plugins&lt;/h2>
&lt;hr>
&lt;h3 id="plugins-in-11ty">Plugins in 11ty&lt;/h3>
&lt;p>Plugins are custom code that Eleventy can import into a project from an external repository.&lt;/p>
&lt;ul>
&lt;li>&lt;a href="https://www.11ty.dev/docs/plugins/#list-of-official-plugins" target="_blank" rel="noopener">List of official plugins&lt;/a>&lt;/li>
&lt;li>&lt;a href="https://www.11ty.dev/docs/plugins/#community-contributed-plugins" target="_blank" rel="noopener">List of community plugins&lt;/a>&lt;/li>
&lt;/ul>
&lt;hr>
&lt;h3 id="cache-api-using-plugin-fetchhttpswww11tydevdocspluginsfetch">Cache API using plugin &lt;a href="https://www.11ty.dev/docs/plugins/fetch/" target="_blank" rel="noopener">Fetch&lt;/a>&lt;/h3>
&lt;ul>
&lt;li>Fetch network resources and cache them so you don’t bombard your API (or other resources).&lt;/li>
&lt;li>Do this &lt;em>at configurable intervals&lt;/em> — &lt;em>not with every build&lt;/em>!
&lt;ul>
&lt;li>Once per minute, or once per hour, once per day, or however often you like!&lt;/li>
&lt;/ul>
&lt;/li>
&lt;/ul>
&lt;hr>
&lt;h3 id="plugin-fetchhttpswww11tydevdocspluginsfetch-usage">Plugin &lt;a href="https://www.11ty.dev/docs/plugins/fetch/" target="_blank" rel="noopener">Fetch&lt;/a> usage&lt;/h3>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-sh" data-lang="sh">&lt;span style="display:flex;">&lt;span>npm install @11ty/eleventy-fetch
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>In &lt;code>_data/posts.js&lt;/code>.&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-js" data-lang="js">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#66d9ef">const&lt;/span> &lt;span style="color:#a6e22e">EleventyFetch&lt;/span> &lt;span style="color:#f92672">=&lt;/span> &lt;span style="color:#a6e22e">require&lt;/span>(&lt;span style="color:#e6db74">&amp;#39;@11ty/eleventy-fetch&amp;#39;&lt;/span>);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#a6e22e">module&lt;/span>.&lt;span style="color:#a6e22e">exports&lt;/span> &lt;span style="color:#f92672">=&lt;/span> &lt;span style="color:#66d9ef">async&lt;/span> &lt;span style="color:#66d9ef">function&lt;/span> () {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#66d9ef">const&lt;/span> &lt;span style="color:#a6e22e">url&lt;/span> &lt;span style="color:#f92672">=&lt;/span> &lt;span style="color:#e6db74">&amp;#39;https://jsonplaceholder.typicode.com/posts&amp;#39;&lt;/span>;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#66d9ef">return&lt;/span> &lt;span style="color:#a6e22e">EleventyFetch&lt;/span>(&lt;span style="color:#a6e22e">url&lt;/span>, {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#a6e22e">duration&lt;/span>&lt;span style="color:#f92672">:&lt;/span> &lt;span style="color:#e6db74">&amp;#39;1m&amp;#39;&lt;/span>, &lt;span style="color:#75715e">// save for 1 minute
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#75715e">&lt;/span> &lt;span style="color:#a6e22e">type&lt;/span>&lt;span style="color:#f92672">:&lt;/span> &lt;span style="color:#e6db74">&amp;#39;json&amp;#39;&lt;/span>, &lt;span style="color:#75715e">// we’ll parse JSON for you
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#75715e">&lt;/span> });
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>};
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;hr>
&lt;h3 id="plugin-fetchhttpswww11tydevdocspluginsfetch-usage-cont">Plugin &lt;a href="https://www.11ty.dev/docs/plugins/fetch/" target="_blank" rel="noopener">Fetch&lt;/a> usage (cont)&lt;/h3>
&lt;p>API is only called when cache is stale (&amp;gt; 1 minute).&lt;/p>
&lt;p>
&lt;figure >
&lt;div class="d-flex justify-content-center">
&lt;div class="w-100" >&lt;img alt=""
src="https://slides.nauda.dev/slides/jamstack-11ty/11ty-fetch-plugin.gif"
loading="lazy" data-zoomable />&lt;/div>
&lt;/div>&lt;/figure>
&lt;/p>
&lt;hr>
&lt;h3 id="notable-official-plugins">Notable official plugins&lt;/h3>
&lt;ul>
&lt;li>&lt;a href="https://www.11ty.dev/docs/plugins/navigation/" target="_blank" rel="noopener">Navigation&lt;/a>: creating infinite-depth hierarchical navigation.&lt;/li>
&lt;li>&lt;a href="https://www.11ty.dev/docs/plugins/image/" target="_blank" rel="noopener">Image&lt;/a>: low level utility to perform build-time image transformations for both vector and raster images.&lt;/li>
&lt;li>&lt;a href="https://www.11ty.dev/docs/plugins/i18n/" target="_blank" rel="noopener">I18n&lt;/a>: manage pages and linking between localized content.&lt;/li>
&lt;li>&lt;a href="https://www.11ty.dev/docs/plugins/rss/" target="_blank" rel="noopener">RSS&lt;/a>: generating an RSS feed (actually an Atom feed, but who’s counting) using the Nunjucks templating engine.&lt;/li>
&lt;/ul>
&lt;hr>
&lt;section data-noprocess data-shortcode-slide
data-background-image="11ty-bg.png"
>
&lt;h2 id="paginationhttpswww11tydevdocspagination">&lt;a href="https://www.11ty.dev/docs/pagination/" target="_blank" rel="noopener">Pagination&lt;/a>&lt;/h2>
&lt;hr>
&lt;h3 id="paginate-posts">Paginate posts&lt;/h3>
&lt;p>Each page with &lt;code>size=5&lt;/code>. At &lt;code>posts/index.njk&lt;/code>.&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-yaml" data-lang="yaml">&lt;span style="display:flex;">&lt;span>---
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f92672">title&lt;/span>: &lt;span style="color:#ae81ff">Posts&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f92672">layout&lt;/span>: &lt;span style="color:#ae81ff">layout.njk&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f92672">pagination&lt;/span>:
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#f92672">data&lt;/span>: &lt;span style="color:#ae81ff">posts&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#f92672">size&lt;/span>: &lt;span style="color:#ae81ff">5&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f92672">permalink&lt;/span>: &lt;span style="color:#e6db74">&amp;#34;/posts/{{ pagination.pageNumber }}/index.html&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>---
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#ae81ff">&amp;lt;h1&amp;gt;Posts&amp;lt;/h1&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#ae81ff">&amp;lt;ul&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>{&lt;span style="color:#ae81ff">% for item in pagination.items %}&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#ae81ff">&amp;lt;li&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#ae81ff">&amp;lt;a href=&amp;#34;/posts/{{ item.title | slugify }}&amp;#34;&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> {{ &lt;span style="color:#ae81ff">item.title }}&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#ae81ff">&amp;lt;/a&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#ae81ff">&amp;lt;/li&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>{&lt;span style="color:#ae81ff">% endfor %}&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#ae81ff">&amp;lt;/ul&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;blockquote>
&lt;p>&lt;code>pagination.pageNumber&lt;/code> starts from 0.&lt;/p>
&lt;/blockquote>
&lt;hr>
&lt;h3 id="add-pagination-navigation">Add pagination navigation&lt;/h3>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-html" data-lang="html">&lt;span style="display:flex;">&lt;span>&amp;lt;&lt;span style="color:#f92672">nav&lt;/span> &lt;span style="color:#a6e22e">aria-labelledby&lt;/span>&lt;span style="color:#f92672">=&lt;/span>&lt;span style="color:#e6db74">&amp;#34;my-pagination&amp;#34;&lt;/span>&amp;gt;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &amp;lt;&lt;span style="color:#f92672">ul&lt;/span>&amp;gt;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &amp;lt;&lt;span style="color:#f92672">li&lt;/span>&amp;gt;{% if page.url != pagination.href.first %}&amp;lt;&lt;span style="color:#f92672">a&lt;/span> &lt;span style="color:#a6e22e">href&lt;/span>&lt;span style="color:#f92672">=&lt;/span>&lt;span style="color:#e6db74">&amp;#34;{{ pagination.href.first }}&amp;#34;&lt;/span>&amp;gt;First&amp;lt;/&lt;span style="color:#f92672">a&lt;/span>&amp;gt;{% else %}First{% endif %}&amp;lt;/&lt;span style="color:#f92672">li&lt;/span>&amp;gt;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &amp;lt;&lt;span style="color:#f92672">li&lt;/span>&amp;gt;{% if pagination.href.previous %}&amp;lt;&lt;span style="color:#f92672">a&lt;/span> &lt;span style="color:#a6e22e">href&lt;/span>&lt;span style="color:#f92672">=&lt;/span>&lt;span style="color:#e6db74">&amp;#34;{{ pagination.href.previous }}&amp;#34;&lt;/span>&amp;gt;Previous&amp;lt;/&lt;span style="color:#f92672">a&lt;/span>&amp;gt;{% else %}Previous{% endif %}&amp;lt;/&lt;span style="color:#f92672">li&lt;/span>&amp;gt;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>{%- for pageEntry in pagination.pages %}
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &amp;lt;&lt;span style="color:#f92672">li&lt;/span>&amp;gt;&amp;lt;&lt;span style="color:#f92672">a&lt;/span> &lt;span style="color:#a6e22e">href&lt;/span>&lt;span style="color:#f92672">=&lt;/span>&lt;span style="color:#e6db74">&amp;#34;{{ pagination.hrefs[ loop.index0 ] }}&amp;#34;&lt;/span>&lt;span style="color:#960050;background-color:#1e0010">{%&lt;/span> &lt;span style="color:#a6e22e">if&lt;/span> &lt;span style="color:#a6e22e">page&lt;/span>&lt;span style="color:#960050;background-color:#1e0010">.&lt;/span>&lt;span style="color:#a6e22e">url &lt;/span>&lt;span style="color:#f92672">=&lt;/span>&lt;span style="color:#e6db74">=&lt;/span> &lt;span style="color:#a6e22e">pagination&lt;/span>&lt;span style="color:#960050;background-color:#1e0010">.&lt;/span>&lt;span style="color:#a6e22e">hrefs&lt;/span>&lt;span style="color:#960050;background-color:#1e0010">[&lt;/span> &lt;span style="color:#a6e22e">loop&lt;/span>&lt;span style="color:#960050;background-color:#1e0010">.&lt;/span>&lt;span style="color:#a6e22e">index0&lt;/span> &lt;span style="color:#960050;background-color:#1e0010">]&lt;/span> &lt;span style="color:#960050;background-color:#1e0010">%}&lt;/span> &lt;span style="color:#a6e22e">aria-current&lt;/span>&lt;span style="color:#f92672">=&lt;/span>&lt;span style="color:#e6db74">&amp;#34;page&amp;#34;&lt;/span>&lt;span style="color:#960050;background-color:#1e0010">{%&lt;/span> &lt;span style="color:#a6e22e">endif&lt;/span> &lt;span style="color:#960050;background-color:#1e0010">%}&lt;/span>&amp;gt;{{ loop.index }}&amp;lt;/&lt;span style="color:#f92672">a&lt;/span>&amp;gt;&amp;lt;/&lt;span style="color:#f92672">li&lt;/span>&amp;gt;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>{%- endfor %}
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &amp;lt;&lt;span style="color:#f92672">li&lt;/span>&amp;gt;{% if pagination.href.next %}&amp;lt;&lt;span style="color:#f92672">a&lt;/span> &lt;span style="color:#a6e22e">href&lt;/span>&lt;span style="color:#f92672">=&lt;/span>&lt;span style="color:#e6db74">&amp;#34;{{ pagination.href.next }}&amp;#34;&lt;/span>&amp;gt;Next&amp;lt;/&lt;span style="color:#f92672">a&lt;/span>&amp;gt;{% else %}Next{% endif %}&amp;lt;/&lt;span style="color:#f92672">li&lt;/span>&amp;gt;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &amp;lt;&lt;span style="color:#f92672">li&lt;/span>&amp;gt;{% if page.url != pagination.href.last %}&amp;lt;&lt;span style="color:#f92672">a&lt;/span> &lt;span style="color:#a6e22e">href&lt;/span>&lt;span style="color:#f92672">=&lt;/span>&lt;span style="color:#e6db74">&amp;#34;{{ pagination.href.last }}&amp;#34;&lt;/span>&amp;gt;Last&amp;lt;/&lt;span style="color:#f92672">a&lt;/span>&amp;gt;{% else %}Last{% endif %}&amp;lt;/&lt;span style="color:#f92672">li&lt;/span>&amp;gt;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &amp;lt;/&lt;span style="color:#f92672">ul&lt;/span>&amp;gt;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&amp;lt;/&lt;span style="color:#f92672">nav&lt;/span>&amp;gt;
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;hr>
&lt;h3 id="make-first-page-at-1">Make first page at 1&lt;/h3>
&lt;p>Change &lt;code>permalink&lt;/code>.&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-yaml" data-lang="yaml">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f92672">permalink&lt;/span>: &lt;span style="color:#e6db74">&amp;#34;/posts/{% if pagination.pageNumber &amp;gt; 0 %}page-{{ pagination.pageNumber + 1 }}/{% endif %}index.html&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;hr>
&lt;h3 id="generate-post-detail-page">Generate post detail page&lt;/h3>
&lt;p>Create &lt;code>posts/$slug.njk&lt;/code> (file name is not important, &lt;em>file extension is important&lt;/em>).&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-yaml" data-lang="yaml">&lt;span style="display:flex;">&lt;span>---
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f92672">pagination&lt;/span>:
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#f92672">data&lt;/span>: &lt;span style="color:#ae81ff">posts&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#f92672">size&lt;/span>: &lt;span style="color:#ae81ff">1&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#f92672">alias&lt;/span>: &lt;span style="color:#ae81ff">post&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f92672">permalink&lt;/span>: &lt;span style="color:#e6db74">&amp;#34;posts/{{ post.title | slugify }}/&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f92672">eleventyComputed&lt;/span>:
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#f92672">title&lt;/span>: &lt;span style="color:#e6db74">&amp;#34;{{ post.title }}&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f92672">layout&lt;/span>: &lt;span style="color:#ae81ff">layout.njk&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>---
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#ae81ff">&amp;lt;h1&amp;gt;{{ title }}&amp;lt;/h1&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>{{ &lt;span style="color:#ae81ff">post.body }}&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;hr>
&lt;section data-noprocess data-shortcode-slide
data-background-image="11ty-bg.png"
>
&lt;h2 id="eleventy-supplied-data">Eleventy Supplied Data&lt;/h2>
&lt;hr>
&lt;h3 id="eleventy-supplied-datahttpswww11tydevdocsdata-eleventy-supplied">&lt;a href="https://www.11ty.dev/docs/data-eleventy-supplied" target="_blank" rel="noopener">Eleventy Supplied Data&lt;/a>&lt;/h3>
&lt;ul>
&lt;li>&lt;code>pkg&lt;/code>: project’s &lt;code>package.json&lt;/code> values.&lt;/li>
&lt;li>&lt;code>pagination&lt;/code>: when enabled using pagination in front matter.&lt;/li>
&lt;li>&lt;code>collections&lt;/code>: Lists of all of your content, grouped by tags.&lt;/li>
&lt;li>&lt;code>page&lt;/code>: Has information about the current page.&lt;/li>
&lt;li>&lt;code>eleventy&lt;/code>: contains Eleventy-specific data from environment variables and the Serverless plugin (if used).&lt;/li>
&lt;/ul>
&lt;hr>
&lt;section data-noprocess data-shortcode-slide
data-background-image="11ty-bg.png"
>
&lt;h2 id="partials">Partials&lt;/h2>
&lt;hr>
&lt;h3 id="template-includehttpswww11tydevdocsdata-eleventy-supplied">&lt;a href="https://www.11ty.dev/docs/data-eleventy-supplied" target="_blank" rel="noopener">Template &lt;code>include&lt;/code>&lt;/a>&lt;/h3>
&lt;ul>
&lt;li>&lt;a href="https://mozilla.github.io/nunjucks/templating.html#include" target="_blank" rel="noopener">&lt;code>include&lt;/code>&lt;/a> pulls in other templates in place. It&amp;rsquo;s useful when you need to share smaller chunks across several templates that already inherit other templates.&lt;/li>
&lt;li>Paths are relative to &lt;code>_includes&lt;/code> folder.&lt;/li>
&lt;/ul>
&lt;hr>
&lt;h3 id="practice-header-partial">Practice: &lt;code>header&lt;/code> partial&lt;/h3>
&lt;p>Create &lt;code>_includes/partials/header.njk&lt;/code>:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-html" data-lang="html">&lt;span style="display:flex;">&lt;span>&amp;lt;&lt;span style="color:#f92672">header&lt;/span>&amp;gt;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &amp;lt;&lt;span style="color:#f92672">nav&lt;/span>&amp;gt;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &amp;lt;&lt;span style="color:#f92672">ul&lt;/span>&amp;gt;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> {% for item in header %}
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &amp;lt;&lt;span style="color:#f92672">li&lt;/span>&amp;gt;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &amp;lt;&lt;span style="color:#f92672">a&lt;/span> &lt;span style="color:#a6e22e">href&lt;/span>&lt;span style="color:#f92672">=&lt;/span>&lt;span style="color:#e6db74">&amp;#34;{{ item.url }}&amp;#34;&lt;/span>&amp;gt;{{ item.label }}&amp;lt;/&lt;span style="color:#f92672">a&lt;/span>&amp;gt;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &amp;lt;/&lt;span style="color:#f92672">li&lt;/span>&amp;gt;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> {% endfor %}
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &amp;lt;/&lt;span style="color:#f92672">ul&lt;/span>&amp;gt;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &amp;lt;/&lt;span style="color:#f92672">nav&lt;/span>&amp;gt;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&amp;lt;/&lt;span style="color:#f92672">header&lt;/span>&amp;gt;
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;hr>
&lt;h3 id="practice-header-partial-cont">Practice: &lt;code>header&lt;/code> partial (cont)&lt;/h3>
&lt;p>In &lt;code>_includes/layout.njk&lt;/code>:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-html" data-lang="html">&lt;span style="display:flex;">&lt;span>...
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&amp;lt;&lt;span style="color:#f92672">body&lt;/span>&amp;gt;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> {% include &amp;#34;partials/header.njk&amp;#34; %}}
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#75715e">&amp;lt;!-- Grab the content from the page data, dump it here, and mark it as safe --&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#75715e">&amp;lt;!-- Safe docs: https://mozilla.github.io/nunjucks/templating.html#safe --&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> {{ content | safe }}
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&amp;lt;/&lt;span style="color:#f92672">body&lt;/span>&amp;gt;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>...
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;hr>
&lt;section data-noprocess data-shortcode-slide
data-background-image="11ty-bg.png"
>
&lt;h2 id="collections">Collections&lt;/h2>
&lt;hr>
&lt;h3 id="collections-using-tagshttpswww11tydevdocscollections">&lt;a href="https://www.11ty.dev/docs/collections/" target="_blank" rel="noopener">Collections Using Tags&lt;/a>&lt;/h3>
&lt;ul>
&lt;li>A collection allows you to group content in interesting ways.
&lt;ul>
&lt;li>A piece of content can be a part of multiple collections, if you assign the &lt;em>same string value to the &lt;code>tags&lt;/code>&lt;/em> key in the front matter.&lt;/li>
&lt;li>&lt;code>tags&lt;/code> have a singular purpose in Eleventy: to construct collections of content.&lt;/li>
&lt;li>Some other platforms use tags to refer to a hierarchy of labels for the content.&lt;/li>
&lt;/ul>
&lt;/li>
&lt;/ul>
&lt;hr>
&lt;h3 id="how-to-tags">How to &lt;code>tags&lt;/code>&lt;/h3>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-yaml" data-lang="yaml">&lt;span style="display:flex;">&lt;span>---
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#75715e"># single tag&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f92672">tags&lt;/span>: &lt;span style="color:#ae81ff">cat&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#75715e"># access in template: `collections.cat`&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#75715e"># multiple words in a single tag&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f92672">tags&lt;/span>: &lt;span style="color:#ae81ff">cat and dog&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#75715e"># access in template: `collections[&amp;#39;cat and dog&amp;#39;]`&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#75715e"># multiple tags, single line&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f92672">tags&lt;/span>: [&lt;span style="color:#e6db74">&amp;#39;cat&amp;#39;&lt;/span>, &lt;span style="color:#e6db74">&amp;#39;dog&amp;#39;&lt;/span>]
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#75715e"># or multiple tags, multiple lines&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f92672">tags&lt;/span>:
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> - &lt;span style="color:#ae81ff">cat&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> - &lt;span style="color:#ae81ff">dog&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#75715e"># content would show up in: `collections.cat`, `collections.dog`&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>---
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;hr>
&lt;h3 id="the-special-all-collection">The Special &lt;code>all&lt;/code> Collection&lt;/h3>
&lt;p>By default Eleventy puts all of your content (independent of whether or not it has any assigned tags) into the &lt;code>collections.all&lt;/code> Collection.&lt;/p>
&lt;p>This allows you to iterate over all of your content inside of a template.&lt;/p>
&lt;hr>
&lt;h3 id="exclude-from-collections">Exclude from collections&lt;/h3>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-yaml" data-lang="yaml">&lt;span style="display:flex;">&lt;span>---
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f92672">eleventyExcludeFromCollections&lt;/span>: &lt;span style="color:#66d9ef">true&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f92672">tags&lt;/span>: &lt;span style="color:#ae81ff">post&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>---
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>This will not be available in &lt;code>collections.all&lt;/code> or &lt;code>collections.post&lt;/code>.&lt;/p>
&lt;hr>
&lt;h3 id="collection-item-data-structure">Collection Item Data Structure&lt;/h3>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-js" data-lang="js">&lt;span style="display:flex;">&lt;span>{
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#a6e22e">page&lt;/span>&lt;span style="color:#f92672">:&lt;/span> {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#a6e22e">inputPath&lt;/span>&lt;span style="color:#f92672">:&lt;/span> &lt;span style="color:#e6db74">&amp;#39;./test1.md&amp;#39;&lt;/span>,
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#a6e22e">url&lt;/span>&lt;span style="color:#f92672">:&lt;/span> &lt;span style="color:#e6db74">&amp;#39;/test1/&amp;#39;&lt;/span>,
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#a6e22e">date&lt;/span>&lt;span style="color:#f92672">:&lt;/span> &lt;span style="color:#66d9ef">new&lt;/span> Date(),
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#75715e">// … and everything else in Eleventy’s `page`
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#75715e">&lt;/span> },
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#a6e22e">data&lt;/span>&lt;span style="color:#f92672">:&lt;/span> { &lt;span style="color:#a6e22e">title&lt;/span>&lt;span style="color:#f92672">:&lt;/span> &lt;span style="color:#e6db74">&amp;#39;Test Title&amp;#39;&lt;/span>, &lt;span style="color:#a6e22e">tags&lt;/span>&lt;span style="color:#f92672">:&lt;/span> [&lt;span style="color:#e6db74">&amp;#39;tag1&amp;#39;&lt;/span>, &lt;span style="color:#e6db74">&amp;#39;tag2&amp;#39;&lt;/span>], &lt;span style="color:#a6e22e">date&lt;/span>&lt;span style="color:#f92672">:&lt;/span> &lt;span style="color:#e6db74">&amp;#39;Last Modified&amp;#39;&lt;/span>, &lt;span style="color:#75715e">/* … */&lt;/span> },
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#a6e22e">content&lt;/span>&lt;span style="color:#f92672">:&lt;/span> &lt;span style="color:#e6db74">&amp;#39;&amp;lt;h1&amp;gt;This is my title&amp;lt;/h1&amp;gt;\n\n&amp;lt;p&amp;gt;This is content…&amp;#39;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>}
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;span class="fragment " >
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-html" data-lang="html">&lt;span style="display:flex;">&lt;span>&amp;lt;&lt;span style="color:#f92672">ul&lt;/span>&amp;gt;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>{%- for post in collections.post -%}
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &amp;lt;&lt;span style="color:#f92672">li&lt;/span>&amp;gt;{{ post.data.title }}&amp;lt;/&lt;span style="color:#f92672">li&lt;/span>&amp;gt;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>{%- endfor -%}
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&amp;lt;/&lt;span style="color:#f92672">ul&lt;/span>&amp;gt;
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>
&lt;/span>
&lt;hr>
&lt;h3 id="sorting-ascending">Sorting Ascending&lt;/h3>
&lt;p>The default collection sorting algorithm sorts in ascending order using:&lt;/p>
&lt;ol>
&lt;li>The input file’s Created Date (you can override using date in front matter, as shown below)&lt;/li>
&lt;li>Files created at the exact same time are tie-broken using the input file’s full path including filename&lt;/li>
&lt;/ol>
&lt;hr>
&lt;h3 id="sort-descending">Sort Descending&lt;/h3>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-html" data-lang="html">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#75715e">&amp;lt;!-- nunjucks --&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&amp;lt;&lt;span style="color:#f92672">ul&lt;/span>&amp;gt;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>{%- for post in collections.post | reverse -%}
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &amp;lt;&lt;span style="color:#f92672">li&lt;/span>&amp;gt;{{ post.data.title }}&amp;lt;/&lt;span style="color:#f92672">li&lt;/span>&amp;gt;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>{%- endfor -%}
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&amp;lt;/&lt;span style="color:#f92672">ul&lt;/span>&amp;gt;
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;hr>
&lt;h3 id="advanced-custom-filtering-and-sorting">Advanced: Custom Filtering And Sorting&lt;/h3>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-js" data-lang="js">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#a6e22e">module&lt;/span>.&lt;span style="color:#a6e22e">exports&lt;/span> &lt;span style="color:#f92672">=&lt;/span> &lt;span style="color:#66d9ef">function&lt;/span>(&lt;span style="color:#a6e22e">eleventyConfig&lt;/span>) {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#75715e">// Filter source file names using a glob
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#75715e">&lt;/span> &lt;span style="color:#a6e22e">eleventyConfig&lt;/span>.&lt;span style="color:#a6e22e">addCollection&lt;/span>(&lt;span style="color:#e6db74">&amp;#34;posts&amp;#34;&lt;/span>, &lt;span style="color:#66d9ef">function&lt;/span>(&lt;span style="color:#a6e22e">collectionApi&lt;/span>) {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#66d9ef">return&lt;/span> &lt;span style="color:#a6e22e">collectionApi&lt;/span>.&lt;span style="color:#a6e22e">getFilteredByGlob&lt;/span>(&lt;span style="color:#e6db74">&amp;#34;_posts/*.md&amp;#34;&lt;/span>);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> });
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>};
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;blockquote>
&lt;p>&lt;a href="https://www.11ty.dev/docs/collections/#collection-api-methods" target="_blank" rel="noopener">Collection API methods&lt;/a>&lt;/p>
&lt;/blockquote>
&lt;span class="fragment " >
&lt;blockquote>
&lt;p>&lt;a href="https://darekkay.com/blog/eleventy-group-posts-by-year/" target="_blank" rel="noopener">Tip: Group posts by year&lt;/a>&lt;/p>
&lt;/blockquote>
&lt;/span>
&lt;hr>
&lt;section data-noprocess data-shortcode-slide
data-background-image="11ty-bg.png"
>
&lt;h2 id="template--directory-specific-data-files">Template &amp;amp; Directory Specific Data Files&lt;/h2>
&lt;hr>
&lt;h3 id="template--directory-specific-data-fileshttpswww11tydevdocsdata-template-dir">&lt;a href="https://www.11ty.dev/docs/data-template-dir/" target="_blank" rel="noopener">Template &amp;amp; Directory Specific Data Files&lt;/a>&lt;/h3>
&lt;ul>
&lt;li>While you can provide global data files to supply data to all of your templates, you may want some of your data to be available locally only to one specific template or to a directory of templates.&lt;/li>
&lt;li>For that use, we also search for JSON and JavaScript Data Files in specific places in your directory structure.&lt;/li>
&lt;/ul>
&lt;hr>
&lt;h3 id="template--directory-data-files-search-locationshttpswww11tydevdocsdata-template-dir">&lt;a href="https://www.11ty.dev/docs/data-template-dir/" target="_blank" rel="noopener">Template &amp;amp; Directory Data Files Search Locations&lt;/a>&lt;/h3>
&lt;p>Consider a template located at &lt;code>posts/subdir/my-first-blog-post.md&lt;/code>.&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-md" data-lang="md">&lt;span style="display:flex;">&lt;span>Eleventy will look for data in the following places (starting with highest priority, local data keys override global data):
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#66d9ef">1.&lt;/span> Content Template Front Matter Data
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#66d9ef">-&lt;/span> merged with any Layout Front Matter Data
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#66d9ef">2.&lt;/span> Template Data File
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>posts/subdir/my-first-blog-post.11tydata.js
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>posts/subdir/my-first-blog-post.11tydata.json
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>posts/subdir/my-first-blog-post.json
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#66d9ef">3.&lt;/span> Directory Data File
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>posts/subdir/subdir.11tydata.js
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>posts/subdir/subdir.11tydata.json
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>posts/subdir/subdir.json
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#66d9ef">4.&lt;/span> Parent Directory Data File
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>posts/posts.11tydata.js
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>posts/posts.11tydata.json
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>posts/posts.json
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#66d9ef">5.&lt;/span> Global Data Files in _data/* (.js or .json files) available to all templates.
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;hr>
&lt;h3 id="practice-default-layout-and-tags-for-blog">Practice: default &lt;code>layout&lt;/code> and &lt;code>tags&lt;/code> for Blog&lt;/h3>
&lt;p>Create &lt;code>blog/blog.json&lt;/code>.&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-json" data-lang="json">&lt;span style="display:flex;">&lt;span>{
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#f92672">&amp;#34;layout&amp;#34;&lt;/span>: &lt;span style="color:#e6db74">&amp;#34;layout.njk&amp;#34;&lt;/span>,
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#f92672">&amp;#34;tags&amp;#34;&lt;/span>: &lt;span style="color:#e6db74">&amp;#34;blog&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>}
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;hr>
&lt;section data-noprocess data-shortcode-slide
data-background-image="11ty-bg.png"
>
&lt;h2 id="themes-and-starter-projects">Themes and Starter projects&lt;/h2>
&lt;hr>
&lt;h3 id="starter-projectshttpswww11tydevdocsstarter">&lt;a href="https://www.11ty.dev/docs/starter/" target="_blank" rel="noopener">Starter projects&lt;/a>&lt;/h3>
&lt;p>Choose a repo, clone, then customize and add content.&lt;/p>
&lt;p>&lt;a href="https://jamstackthemes.dev/ssg/eleventy/" target="_blank" rel="noopener">11ty on JamStackThemes&lt;/a>&lt;/p></description></item></channel></rss>