<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title>11ty Rocks!</title>
	<subtitle>A collection of Eleventy (11ty) starters, projects, plugins, and resources created by Stephanie Eckles (@5t3ph).</subtitle>
	
	<link href="https://11ty.rocks/feed/" rel="self"/>
	<link href="https://11ty.rocks"/>
	<updated>2023-03-18T00:00:00Z</updated>
	<id>https://11ty.rocks/</id>
	<author>
		<name>Stephanie Eckles</name>
	</author>
	
	
	<entry>
		<title>Smart Incremental Rebuilds With eleventyImport</title>
		<link href="https://11ty.rocks/posts/smart-incremental-rebuilds-with-eleventy-import/"/>
		<updated>2023-03-18T00:00:00Z</updated>
		<id>https://11ty.rocks/posts/smart-incremental-rebuilds-with-eleventy-import/</id>
		<content type="html">&lt;p&gt;The Eleventy v2 release &lt;a href=&quot;https://www.11ty.dev/docs/usage/incremental/&quot;&gt;improved incremental builds&lt;/a&gt; in several ways.&lt;/p&gt;
&lt;p&gt;However, a standing issue had been that when you display content from a collection and run an incremental build, that content wouldn&#39;t be updated in-sync. You would have to stop an restart your build, or opt back out of incremental local dev.&lt;/p&gt;
&lt;p&gt;An additional method was added in v2 to resolve this behavior, and allow you to define which collections can re-build an associated template.&lt;/p&gt;
&lt;div class=&quot;heading-wrapper h2&quot;&gt;
&lt;h2 id=&quot;using-eleventyimport&quot;&gt;Using &lt;code&gt;eleventyImport&lt;/code&gt;&lt;/h2&gt;
&lt;a class=&quot;tdbc-anchor&quot; href=&quot;https://11ty.rocks/posts/smart-incremental-rebuilds-with-eleventy-import/#using-eleventyimport&quot; aria-labelledby=&quot;using-eleventyimport&quot;&gt;&lt;span hidden=&quot;&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;The &lt;code&gt;eleventyImport&lt;/code&gt; object can be added via front matter with one child parameter of &lt;code&gt;collections&lt;/code&gt; that has an array value. The array should contain the names of any collections you process content from on the page.&lt;/p&gt;
&lt;p&gt;The docs for this feature give a &lt;code&gt;post&lt;/code&gt; collection as the example:&lt;/p&gt;
&lt;pre class=&quot;language-twig&quot;&gt;&lt;code class=&quot;language-twig&quot;&gt;---&lt;br /&gt;eleventyImport:&lt;br /&gt;  collections: [&quot;post&quot;]&lt;br /&gt;---&lt;br /&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;ul&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token twig language-twig&quot;&gt;&lt;span class=&quot;token delimiter punctuation&quot;&gt;{%-&lt;/span&gt; &lt;span class=&quot;token tag-name keyword&quot;&gt;for&lt;/span&gt; post &lt;span class=&quot;token operator&quot;&gt;in&lt;/span&gt; collections&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;post &lt;span class=&quot;token delimiter punctuation&quot;&gt;-%}&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;li&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token twig language-twig&quot;&gt;&lt;span class=&quot;token delimiter punctuation&quot;&gt;{{&lt;/span&gt; post&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;data&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;title &lt;span class=&quot;token delimiter punctuation&quot;&gt;}}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;li&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token twig language-twig&quot;&gt;&lt;span class=&quot;token delimiter punctuation&quot;&gt;{%-&lt;/span&gt; &lt;span class=&quot;token tag-name keyword&quot;&gt;endfor&lt;/span&gt; &lt;span class=&quot;token delimiter punctuation&quot;&gt;-%}&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;ul&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;div class=&quot;heading-wrapper h2&quot;&gt;
&lt;h2 id=&quot;when-will-templates-rebuild&quot;&gt;When will templates rebuild?&lt;/h2&gt;
&lt;a class=&quot;tdbc-anchor&quot; href=&quot;https://11ty.rocks/posts/smart-incremental-rebuilds-with-eleventy-import/#when-will-templates-rebuild&quot; aria-labelledby=&quot;when-will-templates-rebuild&quot;&gt;&lt;span hidden=&quot;&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;Any content change to a collection template will also trigger rebuild. The rebuild is only of the page that includes the &lt;code&gt;eleventyImport&lt;/code&gt; object, and of the template where content was changed.&lt;/p&gt;
&lt;p&gt;As noted on the &lt;a href=&quot;https://www.11ty.dev/docs/usage/incremental/&quot;&gt;incremental builds docs&lt;/a&gt;, rebuild also happens &amp;quot;when you add or delete a tag from a template, any templates using that collection tag... will be rebuilt.&amp;quot;&lt;/p&gt;
&lt;p&gt;That said, &lt;a href=&quot;https://11ty.rocks/posts/creating-and-using-11ty-collections/&quot;&gt;any way you create a collection&lt;/a&gt; makes the collection eligible to be included in &lt;code&gt;eleventyImport&lt;/code&gt;.&lt;/p&gt;
&lt;div class=&quot;heading-wrapper h2&quot;&gt;
&lt;h2 id=&quot;beware-of-circular-imports&quot;&gt;Beware of circular imports&lt;/h2&gt;
&lt;a class=&quot;tdbc-anchor&quot; href=&quot;https://11ty.rocks/posts/smart-incremental-rebuilds-with-eleventy-import/#beware-of-circular-imports&quot; aria-labelledby=&quot;beware-of-circular-imports&quot;&gt;&lt;span hidden=&quot;&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;If your blog index resides in your &lt;code&gt;posts&lt;/code&gt; folder and you are using a &lt;a href=&quot;https://11ty.rocks/tips/data-directory-file/&quot;&gt;directory data file&lt;/a&gt; to assign the collection, then you&#39;ll want to exclude the main index from being included in collections:&lt;/p&gt;
&lt;pre class=&quot;language-md&quot;&gt;&lt;code class=&quot;language-md&quot;&gt;eleventyExcludeFromCollections: true&lt;/code&gt;&lt;/pre&gt;
</content>
	</entry>
	
	
	<entry>
		<title>Process CSS or Sass With LightningCSS</title>
		<link href="https://11ty.rocks/posts/process-css-with-lightningcss/"/>
		<updated>2023-02-25T00:00:00Z</updated>
		<id>https://11ty.rocks/posts/process-css-with-lightningcss/</id>
		<content type="html">&lt;p&gt;To easily process CSS with Sass and/or LightningCSS, simply grab these plugins:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://github.com/5t3ph/eleventy-plugin-sass-lightningcss&quot;&gt;Sass and LightningCSS&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://github.com/5t3ph/eleventy-plugin-lightningcss&quot;&gt;LightningCSS only&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;blockquote&gt;
&lt;p&gt;I&#39;ve written a &lt;a href=&quot;https://thinkdobecreate.com/articles/is-it-time-to-replace-sass/&quot;&gt;comparison of using Sass vs only LightningCSS&lt;/a&gt; if you&#39;re unsure which method you&#39;d like to use.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;If you want to learn how they work or how to more manually include these in your Eleventy build, read on!&lt;/p&gt;
&lt;div class=&quot;heading-wrapper h2&quot;&gt;
&lt;h2 id=&quot;custom-template-languages-in-eleventy&quot;&gt;Custom Template Languages in Eleventy&lt;/h2&gt;
&lt;a class=&quot;tdbc-anchor&quot; href=&quot;https://11ty.rocks/posts/process-css-with-lightningcss/#custom-template-languages-in-eleventy&quot; aria-labelledby=&quot;custom-template-languages-in-eleventy&quot;&gt;&lt;span hidden=&quot;&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;A powerful feature added in the Eleventy v1 release was the ability to add custom template extensions and template formats. Additionally, you can include a custom compile function.&lt;/p&gt;
&lt;p&gt;This opens the possibility to extend processing during build to tools like Sass, or run additional processing against already recognized types like JavaScript such as to minify.&lt;/p&gt;
&lt;p&gt;Or, &lt;a href=&quot;https://www.11ty.dev/docs/languages/custom/&quot;&gt;as the docs show&lt;/a&gt;, you can even invent a file type in order to customize the output in some way.&lt;/p&gt;
&lt;p&gt;We&#39;ll be taking advantage of this feature to add our custom processing of Sass or CSS files.&lt;/p&gt;
&lt;div class=&quot;heading-wrapper h2&quot;&gt;
&lt;h2 id=&quot;adding-sass-support&quot;&gt;Adding Sass Support&lt;/h2&gt;
&lt;a class=&quot;tdbc-anchor&quot; href=&quot;https://11ty.rocks/posts/process-css-with-lightningcss/#adding-sass-support&quot; aria-labelledby=&quot;adding-sass-support&quot;&gt;&lt;span hidden=&quot;&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;The docs actually use Sass as the example for adding support, but here is the compiled snippet with the key features to include.&lt;/p&gt;
&lt;p&gt;First, you&#39;ll need to install the sass package - &lt;code&gt;npm install sass&lt;/code&gt; - and also include it in your config.&lt;/p&gt;
&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; sass &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;require&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;sass&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Then, the following should be placed within your config export:&lt;/p&gt;
&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;// Recognize Sass as a &quot;template languages&quot;&lt;/span&gt;&lt;br /&gt;eleventyConfig&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;addTemplateFormats&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;scss&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token comment&quot;&gt;// Compile Sass&lt;/span&gt;&lt;br /&gt;eleventyConfig&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;addExtension&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;scss&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token literal-property property&quot;&gt;outputFileExtension&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;css&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token function-variable function&quot;&gt;compile&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;async&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;inputContent&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; inputPath&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token comment&quot;&gt;// Skip files like _fileName.scss&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;let&lt;/span&gt; parsed &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; path&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;parse&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;inputPath&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;parsed&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;name&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;startsWith&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;_&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    &lt;span class=&quot;token comment&quot;&gt;// Run file content through Sass&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;let&lt;/span&gt; result &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; sass&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;compileString&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;inputContent&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;token literal-property property&quot;&gt;loadPaths&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;parsed&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;dir &lt;span class=&quot;token operator&quot;&gt;||&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;.&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;token literal-property property&quot;&gt;sourceMap&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token boolean&quot;&gt;false&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// or true, your choice!&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    &lt;span class=&quot;token comment&quot;&gt;// Allow included files from @use or @import to&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token comment&quot;&gt;// trigger rebuilds when using --incremental&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;addDependencies&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;inputPath&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; result&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;loadedUrls&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;async&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; result&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;css&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;div class=&quot;heading-wrapper h2&quot;&gt;
&lt;h2 id=&quot;important-exclude-custom-template-files-from-all-collection&quot;&gt;Important: Exclude Custom Template Files from &lt;code&gt;all&lt;/code&gt; Collection&lt;/h2&gt;
&lt;a class=&quot;tdbc-anchor&quot; href=&quot;https://11ty.rocks/posts/process-css-with-lightningcss/#important-exclude-custom-template-files-from-all-collection&quot; aria-labelledby=&quot;important-exclude-custom-template-files-from-all-collection&quot;&gt;&lt;span hidden=&quot;&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;At this time, any custom template files will end up in &lt;code&gt;collections.all&lt;/code&gt;. This is very problematic if you are using that collection for things like sitemaps or RSS feeds.&lt;/p&gt;
&lt;p&gt;Until Zach decides &lt;a href=&quot;https://github.com/11ty/eleventy/issues/2854&quot;&gt;which way he wants to address this in core&lt;/a&gt;, the quickest fix is to create a directory data file to exclude your Sass (or other custom) files.&lt;/p&gt;
&lt;p&gt;Place the following in the directory containing your Sass files. As an example, for a directory called &lt;code&gt;css&lt;/code&gt; the file would be called &lt;code&gt;css/css.json&lt;/code&gt;:&lt;/p&gt;
&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token string-property property&quot;&gt;&quot;eleventyExcludeFromCollections&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token boolean&quot;&gt;true&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;div class=&quot;heading-wrapper h2&quot;&gt;
&lt;h2 id=&quot;autoprefixing-and-minification-with-lightningcss&quot;&gt;Autoprefixing and Minification with LightningCSS&lt;/h2&gt;
&lt;a class=&quot;tdbc-anchor&quot; href=&quot;https://11ty.rocks/posts/process-css-with-lightningcss/#autoprefixing-and-minification-with-lightningcss&quot; aria-labelledby=&quot;autoprefixing-and-minification-with-lightningcss&quot;&gt;&lt;span hidden=&quot;&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;If you are using more modern CSS features, you&#39;ll want to at least include prefixing. And for even more support of other upcoming features like nesting, color functions, media query range syntax I encourage using &lt;a href=&quot;https://lightningcss.dev/&quot;&gt;LightningCSS&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;We can update the previous snippet to include LightningCSS so that we still support Sass processing.&lt;/p&gt;
&lt;p&gt;First, install both &lt;code&gt;lightningcss&lt;/code&gt; as well as &lt;code&gt;browserslist&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;npm install lightningcss browserslist&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;And include those in your config:&lt;/p&gt;
&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; browserslist &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;require&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;browserslist&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; transform&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; browserslistToTargets &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;require&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;lightningcss&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;We&#39;ve had to include both things so that we can pass browser compile targets to LightningCSS, otherwise prefixing and other transforms of modern CSS would not be applied. This handy web app will help you &lt;a href=&quot;https://browsersl.ist/#q=%3E+0.2%25+and+not+dead&quot;&gt;decide on your browserslist targets&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;In our earlier Sass snippet, we&#39;ll update the final return section:&lt;/p&gt;
&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;let&lt;/span&gt; targets &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;browserslistToTargets&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;browserslist&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;&gt; 0.2% and not dead&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;async&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token keyword&quot;&gt;let&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; code &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;await&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;transform&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token literal-property property&quot;&gt;code&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; Buffer&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;result&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;css&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token literal-property property&quot;&gt;minify&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token boolean&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token literal-property property&quot;&gt;sourceMap&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token boolean&quot;&gt;false&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;    targets&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; code&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;blockquote&gt;
&lt;p&gt;Use the &lt;a href=&quot;https://github.com/5t3ph/eleventy-plugin-sass-lightningcss&quot;&gt;Eleventy plugin for Sass and LightningCSS&lt;/a&gt; to use this setup without adding all of this manually to your config.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;div class=&quot;heading-wrapper h2&quot;&gt;
&lt;h2 id=&quot;process-with-lightningcss-only-no-sass&quot;&gt;Process with LightningCSS Only, No Sass&lt;/h2&gt;
&lt;a class=&quot;tdbc-anchor&quot; href=&quot;https://11ty.rocks/posts/process-css-with-lightningcss/#process-with-lightningcss-only-no-sass&quot; aria-labelledby=&quot;process-with-lightningcss-only-no-sass&quot;&gt;&lt;span hidden=&quot;&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;If Sass isn&#39;t something you want to use, then we can remove the Sass bits and only process our CSS with LightningCSS.&lt;/p&gt;
&lt;p&gt;You&#39;ll still need to install the following:&lt;/p&gt;
&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;npm install lightningcss browserslist&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Then include them in your config:&lt;/p&gt;
&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; browserslist &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;require&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;browserslist&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; bundle&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; browserslistToTargets&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; composeVisitors &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;require&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;lightningcss&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;And here&#39;s the full snippet to place in your config. This includes a preference to allow &amp;quot;bundling&amp;quot; which enables including other files via the &lt;code&gt;@import&lt;/code&gt; syntax. The snippet also assumes those files are prefixed with &lt;code&gt;_&lt;/code&gt; which you can omit or change to your preference.&lt;/p&gt;
&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;// Recognize CSS as a &quot;template language&quot;&lt;/span&gt;&lt;br /&gt;eleventyConfig&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;addTemplateFormats&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;css&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token comment&quot;&gt;// Process CSS with LightningCSS&lt;/span&gt;&lt;br /&gt;eleventyConfig&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;addExtension&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;css&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token literal-property property&quot;&gt;outputFileExtension&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;css&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token function-variable function&quot;&gt;compile&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;async&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;_inputContent&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; inputPath&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;let&lt;/span&gt; parsed &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; path&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;parse&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;inputPath&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;parsed&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;name&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;startsWith&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;_&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;let&lt;/span&gt; targets &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;browserslistToTargets&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;browserslist&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;&gt; 0.2% and not dead&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;async&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;token comment&quot;&gt;// Switch to the `transform` function if you don&#39;t&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;token comment&quot;&gt;// plan to use `@import` to merge files&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;token keyword&quot;&gt;let&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; code &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;await&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;bundle&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token literal-property property&quot;&gt;filename&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; inputPath&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token literal-property property&quot;&gt;minify&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token boolean&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token literal-property property&quot;&gt;sourceMap&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token boolean&quot;&gt;false&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;        targets&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token comment&quot;&gt;// Supports CSS nesting&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token literal-property property&quot;&gt;drafts&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;          nesting&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; code&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Don&#39;t miss the step to exclude these files from &lt;code&gt;collections.all&lt;/code&gt; discussed earlier.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;A &lt;a href=&quot;https://github.com/5t3ph/eleventy-plugin-lightningcss&quot;&gt;plugin to process CSS with LightningCSS&lt;/a&gt; only is also available.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;div class=&quot;heading-wrapper h2&quot;&gt;
&lt;h2 id=&quot;plugin-or-manual-include&quot;&gt;Plugin or Manual Include?&lt;/h2&gt;
&lt;a class=&quot;tdbc-anchor&quot; href=&quot;https://11ty.rocks/posts/process-css-with-lightningcss/#plugin-or-manual-include&quot; aria-labelledby=&quot;plugin-or-manual-include&quot;&gt;&lt;span hidden=&quot;&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;The benefit of the plugin is that it will also automatically get your browserslist definition, and you can just drop it in across projects.&lt;/p&gt;
&lt;p&gt;A manual include is great if you want to customize beyond what the plugins allow, or want to own the responsibility of updating the dependencies.&lt;/p&gt;
</content>
	</entry>
	
	
	<entry>
		<title>Plugin: Collection Schemas</title>
		<link href="https://github.com/5t3ph/eleventy-plugin-collection-schemas"/>
		<updated>2023-02-17T00:00:00Z</updated>
		<id>https://github.com/5t3ph/eleventy-plugin-collection-schemas</id>
		<content type="html">&lt;p&gt;Enforce a typed frontmatter schema for templates within an Eleventy collection.&lt;/p&gt;
&lt;p&gt;Define a unique schema per collection, then receive output during development and builds to note incorrectly typed, missing, invalid, or misplaced custom data keys.&lt;/p&gt;
&lt;a href=&quot;https://github.com/5t3ph/eleventy-plugin-collection-schemas&quot;&gt;Docs for Collection Schemas&lt;/a&gt;</content>
	</entry>
	
	
	<entry>
		<title>Eleventy Collection Schemas</title>
		<link href="https://11ty.rocks/posts/eleventy-collection-schemas/"/>
		<updated>2023-02-17T00:00:00Z</updated>
		<id>https://11ty.rocks/posts/eleventy-collection-schemas/</id>
		<content type="html">&lt;p&gt;A standout feature of Eleventy is &lt;a href=&quot;https://www.11ty.dev/docs/data-cascade/&quot;&gt;the data cascade&lt;/a&gt;. This is the priority order of how global data, front matter data, and other data sources are computed for a given template.&lt;/p&gt;
&lt;p&gt;Additionally, Eleventy allows the creation of &lt;a href=&quot;https://11ty.rocks/posts/creating-and-using-11ty-collections/&quot;&gt;collections of data&lt;/a&gt;. Often the reason for a collection is that the content has shared traits.&lt;/p&gt;
&lt;p&gt;Let&#39;s consider a collection of blog posts, where your layout assumes availability of the following bits of data:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;title&lt;/li&gt;
&lt;li&gt;description&lt;/li&gt;
&lt;li&gt;excerpt&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;None of these are going to be enforced or type-checked by Eleventy. But perhaps its important to you to make &lt;code&gt;title&lt;/code&gt; and &lt;code&gt;description&lt;/code&gt; required keys. Or in the future, you add a &lt;code&gt;draft&lt;/code&gt; key that you want to ensure is a boolean, or an &lt;code&gt;order&lt;/code&gt; field that should be a number.&lt;/p&gt;
&lt;div class=&quot;heading-wrapper h2&quot;&gt;
&lt;h2 id=&quot;introducing-collection-schemas&quot;&gt;Introducing: Collection Schemas&lt;/h2&gt;
&lt;a class=&quot;tdbc-anchor&quot; href=&quot;https://11ty.rocks/posts/eleventy-collection-schemas/#introducing-collection-schemas&quot; aria-labelledby=&quot;introducing-collection-schemas&quot;&gt;&lt;span hidden=&quot;&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href=&quot;https://github.com/5t3ph/eleventy-plugin-collection-schemas&quot;&gt;Collection Schemas&lt;/a&gt; is an Eleventy plugin that allows you to enforce a typed frontmatter schema for templates within an Eleventy collection. It works by you defining a unique schema per collection, then providing output during development and builds to note incorrectly typed, missing, invalid, or misplaced custom data keys.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://11ty.rocks/img/output.png&quot; alt=&quot;example plugin output within the terminal for the conditions listed below&quot; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;small&gt;&lt;em&gt;Terminal output example shown in VS Code using the theme &lt;a href=&quot;https://marketplace.visualstudio.com/items?itemName=apollographql.apollo-midnight-color-theme&quot;&gt;Apollo Midnight&lt;/a&gt;&lt;/em&gt;&lt;/small&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Conditions evaluted for include&lt;/strong&gt;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Missing required meta keys: &lt;code&gt;[LIST]&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Possibly misplaced meta keys: &lt;code&gt;[LIST]&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Incorrect type for meta &lt;code&gt;[KEY]&lt;/code&gt;, change to &lt;code&gt;[TYPE]&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Invalid meta keys: &lt;code&gt;[LIST]&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Where &amp;quot;invalid&amp;quot; catches typos or extra, untyped keys that may need to be added to the schema.&lt;/p&gt;
&lt;div class=&quot;heading-wrapper h3&quot;&gt;
&lt;h3 id=&quot;how-collection-schemas-work&quot;&gt;How collection schemas work&lt;/h3&gt;
&lt;a class=&quot;tdbc-anchor&quot; href=&quot;https://11ty.rocks/posts/eleventy-collection-schemas/#how-collection-schemas-work&quot; aria-labelledby=&quot;how-collection-schemas-work&quot;&gt;&lt;span hidden=&quot;&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;The plugin introduces a new file extension of &lt;code&gt;.meta&lt;/code&gt; (which is configurable) to design your schema with JSON. So for our blog post example, you might have the schema of:&lt;/p&gt;
&lt;pre class=&quot;language-json&quot;&gt;&lt;code class=&quot;language-json&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token property&quot;&gt;&quot;title&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token property&quot;&gt;&quot;type&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;string&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token property&quot;&gt;&quot;required&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token boolean&quot;&gt;true&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token property&quot;&gt;&quot;description&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token property&quot;&gt;&quot;type&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;string&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token property&quot;&gt;&quot;required&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token boolean&quot;&gt;true&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token property&quot;&gt;&quot;excerpt&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token property&quot;&gt;&quot;type&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;string&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token property&quot;&gt;&quot;required&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token boolean&quot;&gt;false&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This &lt;code&gt;.meta&lt;/code&gt; file slots into the data cascade similar to a directory data file, so it will need the same name as the parent directory of your collection. To associate the schema with the collection, the collection will also need the same name.&lt;/p&gt;
&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;posts/&lt;br /&gt;  posts.meta&lt;br /&gt;  posts.json&lt;br /&gt;  post-one.md &lt;- content in any templating language&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Where &lt;code&gt;posts.json&lt;/code&gt; is a directory data file that creates the collection via the tags mechanism:&lt;/p&gt;
&lt;pre class=&quot;language-json&quot;&gt;&lt;code class=&quot;language-json&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token property&quot;&gt;&quot;tags&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;posts&quot;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;blockquote&gt;
&lt;p&gt;✨ Tip: You can also use the directory data file to &lt;a href=&quot;https://11ty.rocks/tips/permalinks/&quot;&gt;change the permalink for all templates&lt;/a&gt; in a collection if you don&#39;t want them to have the collection name as the URL base.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;The plugin leverages the filter capability to obtain the page&#39;s total computed data, which will include the schema from the &lt;code&gt;.meta&lt;/code&gt; file, and then will log any issues to the console.&lt;/p&gt;
&lt;p&gt;To finish tying the schema to the collection via the filter, you&#39;ll also need to create a global data file called &lt;code&gt;eleventyComputed.js&lt;/code&gt; (or extend an existing one) to include the following:&lt;/p&gt;
&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;module&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;exports &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token function-variable function&quot;&gt;metaSchema&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;metaSchema&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;data&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;blockquote&gt;
&lt;p&gt;Review all the &lt;a href=&quot;https://github.com/5t3ph/eleventy-plugin-collection-schemas&quot;&gt;installation and configuration options&lt;/a&gt; for the plugin.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Then, nest any of your schema-related keys under the &lt;code&gt;meta&lt;/code&gt; key within template front matter:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;---
meta:
  title: &amp;quot;My Page Title&amp;quot;
  description: &amp;quot;One morning, when Gregor Samsa woke from troubled dreams, he found himself transformed in his bed into a horrible vermin.&amp;quot;
---
&lt;/code&gt;&lt;/pre&gt;
&lt;div class=&quot;heading-wrapper h2&quot;&gt;
&lt;h2 id=&quot;schema-limitations&quot;&gt;Schema Limitations&lt;/h2&gt;
&lt;a class=&quot;tdbc-anchor&quot; href=&quot;https://11ty.rocks/posts/eleventy-collection-schemas/#schema-limitations&quot; aria-labelledby=&quot;schema-limitations&quot;&gt;&lt;span hidden=&quot;&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;ul&gt;
&lt;li&gt;Only one level of schema data is currently possible&lt;/li&gt;
&lt;li&gt;Only the top-level collection is used to locate schemas&lt;/li&gt;
&lt;/ul&gt;
</content>
	</entry>
	
	
	<entry>
		<title>Plugin: Sass + LightningCSS</title>
		<link href="https://www.npmjs.com/package/@11tyrocks/eleventy-plugin-sass-lightningcss"/>
		<updated>2023-02-02T00:00:00Z</updated>
		<id>https://www.npmjs.com/package/@11tyrocks/eleventy-plugin-sass-lightningcss</id>
		<content type="html">&lt;p&gt;Compile Sass in Eleventy (11ty) and process it with LightningCSS to minify, prefix, and add future CSS support.&lt;/p&gt;
&lt;p&gt;Also respects either your package.json browserslist or a .browserslistrc, otherwise the default targets are &amp;gt; 0.2% and not dead.&lt;/p&gt;
&lt;p&gt;Requires Eleventy v2 beta or stable.&lt;/p&gt;
&lt;a href=&quot;https://www.npmjs.com/package/@11tyrocks/eleventy-plugin-sass-lightningcss&quot;&gt;Add Sass to 11ty&lt;/a&gt;</content>
	</entry>
	
	
	<entry>
		<title>11ty Membership Site</title>
		<link href="https://github.com/5t3ph/11ty-membership-site"/>
		<updated>2023-01-26T00:00:00Z</updated>
		<id>https://github.com/5t3ph/11ty-membership-site</id>
		<content type="html">&lt;p&gt;An Eleventy theme for offering premium content to members by using Edge-powered authentication. Requires Supabase and Netlify accounts.&lt;/p&gt;
&lt;p&gt;Review this article on &lt;a href=&quot;https://11ty.rocks/posts/building-a-membership-site-with-11ty/&quot;&gt;the high-level membership theme concepts&lt;/a&gt; to learn how members-only content works.&lt;/p&gt;
&lt;a href=&quot;https://github.com/5t3ph/11ty-membership-site&quot;&gt;Get this theme&lt;/a&gt;</content>
	</entry>
	
	
	<entry>
		<title>Building A Membership Site With 11ty</title>
		<link href="https://11ty.rocks/posts/building-a-membership-site-with-11ty/"/>
		<updated>2023-01-26T00:00:00Z</updated>
		<id>https://11ty.rocks/posts/building-a-membership-site-with-11ty/</id>
		<content type="html">&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;Spoiler&lt;/em&gt;: This is available as &lt;a href=&quot;https://github.com/5t3ph/11ty-membership-site&quot;&gt;an Eleventy theme&lt;/a&gt; over on GitHub. Read on to explore key concepts about developing using Eleventy Edge.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;A new feature with Eleventy v2 (currently in beta) is Eleventy Edge.&lt;/p&gt;
&lt;p&gt;What is &amp;quot;the Edge?&amp;quot; Here&#39;s a super brief summary:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Low-latency nodes geographically close to the user
&lt;ul&gt;
&lt;li&gt;Faster processing of Edge functions vs. serverless&lt;/li&gt;
&lt;li&gt;Retrieve user-specific data, ex. timezone, cookies&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;“Middleware” to intercept page requests before they are rendered&lt;/li&gt;
&lt;li&gt;Allow redirecting or modifying requested content&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;These features allow us to enable authenticated routes for our 11ty site. And the opt-in Eleventy Edge plugin enables us to add and use Edge-generated data within otherwise static 11ty templates.&lt;/p&gt;
&lt;div class=&quot;heading-wrapper h2&quot;&gt;
&lt;h2 id=&quot;prerequisites&quot;&gt;Prerequisites&lt;/h2&gt;
&lt;a class=&quot;tdbc-anchor&quot; href=&quot;https://11ty.rocks/posts/building-a-membership-site-with-11ty/#prerequisites&quot; aria-labelledby=&quot;prerequisites&quot;&gt;&lt;span hidden=&quot;&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;ul&gt;
&lt;li&gt;11ty v2 beta+ (included in the &lt;a href=&quot;https://github.com/5t3ph/11ty-membership-site&quot;&gt;membership theme&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://netlify.com/&quot;&gt;Netlify account&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://docs.netlify.com/cli/get-started/&quot;&gt;Netlify CLI&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://supabase.io/&quot;&gt;Supabase account&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Additionally, opting-in to the &lt;a href=&quot;https://www.11ty.dev/docs/plugins/edge/&quot;&gt;Eleventy Edge plugin&lt;/a&gt;. This is not a separate install, but it is not included in your build by default. The following are the parts to include (if you are not using &lt;a href=&quot;https://11ty.rocks/posts/building-a-membership-site-with-11ty/(https://github.com/5t3ph/11ty-membership-site)&quot;&gt;the theme&lt;/a&gt;).&lt;/p&gt;
&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; EleventyEdgePlugin &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;require&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;@11ty/eleventy&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;module&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function-variable function&quot;&gt;exports&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;eleventyConfig&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token comment&quot;&gt;// Opt-in to 11ty Edge&lt;/span&gt;&lt;br /&gt;  eleventyConfig&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;addPlugin&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;EleventyEdgePlugin&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;div class=&quot;heading-wrapper h2&quot;&gt;
&lt;h2 id=&quot;how-it-works&quot;&gt;How it works&lt;/h2&gt;
&lt;a class=&quot;tdbc-anchor&quot; href=&quot;https://11ty.rocks/posts/building-a-membership-site-with-11ty/#how-it-works&quot; aria-labelledby=&quot;how-it-works&quot;&gt;&lt;span hidden=&quot;&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;Supabase out-of-the-box has user sigups enabled, and from that we can setup &amp;quot;magic link&amp;quot; authentication as a starting point. This means a new or returning user enters their email and Supabase sends an email with a one-time access token. It&#39;s then up to our site for how to handle the user&#39;s journey after they return with that token.&lt;/p&gt;
&lt;p&gt;For our minimum-viable membership site, here are the features:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Authenticate users with Supabase Magic Links and provide members-only content&lt;/li&gt;
&lt;li&gt;Offer partial content previews to unauthenticated users&lt;/li&gt;
&lt;li&gt;Build using 11ty, Netlify Edge, and Supabase&lt;/li&gt;
&lt;li&gt;Use no frameworks or bundlers, just vanilla JS (+ Deno on the Edge), Nunjucks, and Markdown&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;So, how does this come together? First, Supabase offers an API and functions to easily trigger the necessary actions like login, and retrieval of a user&#39;s session details.&lt;/p&gt;
&lt;p&gt;With the Netlify CLI, we have access to environment variables stored in our Netlify account so that those can be shared to local dev. The Netlify CLI also enables actually using the Edge functions for local development.&lt;/p&gt;
&lt;p&gt;With Edge + Supabase, we don&#39;t need a single-page application framework because only a couple of tiny JavaScript functions are required client-side for initial login! We&#39;ll create a cookie on the Edge to store an &lt;code&gt;_access_token&lt;/code&gt; based on Supabase session details to use for subsequent page requests.&lt;/p&gt;
&lt;p&gt;Eleventy Edge then is attached to each page load where we check for the &lt;code&gt;_access_token&lt;/code&gt; cookie and use the value to validate a user. Edge checks the user&#39;s status before they see any page content and sends down an &lt;code&gt;isUser&lt;/code&gt; variable to pick up in our 11ty templates. Within the &lt;code&gt;{% edge %}&lt;/code&gt; shortcode provided by the plugin is where we render the members-only content, or prompt for a login.&lt;/p&gt;
&lt;p&gt;The rest is leveraging the Nunjucks templating language, and also using Markdown as the way to author post content.&lt;/p&gt;
&lt;div class=&quot;heading-wrapper h2&quot;&gt;
&lt;h2 id=&quot;authentication-flow&quot;&gt;Authentication Flow&lt;/h2&gt;
&lt;a class=&quot;tdbc-anchor&quot; href=&quot;https://11ty.rocks/posts/building-a-membership-site-with-11ty/#authentication-flow&quot; aria-labelledby=&quot;authentication-flow&quot;&gt;&lt;span hidden=&quot;&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;&lt;img src=&quot;https://11ty.rocks/img/authentication-flow.png&quot; alt=&quot;Authentication flow as described following the image&quot; /&gt;&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;User enters email and triggers magic link login from either the index or a post&lt;/li&gt;
&lt;li&gt;Supabase auth sends a magic link to user&#39;s email&lt;/li&gt;
&lt;li&gt;User returns through magic link and arrives at &lt;code&gt;/session/&lt;/code&gt; where:
&lt;ul&gt;
&lt;li&gt;Supabase saves session data to localStorage&lt;/li&gt;
&lt;li&gt;&lt;code&gt;session.js&lt;/code&gt; picks up the session variables and redirects to &lt;code&gt;/access/&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;&lt;code&gt;/access/&lt;/code&gt; route loads the &lt;code&gt;netlify/edge-functions/login.js&lt;/code&gt; Edge function which saves the &lt;code&gt;_access_token&lt;/code&gt; cookie*&lt;/li&gt;
&lt;li&gt;User redirected to the login-originating page (either the index or a specific post)&lt;/li&gt;
&lt;/ol&gt;
&lt;blockquote&gt;
&lt;p&gt;* &lt;strong&gt;Why a cookie?&lt;/strong&gt; Edge functions can read cookies from page headers, so it&#39;s used to validate sessions across page loads.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;div class=&quot;heading-wrapper h3&quot;&gt;
&lt;h3 id=&quot;assigning-routes-to-edge-functions&quot;&gt;Assigning routes to Edge functions&lt;/h3&gt;
&lt;a class=&quot;tdbc-anchor&quot; href=&quot;https://11ty.rocks/posts/building-a-membership-site-with-11ty/#assigning-routes-to-edge-functions&quot; aria-labelledby=&quot;assigning-routes-to-edge-functions&quot;&gt;&lt;span hidden=&quot;&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;Netlify Edge looks at the &lt;code&gt;netlify.toml&lt;/code&gt; file to determine when to pass a page request through an Edge Function.&lt;/p&gt;
&lt;p&gt;Here&#39;s the example of setting the route for the &lt;code&gt;login&lt;/code&gt; Edge function:&lt;/p&gt;
&lt;pre class=&quot;language-toml&quot;&gt;&lt;code class=&quot;language-toml&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token table class-name&quot;&gt;edge_functions&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token key property&quot;&gt;path&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;/access/*&quot;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token key property&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;login&quot;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;div class=&quot;heading-wrapper h2&quot;&gt;
&lt;h2 id=&quot;members-only-content-flow&quot;&gt;Members-Only Content Flow&lt;/h2&gt;
&lt;a class=&quot;tdbc-anchor&quot; href=&quot;https://11ty.rocks/posts/building-a-membership-site-with-11ty/#members-only-content-flow&quot; aria-labelledby=&quot;members-only-content-flow&quot;&gt;&lt;span hidden=&quot;&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;&lt;img src=&quot;https://11ty.rocks/img/gated-content-flow.png&quot; alt=&quot;Members-only content flow, as described following the image&quot; /&gt;&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;The author determines which content (if any) will be gated by setting the &lt;code&gt;premium&lt;/code&gt; variable&lt;/li&gt;
&lt;li&gt;When a user visits a gated post, the 11ty Edge function (&lt;code&gt;netlify/edge-functions/eleventy-edge.js&lt;/code&gt;) checks their authenticated status with Supabase, and sets &lt;code&gt;isUser&lt;/code&gt; as global data for access within the &lt;code&gt;{% edge %}&lt;/code&gt; shortcode
&lt;ul&gt;
&lt;li&gt;If &lt;code&gt;isUser: true&lt;/code&gt; - user sees the premium content&lt;/li&gt;
&lt;li&gt;If &lt;code&gt;isUser: false&lt;/code&gt; - user sees partial content and the login form&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;The &lt;code&gt;isUser&lt;/code&gt; variable is made available because Eleventy Edge allows creating global data on-the-fly! With one caveat: it&#39;s exclusive to the &lt;code&gt;edge&lt;/code&gt; shortcode and only on routes covered by the Edge function. In other words, it is dynamic and isolated to that page load, and does not become a part of the static 11ty build.&lt;/p&gt;
&lt;div class=&quot;heading-wrapper h3&quot;&gt;
&lt;h3 id=&quot;authoring-premium-content&quot;&gt;Authoring premium content&lt;/h3&gt;
&lt;a class=&quot;tdbc-anchor&quot; href=&quot;https://11ty.rocks/posts/building-a-membership-site-with-11ty/#authoring-premium-content&quot; aria-labelledby=&quot;authoring-premium-content&quot;&gt;&lt;span hidden=&quot;&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;How does it look to set the &lt;code&gt;premium&lt;/code&gt; variable? Here&#39;s an example post which is written in Markdown and uses Nunjucks for assigning the variable.&lt;/p&gt;
&lt;pre class=&quot;language-twig&quot;&gt;&lt;code class=&quot;language-twig&quot;&gt;Example post content outside of the gated, members-only content.&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token twig language-twig&quot;&gt;&lt;span class=&quot;token delimiter punctuation&quot;&gt;{%&lt;/span&gt; &lt;span class=&quot;token tag-name keyword&quot;&gt;set&lt;/span&gt; premium &lt;span class=&quot;token delimiter punctuation&quot;&gt;%}&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;This content is super premium! For members only!!&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token twig language-twig&quot;&gt;&lt;span class=&quot;token delimiter punctuation&quot;&gt;{%&lt;/span&gt; &lt;span class=&quot;token tag-name keyword&quot;&gt;endset&lt;/span&gt; &lt;span class=&quot;token delimiter punctuation&quot;&gt;%}&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token twig language-twig&quot;&gt;&lt;span class=&quot;token delimiter punctuation&quot;&gt;{%&lt;/span&gt; &lt;span class=&quot;token tag-name keyword&quot;&gt;include&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;components/gate.njk&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token delimiter punctuation&quot;&gt;%}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;We then include a Nunjucks partial &lt;code&gt;gate.njk&lt;/code&gt; after setting the &lt;code&gt;premium&lt;/code&gt; variable which includes the &lt;code&gt;{% edge %}&lt;/code&gt; shortcode and determines whether the user can see the premium content.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; We have to place the include alongside the content template rathen than in the layout used by the post because the &lt;code&gt;premium&lt;/code&gt; variable will not be available to a layout. So, the include must be added by authors on each post with members-only content.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;pre class=&quot;language-twig&quot;&gt;&lt;code class=&quot;language-twig&quot;&gt;&lt;span class=&quot;token twig language-twig&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;{# gate.njk #}&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token twig language-twig&quot;&gt;&lt;span class=&quot;token delimiter punctuation&quot;&gt;{%&lt;/span&gt; &lt;span class=&quot;token tag-name keyword&quot;&gt;set&lt;/span&gt; loginform &lt;span class=&quot;token delimiter punctuation&quot;&gt;%}&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token twig language-twig&quot;&gt;&lt;span class=&quot;token delimiter punctuation&quot;&gt;{%&lt;/span&gt; &lt;span class=&quot;token tag-name keyword&quot;&gt;set&lt;/span&gt; loginHeadline &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;To continue reading, join or login&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token delimiter punctuation&quot;&gt;%}&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token twig language-twig&quot;&gt;&lt;span class=&quot;token delimiter punctuation&quot;&gt;{%&lt;/span&gt; &lt;span class=&quot;token tag-name keyword&quot;&gt;include&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;components/loginform.njk&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token delimiter punctuation&quot;&gt;%}&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token twig language-twig&quot;&gt;&lt;span class=&quot;token delimiter punctuation&quot;&gt;{%&lt;/span&gt; &lt;span class=&quot;token tag-name keyword&quot;&gt;endset&lt;/span&gt; &lt;span class=&quot;token delimiter punctuation&quot;&gt;%}&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token twig language-twig&quot;&gt;&lt;span class=&quot;token delimiter punctuation&quot;&gt;{%&lt;/span&gt; &lt;span class=&quot;token tag-name keyword&quot;&gt;edge&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;njk, md&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; premium&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; premium&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; loginform&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; loginform &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;token delimiter punctuation&quot;&gt;%}&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token twig language-twig&quot;&gt;&lt;span class=&quot;token delimiter punctuation&quot;&gt;{%&lt;/span&gt; &lt;span class=&quot;token tag-name keyword&quot;&gt;if&lt;/span&gt; premium &lt;span class=&quot;token delimiter punctuation&quot;&gt;%}&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token twig language-twig&quot;&gt;&lt;span class=&quot;token delimiter punctuation&quot;&gt;{%&lt;/span&gt; &lt;span class=&quot;token tag-name keyword&quot;&gt;if&lt;/span&gt; isUser &lt;span class=&quot;token delimiter punctuation&quot;&gt;%}&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;token twig language-twig&quot;&gt;&lt;span class=&quot;token delimiter punctuation&quot;&gt;{{&lt;/span&gt; premium &lt;span class=&quot;token delimiter punctuation&quot;&gt;}}&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token twig language-twig&quot;&gt;&lt;span class=&quot;token delimiter punctuation&quot;&gt;{%&lt;/span&gt; &lt;span class=&quot;token tag-name keyword&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;token delimiter punctuation&quot;&gt;%}&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;token twig language-twig&quot;&gt;&lt;span class=&quot;token delimiter punctuation&quot;&gt;{{&lt;/span&gt; loginform &lt;span class=&quot;token operator&quot;&gt;|&lt;/span&gt; safe &lt;span class=&quot;token delimiter punctuation&quot;&gt;}}&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token twig language-twig&quot;&gt;&lt;span class=&quot;token delimiter punctuation&quot;&gt;{%&lt;/span&gt; &lt;span class=&quot;token tag-name keyword&quot;&gt;endif&lt;/span&gt; &lt;span class=&quot;token delimiter punctuation&quot;&gt;%}&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token twig language-twig&quot;&gt;&lt;span class=&quot;token delimiter punctuation&quot;&gt;{%&lt;/span&gt; &lt;span class=&quot;token tag-name keyword&quot;&gt;endif&lt;/span&gt; &lt;span class=&quot;token delimiter punctuation&quot;&gt;%}&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token twig language-twig&quot;&gt;&lt;span class=&quot;token delimiter punctuation&quot;&gt;{%&lt;/span&gt; &lt;span class=&quot;token tag-name keyword&quot;&gt;endedge&lt;/span&gt; &lt;span class=&quot;token delimiter punctuation&quot;&gt;%}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;For the shortcode, we also designate which templating languages it should use to process the content: Nunjucks &lt;code&gt;njk&lt;/code&gt; and Markdown &lt;code&gt;md&lt;/code&gt;. We need Markdown so that it transforms the authored post content within the &lt;code&gt;premium&lt;/code&gt; variable.&lt;/p&gt;
&lt;p&gt;An important concept is that &lt;strong&gt;Eleventy Edge is not aware of data from your 11ty site&lt;/strong&gt; so it must be explicitly passed into the shortcode. That&#39;s why we must set the &lt;code&gt;loginform&lt;/code&gt; include as a variable as well. Additionally, in order to have named variables within the shortcode, we have to pass them in as an object (but remember: this is Nunjucks, not JS!).&lt;/p&gt;
&lt;p&gt;Finally, the logic within the shortcode says: &amp;quot;If there is premium content and also a valid user, we can show them the content. Otherwise, show the login form instead.&amp;quot;&lt;/p&gt;
&lt;div class=&quot;heading-wrapper h2&quot;&gt;
&lt;h2 id=&quot;next-steps-and-resources&quot;&gt;Next steps and resources&lt;/h2&gt;
&lt;a class=&quot;tdbc-anchor&quot; href=&quot;https://11ty.rocks/posts/building-a-membership-site-with-11ty/#next-steps-and-resources&quot; aria-labelledby=&quot;next-steps-and-resources&quot;&gt;&lt;span hidden=&quot;&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;There are several opportunities for enhancements from &lt;a href=&quot;https://github.com/5t3ph/11ty-membership-site&quot;&gt;the starter theme&lt;/a&gt;.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Create a user dashboard&lt;/li&gt;
&lt;li&gt;Persist user profile data to Supabase&lt;/li&gt;
&lt;li&gt;Add in payment processing&lt;/li&gt;
&lt;li&gt;Use &lt;a href=&quot;https://11ty.rocks/posts/introduction-webc/&quot;&gt;WebC&lt;/a&gt; to save content bookmarks or perform other client-side interactions&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Here are resources to help understand each of the necessary parts more in-depth, and learn how to extend the functionality:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Learn more about all kinds of 11ty topics here on 11ty Rocks!&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://www.11ty.dev/docs/plugins/edge/&quot;&gt;11ty Edge docs&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://supabase.com/docs/guides/auth/overview&quot;&gt;Supabase authentication docs&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://docs.netlify.com/edge-functions/overview/&quot;&gt;Netlify Edge docs&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
</content>
	</entry>
	
	
	<entry>
		<title>11ty Community Links: January 2023</title>
		<link href="https://11ty.rocks/posts/11ty-community-links-january-2023/"/>
		<updated>2023-01-21T00:00:00Z</updated>
		<id>https://11ty.rocks/posts/11ty-community-links-january-2023/</id>
		<content type="html">&lt;ol&gt;
&lt;li&gt;Chris Coleman - “&lt;a href=&quot;https://illtron.net/2023/01/11ty-directory-data-filters/&quot;&gt;Using Eleventy filters in Directory Computed Data&lt;/a&gt;” - shows how a switch to using &lt;code&gt;11tydata.js&lt;/code&gt; instead of JSON for data directory files allows regular JS and therefore more complex logic to work out assigning values for computed data.&lt;/li&gt;
&lt;li&gt;Benny Powers - “&lt;a href=&quot;https://bennypowers.dev/posts/11ty-svg-sprites/&quot;&gt;SVG Icon Sprites in Eleventy&lt;/a&gt;” - uses a technique of creating a collection out of a directory of SVG icons and programmatically turning those into an SVG sprite, and a clever way to add the sprite only once per page where at least one of the associated shortcodes is used.&lt;/li&gt;
&lt;li&gt;Vadim Makeev - “&lt;a href=&quot;https://pepelsbey.dev/articles/eleventy-css-js/&quot;&gt;CSS and JavaScript as first-class citizens in Eleventy&lt;/a&gt;” - shows how to use the v2 additions of &lt;code&gt;addTemplateFormats&lt;/code&gt; and &lt;code&gt;addExtension&lt;/code&gt; to process CSS and JS.&lt;/li&gt;
&lt;li&gt;David Darnes - “&lt;a href=&quot;https://gist.github.com/daviddarnes/8d70d7b8eaee474bcb19e30fc45e63ff&quot;&gt;Compile JavasScript and Sass in Eleventy using Uglify JS and Sass lib&lt;/a&gt;” - is a gist that gives a little different take from Vadim’s article but using the same 11ty features.&lt;/li&gt;
&lt;li&gt;Christopher Kirk-Nielsen - “&lt;a href=&quot;https://chriskirknielsen.com/blog/eleventy-asset-pipeline-precompiled-assets/&quot;&gt;Eleventy Asset Pipeline: Precompiled Assets without Gulp&lt;/a&gt;” - demonstrates an alternative to the previous two articles with the use of &lt;code&gt;eleventy.before&lt;/code&gt; as well as addressing a bit different goals.&lt;/li&gt;
&lt;li&gt;Ashur Cabrera - “&lt;a href=&quot;https://multiline.co/mment/2022/12/importing-external-webc-components&quot;&gt;Importing external components in WebC via NPM&lt;/a&gt;&lt;strong&gt;”&lt;/strong&gt; - explores using &lt;code&gt;webc:import&lt;/code&gt; to share WebC components between projects.&lt;/li&gt;
&lt;li&gt;Lene Saile - “&lt;a href=&quot;https://www.lenesaile.com/en/blog/organizing-the-eleventy-config-file/&quot;&gt;Organizing the Eleventy config file&lt;/a&gt;” - provides some excellent considerations and techniques for taming your 11ty configuration setup.&lt;/li&gt;
&lt;li&gt;Also from Lene - “&lt;a href=&quot;https://github.com/madrilene/eleventy-excellent&quot;&gt;Eleventy Excellent&lt;/a&gt;” - looks like a truly excellent starter to get an 11ty site going quickly!&lt;/li&gt;
&lt;li&gt;Eleventy Blog / Zach Leatherman - “&lt;a href=&quot;https://www.11ty.dev/blog/eleventy-v2-beta/&quot;&gt;The very first beta release of Eleventy v2.0&lt;/a&gt;” - the official announcement of the v2 Beta!&lt;/li&gt;
&lt;li&gt;11ty Rocks / Stephanie Eckles - “&lt;a href=&quot;https://11ty.rocks/posts/new-features-upgrade-considerations-eleventy-version-2/&quot;&gt;New Features and Upgrade Considerations for Eleventy v2.0.0&lt;/a&gt;” - provides a little more context on the major feature additions, breaking changes, and various enhancements to help you prepare for v2.&lt;/li&gt;
&lt;li&gt;Bryan Robinson - “&lt;a href=&quot;https://www.youtube.com/playlist?list=PLOSLUtJ_J3rrNiBBN-wn2BJ11OHiBuC1n&quot;&gt;11ty Second 11ty&lt;/a&gt;” - a YouTube series where Bryan shows off features of Eleventy in snack-size videos.&lt;/li&gt;
&lt;/ol&gt;
&lt;blockquote&gt;
&lt;p&gt;Add your own original article on a unique 11ty topic to the &lt;a href=&quot;https://11ty.rocks/community/&quot;&gt;11ty Rocks Community Resource&lt;/a&gt; page!&lt;/p&gt;
&lt;/blockquote&gt;
</content>
	</entry>
	
	
	<entry>
		<title>New Features and Upgrade Considerations for Eleventy v2.0.0</title>
		<link href="https://11ty.rocks/posts/new-features-upgrade-considerations-eleventy-version-2/"/>
		<updated>2023-01-12T00:00:00Z</updated>
		<id>https://11ty.rocks/posts/new-features-upgrade-considerations-eleventy-version-2/</id>
		<content type="html">&lt;p&gt;2.0.0 canaries have been available for quite some time, and creator Zach Leatherman has helpfully been updating the docs by adding labels to note when a feature became available.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;The &lt;a href=&quot;https://www.11ty.dev/blog/eleventy-v2/&quot;&gt;2.0.0 release&lt;/a&gt; is available as of February 8, 2023, which includes the changes noted in this article.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Recently, I set out to create a new Eleventy project for the first time in a few months using the latest Canary and hit some unexpected errors. That led me down the rabbit hole to see what exactly had changed so I could be prepared to update projects, especially as I use similar setups cross-project and maintain a few 11ty starters.&lt;/p&gt;
&lt;p&gt;This may not be 100% comprehensive, but it includes the most impactful highlights for general use of 11ty.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;If it’s been a while since you created or updated an Eleventy project, you may want to glance at the last section for &lt;a href=&quot;https://11ty.rocks/posts/new-features-upgrade-considerations-eleventy-version-2/#what-you-missed-from-v100&quot;&gt;features you might have missed from v1.0.0&lt;/a&gt;.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;div class=&quot;heading-wrapper h2&quot;&gt;
&lt;h2 id=&quot;major-feature-additions&quot;&gt;Major Feature Additions&lt;/h2&gt;
&lt;a class=&quot;tdbc-anchor&quot; href=&quot;https://11ty.rocks/posts/new-features-upgrade-considerations-eleventy-version-2/#major-feature-additions&quot; aria-labelledby=&quot;major-feature-additions&quot;&gt;&lt;span hidden=&quot;&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;heading-wrapper h3&quot;&gt;
&lt;h3 id=&quot;eleventy-edge&quot;&gt;Eleventy Edge&lt;/h3&gt;
&lt;a class=&quot;tdbc-anchor&quot; href=&quot;https://11ty.rocks/posts/new-features-upgrade-considerations-eleventy-version-2/#eleventy-edge&quot; aria-labelledby=&quot;eleventy-edge&quot;&gt;&lt;span hidden=&quot;&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;Currently only available for projects run on Netlify, this exciting addition brings a shortcode that allows dynamic content to be added to your projects &lt;em&gt;on the edge&lt;/em&gt;. What’s that, you say? It means you can modify a page request before the page content is sent to the user, which allows getting data like the user’s timezone. It also enables retrieving cookies to check if the user is authenticated and permitted to access a particular route. Or, it offers the chance to set cookies to persist preferences like a color theme. These ideas are just the beginning of what’s possible with &lt;a href=&quot;https://www.11ty.dev/docs/plugins/edge/&quot;&gt;Eleventy Edge&lt;/a&gt;!&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Join me on January 25 and 26 for &lt;a href=&quot;http://thejam.dev/&quot;&gt;TheJam.dev&lt;/a&gt; where I’ll demonstrate using Eleventy Edge to build a membership site on Eleventy.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;div class=&quot;heading-wrapper h3&quot;&gt;
&lt;h3 id=&quot;webc&quot;&gt;WebC&lt;/h3&gt;
&lt;a class=&quot;tdbc-anchor&quot; href=&quot;https://11ty.rocks/posts/new-features-upgrade-considerations-eleventy-version-2/#webc&quot; aria-labelledby=&quot;webc&quot;&gt;&lt;span hidden=&quot;&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;In line with moves made by other site builders, &lt;a href=&quot;https://www.11ty.dev/docs/languages/webc/&quot;&gt;WebC&lt;/a&gt; offers the ability for single-file web components. Really what that means is WebC is a first-class templating language in Eleventy that you can use to render “real” web components or as an alternative to solutions like Nunjucks includes and macros for reusable components in your 11ty site.&lt;/p&gt;
&lt;p&gt;Check out these posts from 11ty Rocks to learn more about WebC use cases and features:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://11ty.rocks/posts/introduction-webc/&quot;&gt;Introduction to WebC&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://11ty.rocks/posts/understanding-webc-features-and-concepts/&quot;&gt;Understanding WebC Features and Concepts&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&quot;heading-wrapper h2&quot;&gt;
&lt;h2 id=&quot;breaking-changes&quot;&gt;Breaking Changes&lt;/h2&gt;
&lt;a class=&quot;tdbc-anchor&quot; href=&quot;https://11ty.rocks/posts/new-features-upgrade-considerations-eleventy-version-2/#breaking-changes&quot; aria-labelledby=&quot;breaking-changes&quot;&gt;&lt;span hidden=&quot;&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href=&quot;https://www.11ty.dev/blog/eleventy-v2/#breaking-changes&quot;&gt;A few changes&lt;/a&gt; as noted in the release notes, which Zach recommends using the &lt;a href=&quot;https://github.com/11ty/eleventy-upgrade-help&quot;&gt;eleventy-upgrade-helper plugin&lt;/a&gt; to discover whether your site is impacted.&lt;/p&gt;
&lt;p&gt;Update from an earlier version of this post: &lt;a href=&quot;https://www.11ty.dev/docs/copy/#emulate-passthrough-copy-during-serve&quot;&gt;a proposed breaking change&lt;/a&gt; to &lt;code&gt;addPassthroughCopy&lt;/code&gt; was reversed.&lt;/p&gt;
&lt;div class=&quot;heading-wrapper h2&quot;&gt;
&lt;h2 id=&quot;configuration-build-and-serve&quot;&gt;Configuration, Build, and Serve&lt;/h2&gt;
&lt;a class=&quot;tdbc-anchor&quot; href=&quot;https://11ty.rocks/posts/new-features-upgrade-considerations-eleventy-version-2/#configuration-build-and-serve&quot; aria-labelledby=&quot;configuration-build-and-serve&quot;&gt;&lt;span hidden=&quot;&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;First up, there are now new options for naming your &lt;a href=&quot;https://www.11ty.dev/docs/config/#default-filenames&quot;&gt;Eleventy config file&lt;/a&gt;.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;code&gt;.eleventy.js&lt;/code&gt; - only option &amp;lt; v2.0.0-canary.15&lt;/li&gt;
&lt;li&gt;&lt;code&gt;eleventy.config.js&lt;/code&gt; - coming in v2&lt;/li&gt;
&lt;li&gt;&lt;code&gt;eleventy.config.cjs&lt;/code&gt; - coming in v2&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;The default &lt;a href=&quot;https://www.11ty.dev/docs/dev-server/&quot;&gt;Eleventy dev server&lt;/a&gt; is now a custom solution instead of BrowserSync. If you have customizations reliant on BrowserSync, you can &lt;a href=&quot;https://www.11ty.dev/docs/dev-server/#swap-back-to-browsersync&quot;&gt;revert back&lt;/a&gt; with a config option. However, the default server is much faster and lighter and doesn’t require loading any JS during watch and serve local dev.&lt;/p&gt;
&lt;p&gt;If your site benefits from programmatic ignores (like separating dev vs. prod environment files), you may be interested to know that &lt;code&gt;--watch&lt;/code&gt; ignores are now available separately.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://www.11ty.dev/docs/ignores/#configuration-api-added-in-v1.0.0&quot;&gt;Regular ignore management&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://www.11ty.dev/docs/watch-serve/#configuration-api&quot;&gt;Watch ignore management&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Various enhancements landed for &lt;a href=&quot;https://www.11ty.dev/docs/usage/incremental/&quot;&gt;incremental builds&lt;/a&gt;, notably:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Layouts&lt;/strong&gt; - a change rebuilds any templates using that layout&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Collections&lt;/strong&gt; - adding or deleting a tag from a template will rebuild any related templates&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;To make local dev even faster, you may wish to &lt;a href=&quot;https://www.11ty.dev/docs/copy/#emulate-passthrough-copy-during-serve&quot;&gt;opt-in to emulated passthrough file copying&lt;/a&gt; for faster local builds. Note that opting-in may have breaking behavior if you are copying through files that other processes depend on. For instance, maybe you are referencing a file for your serverless build or a plugin requires a precise and real file path from your final output. In that case, simply do not opt-in to this feature.&lt;/p&gt;
&lt;p&gt;A new command line flag of &lt;code&gt;--ignore-initial&lt;/code&gt; will &lt;a href=&quot;https://www.11ty.dev/docs/usage/#ignore-initial-to-run-eleventy-without-an-initial-build&quot;&gt;run Eleventy without an initial build&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;The configuration events added in v1 will have &lt;a href=&quot;https://www.11ty.dev/docs/events/#event-arguments&quot;&gt;event arguments&lt;/a&gt; available in v2 that provide metadata about the build, including the following objects:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;dir&lt;/code&gt; - object with current project directories&lt;/li&gt;
&lt;li&gt;&lt;code&gt;outputMode&lt;/code&gt; - default is &lt;code&gt;fs&lt;/code&gt; (file system), or &lt;a href=&quot;https://www.11ty.dev/docs/usage/#to-can-output-json-added-in-v1.0.0&quot;&gt;option passed via —to&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;runMode&lt;/code&gt; - one of &lt;code&gt;build&lt;/code&gt;, &lt;code&gt;watch&lt;/code&gt;, or &lt;code&gt;serve&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;results&lt;/code&gt; - for &lt;code&gt;eleventy.after&lt;/code&gt; only, includes processed Eleventy output&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Finally, for configuration updates, if you don’t want directory indexes created by default, you can &lt;a href=&quot;https://www.11ty.dev/docs/data-eleventy-supplied/#changing-your-project-default-permalinks&quot;&gt;change your default permalinks&lt;/a&gt; with this snippet.&lt;/p&gt;
&lt;div class=&quot;heading-wrapper h2&quot;&gt;
&lt;h2 id=&quot;custom-data-and-data-cascade&quot;&gt;Custom Data and Data Cascade&lt;/h2&gt;
&lt;a class=&quot;tdbc-anchor&quot; href=&quot;https://11ty.rocks/posts/new-features-upgrade-considerations-eleventy-version-2/#custom-data-and-data-cascade&quot; aria-labelledby=&quot;custom-data-and-data-cascade&quot;&gt;&lt;span hidden=&quot;&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;The &lt;a href=&quot;https://www.11ty.dev/docs/data-eleventy-supplied/&quot;&gt;supplied data variables&lt;/a&gt; of &lt;code&gt;eleventy&lt;/code&gt; (added in v1) and &lt;code&gt;page&lt;/code&gt; will be available as of v2 in filters and shortcodes. The &lt;code&gt;page&lt;/code&gt; variable has also been extended to transforms, linters, and collection entries.&lt;/p&gt;
&lt;p&gt;I’m a big fan of directory data files (&lt;a href=&quot;https://11ty.rocks/tips/data-directory-file/&quot;&gt;here are some tips&lt;/a&gt; for using them). In v2, you can configure &lt;a href=&quot;https://www.11ty.dev/docs/config/#change-base-file-name-for-data-files&quot;&gt;a different base file name&lt;/a&gt; for them instead of the default of matching them to the directory file name, ex. &lt;code&gt;index&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://www.11ty.dev/docs/data-custom/&quot;&gt;Custom data formats&lt;/a&gt; (the ability to support additional template extensions) received various updates.&lt;/p&gt;
&lt;p&gt;A late addition for Eleventy Serverless (introduced v1) added the ability to &lt;a href=&quot;https://www.11ty.dev/docs/plugins/serverless/#compile-the-data-cascade-for-the-project&quot;&gt;compile the data cascade&lt;/a&gt;. This means access to collections without extra hoops to make them available to serverless templates (with caveats noted in docs).&lt;/p&gt;
&lt;div class=&quot;heading-wrapper h2&quot;&gt;
&lt;h2 id=&quot;collections-filters-and-shortcodes&quot;&gt;Collections, Filters, and Shortcodes&lt;/h2&gt;
&lt;a class=&quot;tdbc-anchor&quot; href=&quot;https://11ty.rocks/posts/new-features-upgrade-considerations-eleventy-version-2/#collections-filters-and-shortcodes&quot; aria-labelledby=&quot;collections-filters-and-shortcodes&quot;&gt;&lt;span hidden=&quot;&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;An exciting update for those of us who have tried to get dynamic/real-time data pulled at build-time is &lt;a href=&quot;https://www.11ty.dev/docs/shortcodes/#asynchronous-universal-shortcodes&quot;&gt;universal async shortcodes&lt;/a&gt; &lt;em&gt;and&lt;/em&gt; &lt;a href=&quot;https://www.11ty.dev/docs/filters/#asynchronous-universal-filters&quot;&gt;universal async filters&lt;/a&gt;!&lt;/p&gt;
&lt;p&gt;Collections received a couple of updates, including:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://www.11ty.dev/docs/collections/#declare-your-collections-for-incremental-builds&quot;&gt;declaring collections for incremental builds&lt;/a&gt; to trigger rebuilds when a collection item is changed&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://www.11ty.dev/docs/collections/#collection-item-data-structure&quot;&gt;new/updated data structure for collection items&lt;/a&gt;, notably:
&lt;ul&gt;
&lt;li&gt;Use &lt;code&gt;page.url&lt;/code&gt; instead of &lt;code&gt;url&lt;/code&gt; (see docs for other properties moved to &lt;code&gt;page&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;Use &lt;code&gt;content&lt;/code&gt; instead of &lt;code&gt;data.templateContent&lt;/code&gt; to get the compiled output&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;You can now &lt;a href=&quot;https://www.11ty.dev/docs/filters/log/#using-log-in-filter-chains&quot;&gt;chain ‘log’ in filters&lt;/a&gt;, for example &lt;code&gt;{{ myData | log | otherFilter }}&lt;/code&gt;. Whereas before, you would have to break those calls apart, now &lt;code&gt;log&lt;/code&gt; will output and then pass the data along the chain to the next filter.&lt;/p&gt;
&lt;div class=&quot;heading-wrapper h2&quot;&gt;
&lt;h2 id=&quot;content-creation&quot;&gt;Content Creation&lt;/h2&gt;
&lt;a class=&quot;tdbc-anchor&quot; href=&quot;https://11ty.rocks/posts/new-features-upgrade-considerations-eleventy-version-2/#content-creation&quot; aria-labelledby=&quot;content-creation&quot;&gt;&lt;span hidden=&quot;&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;Here are some quick hits that may impact how you create content with Eleventy:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://www.11ty.dev/docs/dates/&quot;&gt;new date option&lt;/a&gt;: &lt;code&gt;git Created&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;pagination option to &lt;a href=&quot;https://www.11ty.dev/docs/pagination/#generating-an-empty-results-page&quot;&gt;allow empty pages&lt;/a&gt; when no data is available&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://www.11ty.dev/docs/permalinks/#mapping-one-url-to-multiple-files-for-internationalization&quot;&gt;map one URL to multiple files&lt;/a&gt;, useful for scenarios like internationalization&lt;/li&gt;
&lt;li&gt;Markdown processing by default now has &lt;a href=&quot;https://www.11ty.dev/docs/languages/markdown/#indented-code-blocks&quot;&gt;disabled indented code blocks&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Also, when defining layout files, it is now &lt;a href=&quot;https://www.11ty.dev/docs/layouts/#omitting-the-layouts-file-extension&quot;&gt;strongly recommended to include the layout file extension&lt;/a&gt;. This is due to the slowness of determining which file is actually meant to be used when no extension is included.&lt;/p&gt;
&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;---&lt;br /&gt;layout: base &lt;- no longer recommended&lt;br /&gt;layout: base.njk &lt;- best practice: always add file extension&lt;br /&gt;---&lt;/code&gt;&lt;/pre&gt;
&lt;div class=&quot;heading-wrapper h2&quot;&gt;
&lt;h2 id=&quot;upgrading-to-v200&quot;&gt;Upgrading to v2.0.0&lt;/h2&gt;
&lt;a class=&quot;tdbc-anchor&quot; href=&quot;https://11ty.rocks/posts/new-features-upgrade-considerations-eleventy-version-2/#upgrading-to-v200&quot; aria-labelledby=&quot;upgrading-to-v200&quot;&gt;&lt;span hidden=&quot;&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;The top two things that may impact your current projects are:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;changing &lt;a href=&quot;https://11ty.rocks/posts/new-features-upgrade-considerations-eleventy-version-2/#collections-filters-and-shortcodes&quot;&gt;collection data references&lt;/a&gt; like &lt;code&gt;url&lt;/code&gt; to be based off of &lt;code&gt;page&lt;/code&gt; and updating &lt;code&gt;templateContent&lt;/code&gt; to &lt;code&gt;content&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://11ty.rocks/posts/new-features-upgrade-considerations-eleventy-version-2/#content-creation&quot;&gt;including the file extension&lt;/a&gt; when you define a layout, ex &lt;code&gt;layout: base.njk&lt;/code&gt; instead of &lt;code&gt;layout: base&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;And, perhaps you may want to &lt;a href=&quot;https://11ty.rocks/posts/new-features-upgrade-considerations-eleventy-version-2/#configuration-build-and-serve&quot;&gt;change the name of your Eleventy config&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;There&#39;s also an upgrade plugin available: &lt;a href=&quot;https://github.com/11ty/eleventy-upgrade-help&quot;&gt;eleventy-upgrade-help&lt;/a&gt;&lt;/p&gt;
&lt;div class=&quot;heading-wrapper h2&quot;&gt;
&lt;h2 id=&quot;what-you-missed-from-v100&quot;&gt;What You Missed From v1.0.0&lt;/h2&gt;
&lt;a class=&quot;tdbc-anchor&quot; href=&quot;https://11ty.rocks/posts/new-features-upgrade-considerations-eleventy-version-2/#what-you-missed-from-v100&quot; aria-labelledby=&quot;what-you-missed-from-v100&quot;&gt;&lt;span hidden=&quot;&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;I started using Eleventy at version 0.10.0 in April 2020, and v1.0.0 stable was released a year and a half later, on &lt;a href=&quot;https://www.11ty.dev/blog/eleventy-one-point-oh/&quot;&gt;January 9, 2022&lt;/a&gt;. If you also did most of your learning with Eleventy before v1 and haven’t updated things or built new in a while, there’s a good chance you missed some of the following!&lt;/p&gt;
&lt;p&gt;Probably the biggest feature splash was &lt;a href=&quot;https://www.11ty.dev/docs/plugins/serverless/&quot;&gt;Eleventy Serverless&lt;/a&gt;, which enables building entire templates upon page request for fully dynamic pages. The two available modes are:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;On-demand builders&lt;/strong&gt; which cache the result after the first page request (rebuild to expire), great for infrequently used pages or generating open graph images&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Dynamic templates&lt;/strong&gt; which re-render on every page request, great for CMS previews, accepting user input, or even to &lt;a href=&quot;https://11ty-serverless-search.netlify.app/&quot;&gt;generate and display site search results&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Here are several other key updates from Eleventy v1.0.0:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;slug&lt;/code&gt; filter changed to &lt;code&gt;slugify&lt;/code&gt; with &lt;a href=&quot;https://www.11ty.dev/docs/filters/slugify/&quot;&gt;better special character handling&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://www.11ty.dev/docs/dates/&quot;&gt;Date formats&lt;/a&gt; are assumed to be UTC&lt;/li&gt;
&lt;li&gt;Noted earlier, but &lt;a href=&quot;https://www.11ty.dev/docs/events/&quot;&gt;configuration events&lt;/a&gt; to run code &lt;code&gt;before&lt;/code&gt; or &lt;code&gt;after&lt;/code&gt; compile&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://www.11ty.dev/docs/data-deep-merge/&quot;&gt;Data deep merge on by default&lt;/a&gt; resulting in data like tags that are added in a template and a layout being merged together, rather than the template, which has higher data cascade priority, having only its tags used&lt;/li&gt;
&lt;li&gt;Speaking of the data cascade, the priority of &lt;a href=&quot;https://www.11ty.dev/docs/data-cascade/#sources-of-data&quot;&gt;front matter data in layouts&lt;/a&gt; was &lt;em&gt;lowered&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;Global data was allowed to be &lt;a href=&quot;https://www.11ty.dev/docs/data-global-custom/&quot;&gt;added from the config file&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://www.11ty.dev/docs/languages/custom/&quot;&gt;Custom template extensions&lt;/a&gt; allow adding your own template formats &lt;em&gt;and&lt;/em&gt; provide a custom compiler, such as the docs example of adding Sass processing&lt;/li&gt;
&lt;li&gt;The &lt;a href=&quot;https://www.11ty.dev/docs/plugins/render/&quot;&gt;render plugin&lt;/a&gt; enables shortcodes to render template strings or files inside of a template of a different template language, ex. render a Markdown block within Nunjucks&lt;/li&gt;
&lt;/ul&gt;
&lt;hr /&gt;
&lt;p&gt;Whew, that was a lot! Go forth and enjoy building with these new and updated Eleventy features! &lt;strong&gt;PS - if you&#39;re new to Eleventy&lt;/strong&gt;, check out my guide to &lt;a href=&quot;https://11ty.rocks/posts/create-your-first-basic-11ty-website/&quot;&gt;creating your first basic 11ty website&lt;/a&gt;.&lt;/p&gt;
</content>
	</entry>
	
	
	<entry>
		<title>Understanding WebC Features and Concepts</title>
		<link href="https://11ty.rocks/posts/understanding-webc-features-and-concepts/"/>
		<updated>2022-10-24T00:00:00Z</updated>
		<id>https://11ty.rocks/posts/understanding-webc-features-and-concepts/</id>
		<content type="html">&lt;blockquote&gt;
&lt;p&gt;If you haven’t yet heard of WebC, check out another 11ty Rocks article, &lt;a href=&quot;https://11ty.rocks/posts/introduction-webc&quot;&gt;Introduction to WebC&lt;/a&gt;.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;div class=&quot;heading-wrapper h2&quot;&gt;
&lt;h2 id=&quot;including-webc-components-outside-of-webc-templates&quot;&gt;Including WebC components outside of &lt;code&gt;.webc&lt;/code&gt; templates&lt;/h2&gt;
&lt;a class=&quot;tdbc-anchor&quot; href=&quot;https://11ty.rocks/posts/understanding-webc-features-and-concepts/#including-webc-components-outside-of-webc-templates&quot; aria-labelledby=&quot;including-webc-components-outside-of-webc-templates&quot;&gt;&lt;span hidden=&quot;&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;One option for using WebC is to go all in and start defining your templates using the &lt;code&gt;.webc&lt;/code&gt; extension. If you do that, you’ll also get access to any components you define due to already being within a WebC context.&lt;/p&gt;
&lt;p&gt;For myself, I want to use my WebC components within other templates that I already have. Typically, I favor Nunjucks and Markdown for my 11ty projects.&lt;/p&gt;
&lt;p&gt;One way to make WebC components available to other template types is by listing the path under the &lt;code&gt;components&lt;/code&gt; option for the WebC plugin (aka “&lt;a href=&quot;https://www.11ty.dev/docs/languages/webc/#defining-components&quot;&gt;global no-import components&lt;/a&gt;”). The gotcha here is when you have also customized your 11ty &lt;code&gt;input&lt;/code&gt; directory to something besides the default of the project root.&lt;/p&gt;
&lt;p&gt;The &lt;code&gt;components&lt;/code&gt; path is &lt;em&gt;root-relative&lt;/em&gt; as opposed to &lt;em&gt;input directory relative&lt;/em&gt;, which means that if you customize the &lt;code&gt;input&lt;/code&gt; directory, you’ll need to include that in the path update.&lt;/p&gt;
&lt;p&gt;I like to &lt;a href=&quot;https://www.11ty.dev/docs/config/#input-directory&quot;&gt;customize the &lt;code&gt;input&lt;/code&gt; directory&lt;/a&gt; to &lt;code&gt;src&lt;/code&gt;, which makes the following my path when following the recommendation to put the &lt;code&gt;components&lt;/code&gt; directory inside the &lt;code&gt;_includes&lt;/code&gt; directory.&lt;/p&gt;
&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;eleventyConfig&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;addPlugin&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;pluginWebc&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token literal-property property&quot;&gt;components&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;src/_includes/components/**/*.webc&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Extra gotcha&lt;/strong&gt;: If you try to place your &lt;code&gt;components&lt;/code&gt; directory outside the &lt;code&gt;_includes&lt;/code&gt; directory, you’ll have to resolve ignoring it during 11ty’s build process, which is already handled if you stick with placing it in &lt;code&gt;_includes&lt;/code&gt;. Otherwise, your components will build out as extra pages which is not the behavior you want!&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;You’ll also need to &lt;a href=&quot;https://www.11ty.dev/docs/languages/webc/#use-the-render-plugin&quot;&gt;include the Render plugin&lt;/a&gt; to process your WebC components outside of &lt;code&gt;.webc&lt;/code&gt; templates, which supports Liquid, Nunjucks, and 11ty.js.&lt;/p&gt;
&lt;p&gt;The Render plugin is included with 11ty but is opt-in, so here are the changes to make to your config:&lt;/p&gt;
&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;// .eleventy.js&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; EleventyRenderPlugin &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;require&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;@11ty/eleventy&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token comment&quot;&gt;// Add the plugin within your existing module export&lt;/span&gt;&lt;br /&gt;module&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function-variable function&quot;&gt;exports&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;eleventyConfig&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;  eleventyConfig&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;addPlugin&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;EleventyRenderPlugin&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Then you can use the Render plugin to wrap your WebC component when outside of a &lt;code&gt;.webc&lt;/code&gt; template.&lt;/p&gt;
&lt;pre class=&quot;language-twig&quot;&gt;&lt;code class=&quot;language-twig&quot;&gt;// Nunjucks&lt;br /&gt;&lt;span class=&quot;token twig language-twig&quot;&gt;&lt;span class=&quot;token delimiter punctuation&quot;&gt;{%&lt;/span&gt; &lt;span class=&quot;token tag-name keyword&quot;&gt;renderTemplate&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;webc&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token delimiter punctuation&quot;&gt;%}&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;my-custom-component&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;my-custom-component&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token twig language-twig&quot;&gt;&lt;span class=&quot;token delimiter punctuation&quot;&gt;{%&lt;/span&gt; &lt;span class=&quot;token tag-name keyword&quot;&gt;endrenderTemplate&lt;/span&gt; &lt;span class=&quot;token delimiter punctuation&quot;&gt;%}&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;blockquote&gt;
&lt;p&gt;Unfortunately, using the Render plugin to try to render your WebC components in markdown will not be successful. I’ve &lt;a href=&quot;https://github.com/11ty/eleventy/issues/2607&quot;&gt;created an issue&lt;/a&gt; to hopefully work this out for folks like myself who write blog posts with markdown.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;div class=&quot;heading-wrapper h2&quot;&gt;
&lt;h2 id=&quot;static-html-webc-rendering-vs-web-component-rendering&quot;&gt;Static HTML WebC rendering vs. web component rendering&lt;/h2&gt;
&lt;a class=&quot;tdbc-anchor&quot; href=&quot;https://11ty.rocks/posts/understanding-webc-features-and-concepts/#static-html-webc-rendering-vs-web-component-rendering&quot; aria-labelledby=&quot;static-html-webc-rendering-vs-web-component-rendering&quot;&gt;&lt;span hidden=&quot;&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;Since WebC is very new, a misconception I had was that it created “real” web components in all instances. As it turns out, using WebC for native web component rendering is not the primary concern and entirely up to you as the author.&lt;/p&gt;
&lt;div class=&quot;heading-wrapper h3&quot;&gt;
&lt;h3 id=&quot;webc-for-static-html&quot;&gt;WebC for static HTML&lt;/h3&gt;
&lt;a class=&quot;tdbc-anchor&quot; href=&quot;https://11ty.rocks/posts/understanding-webc-features-and-concepts/#webc-for-static-html&quot; aria-labelledby=&quot;webc-for-static-html&quot;&gt;&lt;span hidden=&quot;&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;WebC promotes the use of static HTML and can be used as a way to include HTML that has awareness of the Eleventy data cascade. This makes WebC an alternative to methods like Nunjucks includes or macros, or Eleventy shortcodes.&lt;/p&gt;
&lt;p&gt;When using WebC for static HTML components, the outer wrapper - for example, &lt;code&gt;&amp;lt;my-component&amp;gt;&lt;/code&gt; - is removed in the final rendering.&lt;/p&gt;
&lt;p&gt;Once you include a &lt;code&gt;style&lt;/code&gt; or &lt;code&gt;script&lt;/code&gt; block in your WebC component, it is treated as a custom element. By default the outer wrapper - aka the “host component” - is retained, which is the first difference from HTML-only WebC components. A unique aspect of how WebC handles this rendering is that you can overload &lt;em&gt;any&lt;/em&gt; existing element, such as &lt;code&gt;blockquote&lt;/code&gt; or &lt;code&gt;img&lt;/code&gt;.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;If you’re interested in how WebC handles scripts and styles, learn about &lt;a href=&quot;https://www.11ty.dev/docs/languages/webc/#asset-bundling&quot;&gt;WebC asset bundling&lt;/a&gt; in the docs.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Up until the point you register a web component, you still have a static HTML WebC component. This means you can still leverage scoped styles and co-locate your scripts and take advantage of the WebC format without the jump to a &amp;quot;real&amp;quot; web component.&lt;/p&gt;
&lt;div class=&quot;heading-wrapper h3&quot;&gt;
&lt;h3 id=&quot;webc-for-web-components&quot;&gt;WebC for web components&lt;/h3&gt;
&lt;a class=&quot;tdbc-anchor&quot; href=&quot;https://11ty.rocks/posts/understanding-webc-features-and-concepts/#webc-for-web-components&quot; aria-labelledby=&quot;webc-for-web-components&quot;&gt;&lt;span hidden=&quot;&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;So, what if you want a &lt;em&gt;real&lt;/em&gt; web component? If you have low experience with creating them, a gotcha may be that in order to register a native web component, it needs to have a hyphenated name like &lt;code&gt;super-slider&lt;/code&gt; and not just &lt;code&gt;slider&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;You’ll also need to ensure that when you place the &lt;code&gt;script&lt;/code&gt; tag for the asset bundle that it includes the attribute &lt;code&gt;type=&amp;quot;module&amp;quot;&lt;/code&gt; or the browser will prevent it registering correctly.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;It should be noted that WebC becomes the manager for scripts and styles but the native web component behavior described doesn’t strictly require WebC.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;11ty’s creator, Zach Leatherman, is positioning WebC as a convenience for building progressively enhanced components that work when Javascript is not available. One method that may be appropriate if your component relies on JS to work is to wrap your WebC content with the native HTML &lt;code&gt;template&lt;/code&gt; element. This will prevent the contents rendering immediately to the page. Then, by registering your web component, which happens with JS, you can reveal the &lt;code&gt;template&lt;/code&gt; contents.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Evan shows this &lt;a href=&quot;https://11ty.rocks/posts/introduction-webc/#webc-for-web-components&quot;&gt;pattern of using &lt;code&gt;template&lt;/code&gt;&lt;/a&gt; in the &lt;code&gt;theme-select&lt;/code&gt; example from the 11ty Rocks’ article Introduction to WebC.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;We&#39;ll review a bit more advanced use of &lt;code&gt;template&lt;/code&gt; in the last section.&lt;/p&gt;
&lt;div class=&quot;heading-wrapper h2&quot;&gt;
&lt;h2 id=&quot;styling-for-custom-elements-and-web-components&quot;&gt;Styling for custom elements and web components&lt;/h2&gt;
&lt;a class=&quot;tdbc-anchor&quot; href=&quot;https://11ty.rocks/posts/understanding-webc-features-and-concepts/#styling-for-custom-elements-and-web-components&quot; aria-labelledby=&quot;styling-for-custom-elements-and-web-components&quot;&gt;&lt;span hidden=&quot;&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;It may surprise you (as it did me!) to see that styles are applied to custom elements without a shadow DOM. This includes affecting what renders after the &lt;code&gt;template&lt;/code&gt; content becomes visible using the method described.&lt;/p&gt;
&lt;p&gt;You can use two native CSS selectors to distinguish between the states of before and after the component is registered, which is especially useful if not all your component elements are wrapped up in &lt;code&gt;template&lt;/code&gt;.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;:host&lt;/code&gt; - refers to the parent custom element/web component&lt;/li&gt;
&lt;li&gt;&lt;code&gt;:host:defined&lt;/code&gt; - the “defined” state is true after a web component is registered, which effectively also means when JS is available&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;For general use of &lt;code&gt;:host&lt;/code&gt; outside of a shadow DOM, within WebC you’ll also need to set &lt;code&gt;webc:scoped&lt;/code&gt; on &lt;code&gt;style&lt;/code&gt;. WebC will then hijack &lt;code&gt;:host&lt;/code&gt; to generate a hashed class for “scoping” the styles you define to your custom element.&lt;/p&gt;
&lt;p&gt;This WebC concept means you can use &lt;code&gt;:host&lt;/code&gt; when you’ve defined a custom element that isn’t registered to become a web component to benefit from scoping.&lt;/p&gt;
&lt;p&gt;Alternatively, you can apply classes within your &lt;code&gt;.webc&lt;/code&gt; component or per instance and use styles from your stylesheet and any framework. WebC will merge classes as necessary and will apply the classes to the outer custom element.&lt;/p&gt;
&lt;div class=&quot;heading-wrapper h2&quot;&gt;
&lt;h2 id=&quot;data-within-webc-components&quot;&gt;Data within WebC components&lt;/h2&gt;
&lt;a class=&quot;tdbc-anchor&quot; href=&quot;https://11ty.rocks/posts/understanding-webc-features-and-concepts/#data-within-webc-components&quot; aria-labelledby=&quot;data-within-webc-components&quot;&gt;&lt;span hidden=&quot;&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;There are three main ways to render data passed into your WebC component:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;@html&lt;/code&gt; allows rendering the attribute as the HTML content&lt;/li&gt;
&lt;li&gt;dynamic attributes are created be prepending an HTML attribute with a colon, like &lt;code&gt;:att&lt;/code&gt; and filling it with the corresponding attribute from the host component&lt;/li&gt;
&lt;li&gt;slots, which we’ll discuss in the next section&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Both &lt;code&gt;@html&lt;/code&gt; and dynamic attributes allow rendering of attributes/props passed to the host component. The following shows how to use each for a form field component.&lt;/p&gt;
&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;&amp;lt;!-- page.webc --&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;form-field&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;label&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;Name&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;type&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;text&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;value&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;Stephanie&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;form-field&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token comment&quot;&gt;&amp;lt;!-- form-field.webc --&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;label&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;@html&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;label&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;label&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;input&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;:type&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;type&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;:value&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;value&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;/&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;div class=&quot;heading-wrapper h3&quot;&gt;
&lt;h3 id=&quot;unique-values-using-uid&quot;&gt;Unique values using &lt;code&gt;uid&lt;/code&gt;&lt;/h3&gt;
&lt;a class=&quot;tdbc-anchor&quot; href=&quot;https://11ty.rocks/posts/understanding-webc-features-and-concepts/#unique-values-using-uid&quot; aria-labelledby=&quot;unique-values-using-uid&quot;&gt;&lt;span hidden=&quot;&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;An (as yet) undocumented feature of the WebC plugin is the attribute &lt;code&gt;uid&lt;/code&gt; which generates a unique string per instance. We can use this to enhance our &lt;code&gt;form-field&lt;/code&gt; component to ensure each field has a unique &lt;code&gt;id&lt;/code&gt; and semantically using that as the value of the label &lt;code&gt;for&lt;/code&gt; as well.&lt;/p&gt;
&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;&amp;lt;!-- form-field.webc --&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;label&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;@html&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;label&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;:for&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;uid&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;label&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;input&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;:type&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;type&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;:value&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;value&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;:id&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;uid&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;/&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token comment&quot;&gt;&amp;lt;!-- renders to: --&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;label&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;for&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;webc-97Lq2&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;Name&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;label&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;input&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;type&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;text&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;value&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;Stephanie&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;webc-97Lq2&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;/&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;div class=&quot;heading-wrapper h3&quot;&gt;
&lt;h3 id=&quot;concatenating-strings&quot;&gt;Concatenating strings&lt;/h3&gt;
&lt;a class=&quot;tdbc-anchor&quot; href=&quot;https://11ty.rocks/posts/understanding-webc-features-and-concepts/#concatenating-strings&quot; aria-labelledby=&quot;concatenating-strings&quot;&gt;&lt;span hidden=&quot;&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;Keeping with our &lt;code&gt;form-field&lt;/code&gt;, perhaps we want to enable a field description. For accessibility we should tie that to the field with &lt;code&gt;aria-describedby&lt;/code&gt;. We can concatenate an extra string with the &lt;code&gt;uid&lt;/code&gt; to create the &lt;code&gt;id&lt;/code&gt; for that relationship:&lt;/p&gt;
&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;input&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;:type&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;type&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;:value&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;value&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;:id&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;uid&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;:aria-describedby&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&#39;&lt;/span&gt;desc-&#39; + uid&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;/&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;p&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;:id&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&#39;&lt;/span&gt;desc-&#39; + uid&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;@html&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;description&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;p&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This JS-flavored syntax for concatenating works for any dynamic attribute, as well as populating the &lt;code&gt;@html&lt;/code&gt; value. Alternatively, you can use template literal strings, such as &lt;code&gt;:id=&amp;quot;`desc-${uid}`&amp;quot;&lt;/code&gt;.&lt;/p&gt;
&lt;div class=&quot;heading-wrapper h3&quot;&gt;
&lt;h3 id=&quot;privatising-attributes&quot;&gt;Privatising attributes&lt;/h3&gt;
&lt;a class=&quot;tdbc-anchor&quot; href=&quot;https://11ty.rocks/posts/understanding-webc-features-and-concepts/#privatising-attributes&quot; aria-labelledby=&quot;privatising-attributes&quot;&gt;&lt;span hidden=&quot;&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;So far, this example is static HTML so WebC strips the custom element from the final render. If we add some scoped style, the custom element is retained. Additionally, the attributes we passed in are also retained as attributes on the custom element and are visible in the browser:&lt;/p&gt;
&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;&amp;lt;!-- rendered source --&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;form-field&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token attr-name&quot;&gt;label&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;Name&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token attr-name&quot;&gt;type&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;text&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token attr-name&quot;&gt;value&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;Stephanie&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token attr-name&quot;&gt;description&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;Your first name please&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;wjuym-vnb&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;form-field&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;To remove those from continuing to be part of the custom element, with WebC we can make them “private” when including the component. This is done by prepending each attribute with &lt;code&gt;@&lt;/code&gt;, such as &lt;code&gt;@label&lt;/code&gt;, which turns it into a property (aka prop). In our &lt;code&gt;form-field&lt;/code&gt; example, this means all attributes will be removed from the final render except the &lt;code&gt;class&lt;/code&gt;.&lt;/p&gt;
&lt;div class=&quot;heading-wrapper h3&quot;&gt;
&lt;h3 id=&quot;removing-unnecessary-elements&quot;&gt;Removing unnecessary elements&lt;/h3&gt;
&lt;a class=&quot;tdbc-anchor&quot; href=&quot;https://11ty.rocks/posts/understanding-webc-features-and-concepts/#removing-unnecessary-elements&quot; aria-labelledby=&quot;removing-unnecessary-elements&quot;&gt;&lt;span hidden=&quot;&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;If we consider a secondary component for radios and checkboxes, maybe we want the label to wrap the input. This poses what may seem like a problem in that we need to still render the label value, which we’ve learned is done via &lt;code&gt;@html&lt;/code&gt; and means we need to add an element to attach that too. You might be inclined to use a &lt;code&gt;span&lt;/code&gt; as follows:&lt;/p&gt;
&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;label&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;:for&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;uid&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;input&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;:type&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;type&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;:id&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;uid&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;/&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;span&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;@html&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;label&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;span&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;label&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;A &lt;code&gt;span&lt;/code&gt; is semantically ok, but if you do not &lt;em&gt;need&lt;/em&gt; it for styling purposes, then you can attach the attribute &lt;code&gt;webc:nokeep&lt;/code&gt; which will discard the &lt;code&gt;span&lt;/code&gt; upon render.&lt;/p&gt;
&lt;p&gt;Since you’re discarding the element, you can choose something else even completely made-up as long as you haven’t assigned it to another WebC component. For example, simply &lt;code&gt;x&lt;/code&gt;:&lt;/p&gt;
&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;x&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;@html&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;label&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;&lt;span class=&quot;token namespace&quot;&gt;webc:&lt;/span&gt;nokeep&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;x&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;div class=&quot;heading-wrapper h2&quot;&gt;
&lt;h2 id=&quot;advanced-patterns-with-slots&quot;&gt;Advanced patterns with slots&lt;/h2&gt;
&lt;a class=&quot;tdbc-anchor&quot; href=&quot;https://11ty.rocks/posts/understanding-webc-features-and-concepts/#advanced-patterns-with-slots&quot; aria-labelledby=&quot;advanced-patterns-with-slots&quot;&gt;&lt;span hidden=&quot;&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;Attributes and props fit a lot of use cases, but to enable a bit more flexibility in structuring your components you can use slots. Evan already covered &lt;a href=&quot;https://11ty.rocks/posts/introduction-webc/#slots&quot;&gt;using slots for a static HTML &lt;code&gt;card&lt;/code&gt; component&lt;/a&gt; in the intro article, so we’ll look at two other patterns.&lt;/p&gt;
&lt;p&gt;First, we can break up large components and use slots to fit them together thanks to WebC rendering.&lt;/p&gt;
&lt;p&gt;If we create a &lt;code&gt;form-submit&lt;/code&gt; component separate from the &lt;code&gt;form-field&lt;/code&gt; and &lt;code&gt;form-input&lt;/code&gt; then we can use slots to help structure the component. We’ll have a single slot called &lt;code&gt;fields&lt;/code&gt; which can be populated per instance. This allows freeform flexibility for how the form fields are created and ordered.&lt;/p&gt;
&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;&amp;lt;!-- form-submit.webc --&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;form&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;slot&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;fields&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;slot&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;button&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;type&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;submit&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;Submit&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;button&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;form&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token comment&quot;&gt;&amp;lt;!-- turn it into a full web component to handle validation&lt;br /&gt;and submission logic --&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Then, we assign to fields to the slot by referencing the name of &lt;code&gt;fields&lt;/code&gt; in the &lt;code&gt;slot&lt;/code&gt; attribute. Also note the use of &lt;code&gt;webc:nokeep&lt;/code&gt; which is optional but may be preferred.&lt;/p&gt;
&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;&amp;lt;!-- page.webc --&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;form-submit&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;div&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;slot&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;fields&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;&lt;span class=&quot;token namespace&quot;&gt;webc:&lt;/span&gt;nokeep&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;form-field&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;label&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;Name&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;type&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;text&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;value&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;Stephanie&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;description&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;Your first name please&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;form-field&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;fieldset&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;form-input&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;label&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;Blue&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;type&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;radio&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;fav-color&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;form-input&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;form-input&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;label&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;Red&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;type&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;radio&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;fav-color&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;form-input&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;form-input&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;label&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;Green&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;type&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;radio&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;fav-color&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;form-input&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;fieldset&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;div&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;form-submit&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The result is that WebC will statically render the individual fields within the form.&lt;/p&gt;
&lt;p&gt;If your form requires JS, like a POST request to submit a newsletter form, then you may want to introduce the &lt;code&gt;template&lt;/code&gt; pattern. Let’s setup up a form that also uses slots to represent optional fields. A neat feature of slots is if they are not given content, they are removed from rendering.&lt;/p&gt;
&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;&amp;lt;!-- subscription-form.webc --&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;template&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;form&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;slot&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;name&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;slot&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;slot&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;email&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;slot&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;slot&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;business&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;slot&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;form&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;template&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;script&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token script&quot;&gt;&lt;span class=&quot;token language-javascript&quot;&gt;&lt;br /&gt;  &lt;span class=&quot;token keyword&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;SubscriptionForm&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;extends&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;HTMLElement&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token function&quot;&gt;connectedCallback&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; template &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;querySelector&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;template&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;      &lt;span class=&quot;token comment&quot;&gt;// Swap out the template with its contents so they become visible&lt;/span&gt;&lt;br /&gt;      template&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;replaceWith&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;template&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;content&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;  window&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;customElements&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;define&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;subscription-form&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; SubscriptionForm&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;script&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;And then to use it, we’ll reference our &lt;code&gt;&amp;lt;form-field&amp;gt;&lt;/code&gt; component and directly assign those to a slot:&lt;/p&gt;
&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;&amp;lt;!-- page.webc --&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;subscription-form&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;form-field&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;slot&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;name&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;@label&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;Name&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;@type&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;text&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;form-field&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;form-field&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;slot&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;email&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;@label&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;Email&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;@type&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;email&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;form-field&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;subscription-form&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;blockquote&gt;
&lt;p&gt;Note that we can’t make &lt;code&gt;slot&lt;/code&gt; a private prop with &lt;code&gt;@&lt;/code&gt; or it will fail to be assigned, so you will still see this attribute on the final render.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;But - oh no! The slots haven’t been passed along correctly and aren’t rendering in the browser:&lt;/p&gt;
&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;&amp;lt;!-- rendered source --&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;subscription-form&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;template&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;form&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;slot&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;name&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;slot&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;slot&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;email&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;slot&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;slot&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;business&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;slot&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;form&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;template&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;subscription-form&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;When you try to use slots within &lt;code&gt;template&lt;/code&gt;, and your intent is to allow WebC to process those for rendering, you’ll need a couple extra attributes on &lt;code&gt;template&lt;/code&gt;. Otherwise, WebC will default to keeping the slots exposed for client-side things within your web component.&lt;/p&gt;
&lt;p&gt;The adjustments are to add both &lt;code&gt;webc:keep&lt;/code&gt; and &lt;code&gt;webc:type=&amp;quot;11ty&amp;quot;&lt;/code&gt; to the &lt;code&gt;template&lt;/code&gt;. Use of &lt;code&gt;webc:type=&amp;quot;11ty&amp;quot;&lt;/code&gt; indicates that WebC should process the slots. And typically that would also wipe away the &lt;code&gt;template&lt;/code&gt; so we need &lt;code&gt;webc:keep&lt;/code&gt; added to keep it for the web component registration script.&lt;/p&gt;
&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;&amp;lt;!-- adjustment in subscription-form.webc--&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;template&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;&lt;span class=&quot;token namespace&quot;&gt;webc:&lt;/span&gt;keep&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;&lt;span class=&quot;token namespace&quot;&gt;webc:&lt;/span&gt;type&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;11ty&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;template&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Now the &lt;code&gt;subscription-form&lt;/code&gt; not only renders but there is no error from not including the “business” slot, and no empty placeholder for it either:&lt;/p&gt;
&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;&amp;lt;!-- updated rendered source --&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;subscription-form&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;template&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;form&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;form-field&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;slot&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;name&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;wjuym-vnb&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt; ... &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;form-field&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;form-field&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;slot&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;email&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;wjuym-vnb&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt; ... &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;form-field&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;form&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;template&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;subscription-form&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The composable nature of slots and how they can be processed at build-time rather than another piece for the client-side to handle makes this a strong contender against other Eleventy component patterns!&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;Have you created a WebC resource? Be sure to add it to the &lt;a href=&quot;https://11ty.rocks/community/&quot;&gt;community resources&lt;/a&gt; or the &lt;a href=&quot;https://github.com/5t3ph/11ty-rocks/blob/main/join-webring.md&quot;&gt;11ty Rocks webring&lt;/a&gt;!&lt;/p&gt;
</content>
	</entry>
	
	
	<entry>
		<title>Introduction to WebC</title>
		<link href="https://11ty.rocks/posts/introduction-webc/"/>
		<updated>2022-10-15T00:00:00Z</updated>
		<id>https://11ty.rocks/posts/introduction-webc/</id>
		<content type="html">&lt;p&gt;&lt;a href=&quot;https://github.com/11ty/webc&quot;&gt;WebC&lt;/a&gt; is a new tool by &lt;a href=&quot;https://www.zachleat.com/&quot;&gt;Zach Leatherman&lt;/a&gt; (creator of Eleventy) for serializing custom elements at build time. It aggregates component-level CSS and JavaScript, allowing developers to keep their styles and scripts together with the markup as single file components, the way you may be used to if you work with JavaScript frameworks such as &lt;a href=&quot;https://svelte.dev/&quot;&gt;Svelte&lt;/a&gt; or &lt;a href=&quot;https://vuejs.org/&quot;&gt;Vue&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;All without having to ship a single line of JavaScript to the client — unless you want it to.&lt;/p&gt;
&lt;div class=&quot;heading-wrapper h2&quot;&gt;
&lt;h2 id=&quot;webc-in-a-nutshell&quot;&gt;WebC in a nutshell&lt;/h2&gt;
&lt;a class=&quot;tdbc-anchor&quot; href=&quot;https://11ty.rocks/posts/introduction-webc/#webc-in-a-nutshell&quot; aria-labelledby=&quot;webc-in-a-nutshell&quot;&gt;&lt;span hidden=&quot;&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;First and foremost: WebC components are just HTML. If you already know how to write HTML, CSS, and JavaScript, you are ready to start working with WebC.&lt;/p&gt;
&lt;p&gt;Let’s define our first component: a footer for our site. We’ll create a file called &lt;code&gt;site-footer.webc&lt;/code&gt; and put in it the following HTML:&lt;/p&gt;
&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;&amp;lt;!-- site-footer.webc --&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;footer&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;p&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token entity named-entity&quot; title=&quot;&amp;copy;&quot;&gt;&amp;amp;copy;&lt;/span&gt; 2022 Yours Truly&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;p&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;footer&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Now we can use a &lt;code&gt;&amp;lt;site-footer&amp;gt;&amp;lt;/site-footer&amp;gt;&lt;/code&gt; custom element and WebC will replace that element with the markup from &lt;code&gt;site-footer.webc&lt;/code&gt;.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;For the purposes of this article, we won’t concern ourselves with &lt;a href=&quot;https://github.com/11ty/webc#html-imports-kidding-kinda&quot;&gt;importing components in WebC&lt;/a&gt;. When you set up the WebC plugin for Eleventy, you can &lt;a href=&quot;https://www.11ty.dev/docs/languages/webc/#global-no-import-components&quot;&gt;configure a directory for global components&lt;/a&gt; so that they’re always available.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;So if we have a file — &lt;code&gt;page.webc&lt;/code&gt; — with all of our HTML boilerplate, we insert our footer into that file using this custom element.&lt;/p&gt;
&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;&amp;lt;!-- page.webc --&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token doctype&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;!&lt;/span&gt;&lt;span class=&quot;token doctype-tag&quot;&gt;doctype&lt;/span&gt; &lt;span class=&quot;token name&quot;&gt;html&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;html&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;head&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;head&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;body&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;site-footer&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;site-footer&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;body&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;html&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;When we process &lt;code&gt;page.webc&lt;/code&gt;, the resulting HTML will look like this (give or take some whitespace):&lt;/p&gt;
&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;&amp;lt;!-- page/index.html --&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token doctype&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;!&lt;/span&gt;&lt;span class=&quot;token doctype-tag&quot;&gt;doctype&lt;/span&gt; &lt;span class=&quot;token name&quot;&gt;html&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;html&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;head&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;head&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;body&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token comment&quot;&gt;&amp;lt;!-- &amp;lt;site-footer&gt; --&gt;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;footer&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;p&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token entity named-entity&quot; title=&quot;&amp;copy;&quot;&gt;&amp;amp;copy;&lt;/span&gt; 2022 Yours Truly&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;p&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;footer&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token comment&quot;&gt;&amp;lt;!-- &amp;lt;/site-footer&gt; --&gt;&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;body&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;html&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;div class=&quot;heading-wrapper h2&quot;&gt;
&lt;h2 id=&quot;single-file-components&quot;&gt;Single file components&lt;/h2&gt;
&lt;a class=&quot;tdbc-anchor&quot; href=&quot;https://11ty.rocks/posts/introduction-webc/#single-file-components&quot; aria-labelledby=&quot;single-file-components&quot;&gt;&lt;span hidden=&quot;&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;At this point, it may still be unclear what advantages we get by using WebC. After all, many of the template languages that Eleventy already supports allow you to import partials from other files like this. But what WebC can add to even this basic use case is the single file component (SFC) authoring experience.&lt;/p&gt;
&lt;p&gt;An SFC is a file that contains HTML, CSS, and JavaScript that defines the component. They often follow this structure:&lt;/p&gt;
&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;script&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token script&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;script&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token comment&quot;&gt;&amp;lt;!-- Markup here --&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;style&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token style&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;style&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Going back to our &lt;code&gt;site-footer.webc&lt;/code&gt;, we can colocate the styles for our footer with the markup.&lt;/p&gt;
&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;&amp;lt;!-- site-footer.webc --&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;footer&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;p&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token entity named-entity&quot; title=&quot;&amp;copy;&quot;&gt;&amp;amp;copy;&lt;/span&gt; 2022 Yours Truly&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;p&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;footer&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;style&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token style&quot;&gt;&lt;span class=&quot;token language-css&quot;&gt;&lt;br /&gt;  &lt;span class=&quot;token selector&quot;&gt;footer&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token property&quot;&gt;padding-block&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 3rem&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token property&quot;&gt;padding-inline&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 1rem&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;  &lt;span class=&quot;token selector&quot;&gt;footer &gt; p&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token property&quot;&gt;font-family&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; fantasy&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;style&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;One advantage to writing your components this way instead of having your markup and styles in separate files is that when you’re making changes, it’s easier to remember to update the styles. If we introduce a &lt;code&gt;&amp;lt;div&amp;gt;&lt;/code&gt; to our footer to wrap the paragraph at some maximum width, our (admittedly contrived) &lt;code&gt;footer &amp;gt; p&lt;/code&gt; selector will no longer apply to the copyright notice in the footer. Being able to see the markup and styles right next to each other helps us keep them synchronized.&lt;/p&gt;
&lt;div class=&quot;heading-wrapper h3&quot;&gt;
&lt;h3 id=&quot;custom-elements-in-webc-output&quot;&gt;Custom elements in WebC output&lt;/h3&gt;
&lt;a class=&quot;tdbc-anchor&quot; href=&quot;https://11ty.rocks/posts/introduction-webc/#custom-elements-in-webc-output&quot; aria-labelledby=&quot;custom-elements-in-webc-output&quot;&gt;&lt;span hidden=&quot;&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;When you have a component that is just HTML, WebC will replace the custom element with that HTML. But as soon as you introduce either a &lt;code&gt;&amp;lt;script&amp;gt;&lt;/code&gt; tag or a &lt;code&gt;&amp;lt;style&amp;gt;&lt;/code&gt; tag to the component, WebC will, by default, leave the custom element in place in case you are using it in either your scripts or your styles. You can tell WebC to remove the custom element by adding &lt;a href=&quot;https://www.11ty.dev/docs/languages/webc/#webcnokeep&quot;&gt;webc:nokeep&lt;/a&gt; to the custom element.&lt;/p&gt;
&lt;div class=&quot;heading-wrapper h3&quot;&gt;
&lt;h3 id=&quot;asset-bundling&quot;&gt;Asset bundling&lt;/h3&gt;
&lt;a class=&quot;tdbc-anchor&quot; href=&quot;https://11ty.rocks/posts/introduction-webc/#asset-bundling&quot; aria-labelledby=&quot;asset-bundling&quot;&gt;&lt;span hidden=&quot;&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;When WebC processes your components and it finds &lt;code&gt;&amp;lt;style&amp;gt;&lt;/code&gt; or &lt;code&gt;&amp;lt;script&amp;gt;&lt;/code&gt; tags in them, it can extract those assets into bundles for you to use later. This allows you to collect your assets into a single &lt;code&gt;&amp;lt;style&amp;gt;&lt;/code&gt; tag inside the page &lt;code&gt;&amp;lt;head&amp;gt;&lt;/code&gt;, rather than leaving &lt;code&gt;&amp;lt;style&amp;gt;&lt;/code&gt; tags strewn about your HTML. See the Eleventy docs on WebC for information on &lt;a href=&quot;https://www.11ty.dev/docs/languages/webc/#css-and-js-(bundler-mode)&quot;&gt;how to include bundled assets in your final markup&lt;/a&gt;.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;By default, when using the Eleventy plugin for WebC, asset bundling is turned on. If you are &lt;a href=&quot;https://github.com/11ty/webc/&quot;&gt;using WebC directly&lt;/a&gt;, however, bundling is off by default.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;div class=&quot;heading-wrapper h3&quot;&gt;
&lt;h3 id=&quot;scoped-styles&quot;&gt;Scoped styles&lt;/h3&gt;
&lt;a class=&quot;tdbc-anchor&quot; href=&quot;https://11ty.rocks/posts/introduction-webc/#scoped-styles&quot; aria-labelledby=&quot;scoped-styles&quot;&gt;&lt;span hidden=&quot;&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;One concern you may have about this single file component approach is that the styles from one component may leak into another. In our &lt;code&gt;site-footer.webc&lt;/code&gt; component, for example, we have styles that apply to all &lt;code&gt;&amp;lt;footer&amp;gt;&lt;/code&gt; elements; if we use a &lt;code&gt;&amp;lt;footer&amp;gt;&lt;/code&gt; in any other part of our site, it will pick up that padding.&lt;/p&gt;
&lt;p&gt;A common solution to this problem with SFCs is to scope the styles using some computer-generated unique class name. WebC supports scoped styles via the &lt;code&gt;webc:scoped&lt;/code&gt; attribute, which you add to your &lt;code&gt;&amp;lt;style&amp;gt;&lt;/code&gt; tag.&lt;/p&gt;
&lt;p&gt;To scope our footer styles to just the &lt;code&gt;&amp;lt;site-footer&amp;gt;&lt;/code&gt; element, we can update our component definition like this:&lt;/p&gt;
&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;style&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;&lt;span class=&quot;token namespace&quot;&gt;webc:&lt;/span&gt;scoped&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token style&quot;&gt;&lt;span class=&quot;token language-css&quot;&gt;&lt;br /&gt;  &lt;span class=&quot;token selector&quot;&gt;:host&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token property&quot;&gt;padding-block&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 3rem&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token property&quot;&gt;padding-inline&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 1rem&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;  &lt;span class=&quot;token selector&quot;&gt;:host footer &gt; p&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token property&quot;&gt;font-family&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; fantasy&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;style&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Did you know&lt;/strong&gt;: &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/CSS/:host&quot;&gt;&lt;code&gt;:host&lt;/code&gt; is a native CSS feature&lt;/a&gt; that selects the shadow DOM root host of web components. WebC is using &lt;code&gt;:host&lt;/code&gt; as a hook to insert the generated class name for scoped styles. If you use &lt;code&gt;:host&lt;/code&gt; outside of scoped styles, it won’t be replaced, but it will still be valid CSS.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Here we’ve added the &lt;code&gt;webc:scoped&lt;/code&gt; attribute to our &lt;code&gt;&amp;lt;style&amp;gt;&lt;/code&gt; element, and introduced the &lt;code&gt;:host&lt;/code&gt; pseudo-class to our selectors. WebC now knows to generate a unique class for &lt;code&gt;&amp;lt;site-footer&amp;gt;&lt;/code&gt;, which will replace &lt;code&gt;:host&lt;/code&gt; with a class selector matching this generated class name. The generated class will be shared across &lt;code&gt;&amp;lt;site-footer&amp;gt;&lt;/code&gt; instances. So our HTML will end up looking something like:&lt;/p&gt;
&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;site-footer&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;blarglargl&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;footer&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;p&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token entity named-entity&quot; title=&quot;&amp;copy;&quot;&gt;&amp;amp;copy;&lt;/span&gt; 2022 Yours Truly&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;p&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;footer&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;site-footer&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;And the styles will be:&lt;/p&gt;
&lt;pre class=&quot;language-css&quot;&gt;&lt;code class=&quot;language-css&quot;&gt;&lt;span class=&quot;token selector&quot;&gt;.blarglargl&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token property&quot;&gt;padding-block&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 3rem&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token property&quot;&gt;padding-inline&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 1rem&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token selector&quot;&gt;.blarglargl footer &gt; p&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token property&quot;&gt;font-family&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; fantasy&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;div class=&quot;heading-wrapper h2&quot;&gt;
&lt;h2 id=&quot;slots&quot;&gt;Slots&lt;/h2&gt;
&lt;a class=&quot;tdbc-anchor&quot; href=&quot;https://11ty.rocks/posts/introduction-webc/#slots&quot; aria-labelledby=&quot;slots&quot;&gt;&lt;span hidden=&quot;&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;WebC supports the use of &lt;code&gt;&amp;lt;slot&amp;gt;&amp;lt;/slot&amp;gt;&lt;/code&gt; for inserting markup inside your components when they’re used. And as with templates and slots for web components, you can define multiple named slots; something that none of the template languages Eleventy currently supports can do.&lt;/p&gt;
&lt;p&gt;To illustrate how this can be useful, let’s create a card component that needs to have a title, some media, and a brief description. We won’t concern ourselves with the CSS for this component, but let’s assume we’re doing some fancy things that require us to place the aformentione title, media, and description inside some wrappers. We can define &lt;code&gt;a-card.webc&lt;/code&gt; like this:&lt;/p&gt;
&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;&amp;lt;!-- a-card.webc --&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;article&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;card&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;div&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;card__container&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;div&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;card__media&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;token comment&quot;&gt;&amp;lt;!-- Media will be inserted here --&gt;&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;slot&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;media&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;slot&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;div&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;strong&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;card__title&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;token comment&quot;&gt;&amp;lt;!-- Title will be inserted here --&gt;&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;slot&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;title&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;slot&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;strong&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;div&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;card__body&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;token comment&quot;&gt;&amp;lt;!-- Description will be inserted here --&gt;&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;slot&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;body&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;slot&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;div&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;div&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;article&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;When we use this card in our markup we place the title, media, and description as children of our custom element and give them the appropriate &lt;code&gt;slot&lt;/code&gt; attribute.&lt;/p&gt;
&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;a-card&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;a&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;href&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;#&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;slot&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;title&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;The Hypnotoad&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;a&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;img&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;src&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;hypnotoad.gif&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;slot&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;media&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;p&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;slot&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;body&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;All glory to the Hypnotoad~&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;p&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;a-card&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Notice that we can order our elements however we want. We don’t have to place the media above the title when we define the card, because they will get pulled into the appropriate order when they&#39;re slotted into the component.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Did you know:&lt;/strong&gt; Slots are also a native part of the web platform. You can use them along with &lt;code&gt;&amp;lt;template&amp;gt;&lt;/code&gt; to achieve the same effect we get with WebC but in the browser — though, unlike with WebC, using templates and slots in the browser requires JavaScript. To learn more about templates and slots, check out Mozilla Developer Network’s article on &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/Web_Components/Using_templates_and_slots&quot;&gt;using templates and slots&lt;/a&gt;.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;div class=&quot;heading-wrapper h2&quot;&gt;
&lt;h2 id=&quot;webc-for-web-components&quot;&gt;WebC for web components&lt;/h2&gt;
&lt;a class=&quot;tdbc-anchor&quot; href=&quot;https://11ty.rocks/posts/introduction-webc/#webc-for-web-components&quot; aria-labelledby=&quot;webc-for-web-components&quot;&gt;&lt;span hidden=&quot;&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;Up to this point, we’ve been looking at how we can use WebC in Eleventy for the same kinds of tasks for which we’ve previously used one of Eleventy’s template languages. But the WebC README declares (emphasis mine):&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;WebC is for Single File &lt;em&gt;Web Components&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;So what does all of this have to do with web components? Well, we can use WebC single file components as a convenient way to write and include web components — with templates and shadow DOM — in our sites. As a simple example, suppose we want to implement a theme toggle on our site that allows visitors to choose a light or dark theme, or to use whichever matches their operating system. We’re implementing this as a web component because it relies on JavaScript to switch the theme. Without JavaScript, the buttons wouldn’t do anything, so we don’t want them to be visible unless JavaScript is available.&lt;/p&gt;
&lt;p&gt;We’ll call our component &lt;code&gt;theme-select.webc&lt;/code&gt;:&lt;/p&gt;
&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;&amp;lt;!-- theme-select.webc --&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;script&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token script&quot;&gt;&lt;span class=&quot;token language-javascript&quot;&gt;&lt;br /&gt;  &lt;span class=&quot;token keyword&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;ThemeSelect&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;extends&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;HTMLElement&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token function&quot;&gt;connectedCallback&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; template &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;querySelector&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;template&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;      &lt;span class=&quot;token comment&quot;&gt;// Swap out the template with its contents so they become visible&lt;/span&gt;&lt;br /&gt;      template&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;replaceWith&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;template&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;content&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;  customElements&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;define&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;theme-select&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; ThemeSelect&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;script&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;template&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;button&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;Light&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;button&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;button&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;System&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;button&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;button&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;Dark&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;button&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;template&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;style&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token style&quot;&gt;&lt;span class=&quot;token language-css&quot;&gt;&lt;br /&gt;  &lt;span class=&quot;token selector&quot;&gt;theme-select&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token comment&quot;&gt;/* ... */&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;style&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;blockquote&gt;
&lt;p&gt;The &lt;code&gt;connectedCallback&lt;/code&gt; method is one of the lifecycle callbacks for custom elements. It runs whenever the element is connected to a document by appending it to another element in the document. You can learn more about these lifecycle callbacks and creating custom elements in the Mozilla Developer Network documents on &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/Web_Components/Using_custom_elements&quot;&gt;using custom elements&lt;/a&gt;.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Now we can put &lt;code&gt;&amp;lt;theme-select&amp;gt;&amp;lt;/theme-select&amp;gt;&lt;/code&gt; somewhere in our site, and we’ll end up with the following in our rendered markup:&lt;/p&gt;
&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;theme-select&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;template&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;button&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;Light&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;button&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;button&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;System&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;button&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;button&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;Dark&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;button&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;template&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;theme-select&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;On top of that, WebC will bundle up the styles and JavaScript needed for this component, which we can place in the &lt;code&gt;&amp;lt;head&amp;gt;&lt;/code&gt; tag, or at the end of the &lt;code&gt;&amp;lt;body&amp;gt;&lt;/code&gt; tag, or wherever we need them. Since the buttons are inside a &lt;code&gt;&amp;lt;template&amp;gt;&lt;/code&gt; tag, they will remain invisible on the page until the custom element is registered by our JavaScript and the web component becomes defined, at which point the &lt;code&gt;connectedCallback&lt;/code&gt; runs, and extracts the buttons from inside the &lt;code&gt;&amp;lt;template&amp;gt;&lt;/code&gt; so that they become visible and usable.&lt;/p&gt;
&lt;p&gt;Of course, you could also set up a Shadow DOM inside of your web component, if you wanted to, but you don’t have to.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;There are plans to allow you to &lt;a href=&quot;https://github.com/11ty/webc/issues/36&quot;&gt;aggregate arbitrary HTML&lt;/a&gt; from your WebC components the way that styles and scripts are aggregated. This would mean that you could include a &lt;code&gt;&amp;lt;template&amp;gt;&lt;/code&gt; as part of your component and guarantee that in the final markup there was only one copy of the template regardless of how many instances of the component you placed on the page.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;div class=&quot;heading-wrapper h2&quot;&gt;
&lt;h2 id=&quot;learn-more-about-webc&quot;&gt;Learn more about WebC&lt;/h2&gt;
&lt;a class=&quot;tdbc-anchor&quot; href=&quot;https://11ty.rocks/posts/introduction-webc/#learn-more-about-webc&quot; aria-labelledby=&quot;learn-more-about-webc&quot;&gt;&lt;span hidden=&quot;&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;There’s a lot more to WebC than what we’ve covered so far. If you want to learn more, the Eleventy docs have a &lt;a href=&quot;https://www.11ty.dev/docs/languages/webc/&quot;&gt;section on WebC&lt;/a&gt; which covers how to set up WebC with Eleventy as well as a lot of what you’ll need to know to use WebC in general, and with Eleventy specifically. Additionally, the &lt;a href=&quot;https://github.com/11ty/webc&quot;&gt;WebC README in the GitHub repo&lt;/a&gt; contains documentation for WebC. And, finally, I’ve created a small website built with Eleventy and WebC at &lt;a href=&quot;https://11ty.webc.fun/&quot;&gt;11ty.webc.fun&lt;/a&gt; which contains little recipes for working with WebC, such as &lt;a href=&quot;https://11ty.webc.fun/recipes/webc-layouts-with-layout-chaining/&quot;&gt;how to use WebC layouts in Eleventy&lt;/a&gt;. You can check out the recipes (there’s an RSS feed, too), or dig into the &lt;a href=&quot;https://github.com/darthmall/11ty.webc.fun/&quot;&gt;code on GitHub&lt;/a&gt; to see how I used WebC.&lt;/p&gt;
&lt;p&gt;And if you have questions, the &lt;a href=&quot;https://www.11ty.dev/blog/discord/&quot;&gt;Eleventy Discord&lt;/a&gt; is a great place to bring them. We have a WebC tag in the support forum.&lt;/p&gt;
</content>
	</entry>
	
	
	<entry>
		<title>Ignore Eleventy Files With Environment Variables</title>
		<link href="https://11ty.rocks/posts/ignore-11ty-files-with-environment-variables/"/>
		<updated>2022-03-25T00:00:00Z</updated>
		<id>https://11ty.rocks/posts/ignore-11ty-files-with-environment-variables/</id>
		<content type="html">&lt;p&gt;In this example, we exclude the &amp;quot;__docs&amp;quot; directory from a production build. Environment variables are injected as part of either the &amp;quot;start&amp;quot; or &amp;quot;build&amp;quot; command, with the cross-env package used to ensure compatibility with Mac or PC.&lt;/p&gt;
&lt;p&gt;Watch how this works, or continue reading and review the code snippets.&lt;/p&gt;
&lt;div class=&quot;tdbc-video&quot;&gt;&lt;iframe src=&quot;https://www.youtube.com/embed/JqtdsuPleSk&quot; frameborder=&quot;0&quot; allow=&quot;accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture&quot; allowfullscreen=&quot;&quot;&gt;&lt;/iframe&gt;&lt;/div&gt;
&lt;blockquote&gt;
&lt;p&gt;Check out &lt;a href=&quot;https://github.com/5t3ph/11ty-design-system-example&quot;&gt;the design system project on GitHub&lt;/a&gt;.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;div class=&quot;heading-wrapper h2&quot;&gt;
&lt;h2 id=&quot;step-one-include-environment-variables&quot;&gt;Step one: Include environment variables&lt;/h2&gt;
&lt;a class=&quot;tdbc-anchor&quot; href=&quot;https://11ty.rocks/posts/ignore-11ty-files-with-environment-variables/#step-one-include-environment-variables&quot; aria-labelledby=&quot;step-one-include-environment-variables&quot;&gt;&lt;span hidden=&quot;&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;When developing an Eleventy project, it&#39;s common to include a couple of commands in &lt;code&gt;package.json&lt;/code&gt; to run Eleventy as a local server and then to do a production-ready build for a web host.&lt;/p&gt;
&lt;p&gt;Here&#39;s an example of a very basic set of scripts:&lt;/p&gt;
&lt;pre class=&quot;language-json&quot;&gt;&lt;code class=&quot;language-json&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;// located in package.json&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token property&quot;&gt;&quot;scripts&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token property&quot;&gt;&quot;start&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;npx @11ty/eleventy --serve&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token property&quot;&gt;&quot;build&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;npx @11ty/eleventy&quot;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;I recommend running &lt;code&gt;npm install cross-env&lt;/code&gt; so that including environment variables at this state works for both PC and Mac users.&lt;/p&gt;
&lt;p&gt;We&#39;ll update both of our scripts to inject an environment variable called &lt;code&gt;ELEVENTY_ENV&lt;/code&gt; with the value of &amp;quot;dev&amp;quot; for the &lt;code&gt;start&lt;/code&gt; command, and the value of &amp;quot;prod&amp;quot; for the &lt;code&gt;build&lt;/code&gt; command.&lt;/p&gt;
&lt;pre class=&quot;language-json&quot;&gt;&lt;code class=&quot;language-json&quot;&gt;&lt;span class=&quot;token property&quot;&gt;&quot;scripts&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token property&quot;&gt;&quot;start&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;cross-env ELEVENTY_ENV=dev npx @11ty/eleventy --serve&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token property&quot;&gt;&quot;build&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;cross-env ELEVENTY_ENV=prod npx @11ty/eleventy&quot;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;div class=&quot;heading-wrapper h2&quot;&gt;
&lt;h2 id=&quot;step-two-ignore-files-from-within-the-eleventy-config&quot;&gt;Step Two: Ignore files from within the Eleventy config&lt;/h2&gt;
&lt;a class=&quot;tdbc-anchor&quot; href=&quot;https://11ty.rocks/posts/ignore-11ty-files-with-environment-variables/#step-two-ignore-files-from-within-the-eleventy-config&quot; aria-labelledby=&quot;step-two-ignore-files-from-within-the-eleventy-config&quot;&gt;&lt;span hidden=&quot;&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;Within &lt;code&gt;.eleventy.js&lt;/code&gt; - &lt;a href=&quot;https://www.11ty.dev/docs/config/&quot;&gt;the Eleventy config file&lt;/a&gt; - we&#39;ll add just a few lines.&lt;/p&gt;
&lt;p&gt;An &lt;code&gt;if&lt;/code&gt; statement will check for whether our &amp;quot;prod&amp;quot; environment variable is available, and if so, we&#39;ll use &lt;a href=&quot;https://www.11ty.dev/docs/ignores/&quot;&gt;Eleventy&#39;s &lt;code&gt;ignore&lt;/code&gt; feature&lt;/a&gt; to exclude our &lt;code&gt;__docs&lt;/code&gt; directory. This effectively prevents those files from building.&lt;/p&gt;
&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;process&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;env&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token constant&quot;&gt;ELEVENTY_ENV&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;===&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;prod&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;  eleventyConfig&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;ignores&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;add&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;./src/__docs/&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Note that in this example project, &lt;code&gt;src&lt;/code&gt; is what the input directory has been customized to, and &lt;code&gt;__docs&lt;/code&gt; is just an example of a directory you may want to exclude.&lt;/p&gt;
&lt;p&gt;If you experience a build error, you may need to run &lt;code&gt;npm install dotenv&lt;/code&gt; and then &lt;code&gt;require&lt;/code&gt; it at the top of the config file, like so:&lt;/p&gt;
&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token function&quot;&gt;require&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;dotenv&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;config&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;hr /&gt;
&lt;blockquote&gt;
&lt;p&gt;Here&#39;s &lt;a href=&quot;https://11ty.rocks/tips/env-variables/&quot;&gt;more tips for managing environment variables&lt;/a&gt; in Eleventy.&lt;/p&gt;
&lt;/blockquote&gt;
</content>
	</entry>
	
	
	<entry>
		<title>Creating and Using Eleventy Collections</title>
		<link href="https://11ty.rocks/posts/creating-and-using-11ty-collections/"/>
		<updated>2021-11-11T00:00:00Z</updated>
		<id>https://11ty.rocks/posts/creating-and-using-11ty-collections/</id>
		<content type="html">&lt;div class=&quot;heading-wrapper h2&quot;&gt;
&lt;h2 id=&quot;what-are-collections&quot;&gt;What Are Collections?&lt;/h2&gt;
&lt;a class=&quot;tdbc-anchor&quot; href=&quot;https://11ty.rocks/posts/creating-and-using-11ty-collections/#what-are-collections&quot; aria-labelledby=&quot;what-are-collections&quot;&gt;&lt;span hidden=&quot;&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;blockquote&gt;
&lt;p&gt;Collections are groups of template* content.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;One template can belong to multiple collections. These collections allow you to sort, filter, and perform other manipulations to customize the display of your template data.&lt;/p&gt;
&lt;p&gt;Learning all the ways to create collections provides you architectural freedom in creating your Eleventy site!&lt;/p&gt;
&lt;p&gt;&lt;small&gt;* In 11ty terms, a &lt;em&gt;template&lt;/em&gt; is any content file to be processed or rendered by 11ty. If you create a new Markdown file, you have created a new Markdown template, etc.&lt;/small&gt;&lt;/p&gt;
&lt;div class=&quot;heading-wrapper h2&quot;&gt;
&lt;h2 id=&quot;creating-collections&quot;&gt;Creating Collections&lt;/h2&gt;
&lt;a class=&quot;tdbc-anchor&quot; href=&quot;https://11ty.rocks/posts/creating-and-using-11ty-collections/#creating-collections&quot; aria-labelledby=&quot;creating-collections&quot;&gt;&lt;span hidden=&quot;&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;Collections are most often created from tags, but can also be groups based on other features like file type or front matter data. They can even be created from local data.&lt;/p&gt;
&lt;div class=&quot;heading-wrapper h3&quot;&gt;
&lt;h3 id=&quot;collections-from-tags&quot;&gt;Collections From &lt;code&gt;tags&lt;/code&gt;&lt;/h3&gt;
&lt;a class=&quot;tdbc-anchor&quot; href=&quot;https://11ty.rocks/posts/creating-and-using-11ty-collections/#collections-from-tags&quot; aria-labelledby=&quot;collections-from-tags&quot;&gt;&lt;span hidden=&quot;&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;The simplest way to create a collection is with tags, and there are four syntaxes available.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Single tag&lt;/strong&gt;:&lt;/p&gt;
&lt;pre class=&quot;language-twig&quot;&gt;&lt;code class=&quot;language-twig&quot;&gt;tags: cat&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;Multi-word tag&lt;/strong&gt;:&lt;/p&gt;
&lt;pre class=&quot;language-twig&quot;&gt;&lt;code class=&quot;language-twig&quot;&gt;tags: cat and dog&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;Multiple tags, single line&lt;/strong&gt;:&lt;/p&gt;
&lt;pre class=&quot;language-twig&quot;&gt;&lt;code class=&quot;language-twig&quot;&gt;tags: [&#39;cat&#39;, &#39;dog&#39;]&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;Multiple tags, multiple lines&lt;/strong&gt;:&lt;/p&gt;
&lt;pre class=&quot;language-twig&quot;&gt;&lt;code class=&quot;language-twig&quot;&gt;tags:&lt;br /&gt;- cat&lt;br /&gt;- dog&lt;/code&gt;&lt;/pre&gt;
&lt;h4&gt;Assigning tags to many templates&lt;/h4&gt;
&lt;p&gt;While the examples shown are intended to be placed in a single template&#39;s front matter, there is an alternate way.&lt;/p&gt;
&lt;p&gt;You may create a &lt;a href=&quot;https://11ty.rocks/tips/data-directory-file&quot;&gt;&lt;em&gt;directory data file&lt;/em&gt;&lt;/a&gt; to assign tags to an entire directory of templates.&lt;/p&gt;
&lt;p&gt;Given a directory called &lt;code&gt;posts&lt;/code&gt;, create the file &lt;code&gt;posts.json&lt;/code&gt; (the name must match the directory name) and add the following to assign your tags.&lt;/p&gt;
&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;// posts/posts.json&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token string-property property&quot;&gt;&quot;tags&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;posts&quot;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;div class=&quot;heading-wrapper h2&quot;&gt;
&lt;h2 id=&quot;display-collection-data&quot;&gt;Display Collection Data&lt;/h2&gt;
&lt;a class=&quot;tdbc-anchor&quot; href=&quot;https://11ty.rocks/posts/creating-and-using-11ty-collections/#display-collection-data&quot; aria-labelledby=&quot;display-collection-data&quot;&gt;&lt;span hidden=&quot;&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;Once you have several templates assigned to a collection - for example, blog posts - you may want to display some of the collection data.&lt;/p&gt;
&lt;p&gt;This example works for both Nunjucks or Liquid templates and will output the name of each item in the &lt;code&gt;posts&lt;/code&gt; collection:&lt;/p&gt;
&lt;pre class=&quot;language-twig&quot;&gt;&lt;code class=&quot;language-twig&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;ul&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token twig language-twig&quot;&gt;&lt;span class=&quot;token delimiter punctuation&quot;&gt;{%&lt;/span&gt; &lt;span class=&quot;token tag-name keyword&quot;&gt;for&lt;/span&gt; post &lt;span class=&quot;token operator&quot;&gt;in&lt;/span&gt; collections&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;posts &lt;span class=&quot;token delimiter punctuation&quot;&gt;%}&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;li&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token twig language-twig&quot;&gt;&lt;span class=&quot;token delimiter punctuation&quot;&gt;{{&lt;/span&gt; post&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;data&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;title &lt;span class=&quot;token delimiter punctuation&quot;&gt;}}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;li&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token twig language-twig&quot;&gt;&lt;span class=&quot;token delimiter punctuation&quot;&gt;{%&lt;/span&gt; &lt;span class=&quot;token tag-name keyword&quot;&gt;endfor&lt;/span&gt; &lt;span class=&quot;token delimiter punctuation&quot;&gt;%}&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;ul&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Other data available to display from a collection includes the following, as described on the &lt;a href=&quot;https://www.11ty.dev/docs/collections/#collection-item-data-structure&quot;&gt;11ty Docs page for Collections&lt;/a&gt;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;inputPath&lt;/code&gt;: the full path to the source input file (including the path to the input directory)&lt;/li&gt;
&lt;li&gt;&lt;code&gt;fileSlug&lt;/code&gt;: mapped from the input file name&lt;/li&gt;
&lt;li&gt;&lt;code&gt;outputPath&lt;/code&gt;: the full path to the output file to be written for this content&lt;/li&gt;
&lt;li&gt;&lt;code&gt;url&lt;/code&gt;: url used to link to this piece of content.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;date&lt;/code&gt;: the resolved JS Date Object&lt;/li&gt;
&lt;li&gt;&lt;code&gt;data&lt;/code&gt;: all data for this piece of content&lt;/li&gt;
&lt;li&gt;&lt;code&gt;templateContent&lt;/code&gt;: the rendered content of this template (excludes layout wrappers)&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&quot;heading-wrapper h2&quot;&gt;
&lt;h2 id=&quot;more-ways-to-create-collections-with-addcollection&quot;&gt;More Ways to Create Collections With &lt;code&gt;addCollection&lt;/code&gt;&lt;/h2&gt;
&lt;a class=&quot;tdbc-anchor&quot; href=&quot;https://11ty.rocks/posts/creating-and-using-11ty-collections/#more-ways-to-create-collections-with-addcollection&quot; aria-labelledby=&quot;more-ways-to-create-collections-with-addcollection&quot;&gt;&lt;span hidden=&quot;&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;Let&#39;s look at the options available for creating collections beyond tags. These will be created within our &lt;code&gt;.eleventy.js&lt;/code&gt; config, and use the &lt;code&gt;addCollection&lt;/code&gt; function. This function allows us to create either new or modified collections.&lt;/p&gt;
&lt;div class=&quot;heading-wrapper h3&quot;&gt;
&lt;h3 id=&quot;group-tags-together&quot;&gt;Group Tags Together&lt;/h3&gt;
&lt;a class=&quot;tdbc-anchor&quot; href=&quot;https://11ty.rocks/posts/creating-and-using-11ty-collections/#group-tags-together&quot; aria-labelledby=&quot;group-tags-together&quot;&gt;&lt;span hidden=&quot;&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;To create a collection based on multiple tags, use the additional function of &lt;code&gt;getFilteredByTags&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;eleventyConfig&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;addCollection&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;tagGroup&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;collectionApi&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; collectionApi&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;getFilteredByTags&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;post&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;page&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;You may also perform additional operations once you have this new collections array to further filter or sort the items.&lt;/p&gt;
&lt;div class=&quot;heading-wrapper h3&quot;&gt;
&lt;h3 id=&quot;glob-by-file-type&quot;&gt;Glob By File Type&lt;/h3&gt;
&lt;a class=&quot;tdbc-anchor&quot; href=&quot;https://11ty.rocks/posts/creating-and-using-11ty-collections/#glob-by-file-type&quot; aria-labelledby=&quot;glob-by-file-type&quot;&gt;&lt;span hidden=&quot;&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;You can create a new collection by selecting all templates by file type using &lt;code&gt;getFilteredByGlob()&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;There are a few stipulations for these collections:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;the templates must be located in your &amp;quot;input&amp;quot; directory
&lt;ul&gt;
&lt;li&gt;exceptions are: &lt;code&gt;_includes&lt;/code&gt;, and templates marked as &lt;code&gt;eleventyExcludeFromCollections&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;must be a template type supported by Eleventy (ex. &lt;code&gt;.css&lt;/code&gt; wouldn&#39;t work)&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;eleventyConfig&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;addCollection&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;onlyMarkdown&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;collectionApi&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; collectionApi&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;getFilteredByGlob&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;**/*.md&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;div class=&quot;heading-wrapper h3&quot;&gt;
&lt;h3 id=&quot;collections-from-template-front-matter-data&quot;&gt;Collections From Template Front Matter Data&lt;/h3&gt;
&lt;a class=&quot;tdbc-anchor&quot; href=&quot;https://11ty.rocks/posts/creating-and-using-11ty-collections/#collections-from-template-front-matter-data&quot; aria-labelledby=&quot;collections-from-template-front-matter-data&quot;&gt;&lt;span hidden=&quot;&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;To create a collection based on front matter data, you can use a filter against all template content with &lt;code&gt;getAll()&lt;/code&gt;. Then, you can access any front matter using &lt;code&gt;item.data.customKey&lt;/code&gt; and return the filtered collection by just checking if that key exists. Or, you could extend this to check for a particular value.&lt;/p&gt;
&lt;p&gt;This technique is useful for grouping similar content beyond tags.&lt;/p&gt;
&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;eleventyConfig&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;addCollection&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;specialCollection&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;collection&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; collection&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;getAll&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;filter&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;item&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; item&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;data&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;customKey&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;div class=&quot;heading-wrapper h3&quot;&gt;
&lt;h3 id=&quot;collections-from-local-data&quot;&gt;Collections From Local Data&lt;/h3&gt;
&lt;a class=&quot;tdbc-anchor&quot; href=&quot;https://11ty.rocks/posts/creating-and-using-11ty-collections/#collections-from-local-data&quot; aria-labelledby=&quot;collections-from-local-data&quot;&gt;&lt;span hidden=&quot;&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;For accessing local data - as in, data returned from files within your &lt;code&gt;_data&lt;/code&gt; directory - use the format &lt;code&gt;getAll()[0].data.[customKey]&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;// Create collection from _data/customData.js&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;eleventyConfig&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;addCollection&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;customDataCollection&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;collection&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; allItems &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; collection&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;getAll&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;data&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;customData&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;  &lt;span class=&quot;token comment&quot;&gt;// Filter or use another method to select the items you want&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token comment&quot;&gt;// for the collection&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; allItems&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;filter&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;item&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token comment&quot;&gt;// ...&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This is useful if you&#39;re not using pagination to generate template content. If you are using pagination, you can instead opt to &lt;a href=&quot;https://www.11ty.dev/docs/pagination/#add-all-pagination-pages-to-collections&quot;&gt;assign paginated content to a collection via &lt;code&gt;tags&lt;/code&gt;&lt;/a&gt; within the pagination process.&lt;/p&gt;
&lt;div class=&quot;heading-wrapper h2&quot;&gt;
&lt;h2 id=&quot;the-all-collection&quot;&gt;The &lt;code&gt;all&lt;/code&gt; Collection&lt;/h2&gt;
&lt;a class=&quot;tdbc-anchor&quot; href=&quot;https://11ty.rocks/posts/creating-and-using-11ty-collections/#the-all-collection&quot; aria-labelledby=&quot;the-all-collection&quot;&gt;&lt;span hidden=&quot;&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;The special &lt;code&gt;all&lt;/code&gt; collection is available by default for all template content, with no extra definition required. It is intended to allow you to access all of your site content, which is useful for things like sitemaps or RSS feeds.&lt;/p&gt;
&lt;p&gt;To access all your template data, iterate over &lt;code&gt;collections.all&lt;/code&gt;.&lt;/p&gt;
&lt;div class=&quot;heading-wrapper h2&quot;&gt;
&lt;h2 id=&quot;filtered-vs-unique-collections&quot;&gt;Filtered vs. Unique Collections&lt;/h2&gt;
&lt;a class=&quot;tdbc-anchor&quot; href=&quot;https://11ty.rocks/posts/creating-and-using-11ty-collections/#filtered-vs-unique-collections&quot; aria-labelledby=&quot;filtered-vs-unique-collections&quot;&gt;&lt;span hidden=&quot;&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;Instead of creating unique collections, existing collections can be passed into filters. Here are some considerations to help you choose which method to use.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Use filters&lt;/strong&gt;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;to apply variance per template (ex. randomization)&lt;/li&gt;
&lt;li&gt;to apply a repeatable modification like sorting (vs. the overhead of unique collections)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Use collections&lt;/strong&gt;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;for consistent results per build throughout your site&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&quot;heading-wrapper h2&quot;&gt;
&lt;h2 id=&quot;exclude-content-from-collections&quot;&gt;Exclude Content From Collections&lt;/h2&gt;
&lt;a class=&quot;tdbc-anchor&quot; href=&quot;https://11ty.rocks/posts/creating-and-using-11ty-collections/#exclude-content-from-collections&quot; aria-labelledby=&quot;exclude-content-from-collections&quot;&gt;&lt;span hidden=&quot;&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;Sometimes you will want to remove a template from being included in collections. This attribute removes the template content from the &lt;code&gt;all&lt;/code&gt; collection and any other defined collection.&lt;/p&gt;
&lt;pre class=&quot;language-md&quot;&gt;&lt;code class=&quot;language-md&quot;&gt;&lt;span class=&quot;token front-matter-block&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;---&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token front-matter yaml language-yaml&quot;&gt;&lt;span class=&quot;token key atrule&quot;&gt;eleventyExcludeFromCollections&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token boolean important&quot;&gt;true&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;---&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;div class=&quot;heading-wrapper h2&quot;&gt;
&lt;h2 id=&quot;summary-of-collection-creation-methods&quot;&gt;Summary of Collection Creation Methods&lt;/h2&gt;
&lt;a class=&quot;tdbc-anchor&quot; href=&quot;https://11ty.rocks/posts/creating-and-using-11ty-collections/#summary-of-collection-creation-methods&quot; aria-labelledby=&quot;summary-of-collection-creation-methods&quot;&gt;&lt;span hidden=&quot;&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;tags&lt;/strong&gt;: easily group content in multiple, flexible ways by template or directory&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;globbed file types&lt;/strong&gt;: succinctly group related template content regardless of file system organization&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;front matter data&lt;/strong&gt;: extend collection schema beyond tags by grouping content from your own custom meta&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;local data&lt;/strong&gt;: benefit from the collection construct without resorting to pagination&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;filtering collections&lt;/strong&gt;: mutate existing collections with repeatable operations, as well as allow randomization per template if desired&lt;/li&gt;
&lt;/ul&gt;
</content>
	</entry>
	
	
	<entry>
		<title>Filter Titles for RSS and Social Shares</title>
		<link href="https://11ty.rocks/tips/filter-titles-for-rss-and-social-shares/"/>
		<updated>2021-08-08T00:00:00Z</updated>
		<id>https://11ty.rocks/tips/filter-titles-for-rss-and-social-shares/</id>
		<content type="html">&lt;p&gt;Sometimes, we want to use characters in our page titles that we can safely escape on our own sites, but which would be stripped out by social networks&#39; link embeds or when pulled up in an RSS reader. For instance, an article called &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/HTML/Element/tfoot&quot;&gt;&amp;quot;&amp;lt;tfoot&amp;gt;: The Table Foot element&amp;quot;&lt;/a&gt; is usually stripped down to &amp;quot;: The Table Foot Element&amp;quot; to prevent cross-site scripting. If you use the &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Glossary/Entity&quot;&gt;&lt;code&gt;&amp;amp;lt;&lt;/code&gt; and &lt;code&gt;&amp;amp;gt;&lt;/code&gt; HTML entities&lt;/a&gt; instead, these same platforms will display your title as &amp;quot;&amp;amp;lt;tfoot&amp;amp;gt;: The Table Foot element,&amp;quot; which is also not ideal.&lt;/p&gt;
&lt;p&gt;You could choose to rework your titles so you don&#39;t run into this issue. Alternatively, you could automatically replace the offending characters with close lookalikes that won&#39;t be stripped out. Here, we&#39;ll replace the less-than and greater-than signs with the similar-looking &lt;code&gt;‹&lt;/code&gt; and &lt;code&gt;›&lt;/code&gt; &lt;a href=&quot;https://en.wikipedia.org/wiki/Guillemet&quot;&gt;single guillemets&lt;/a&gt;.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Accessibility tip:&lt;/strong&gt; Replacing characters with other characters can pose accessibility concerns, as screen readers will attempt to pronounce the characters according to their intended purpose. As such, it&#39;s best to use this technique when you have no other option. Here, we&#39;re fine with replacing less-than and greater-than signs with guillemets because guillements are a kind of quotation mark, and most screen readers will treat them as just a brief pause, which is a better experience than not including the characters at all.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;div class=&quot;heading-wrapper h2&quot;&gt;
&lt;h2 id=&quot;step-1-creating-the-filter&quot;&gt;Step 1: Creating the Filter&lt;/h2&gt;
&lt;a class=&quot;tdbc-anchor&quot; href=&quot;https://11ty.rocks/tips/filter-titles-for-rss-and-social-shares/#step-1-creating-the-filter&quot; aria-labelledby=&quot;step-1-creating-the-filter&quot;&gt;&lt;span hidden=&quot;&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;We&#39;ll create an &lt;a href=&quot;https://www.11ty.dev/docs/filters/&quot;&gt;Eleventy filter&lt;/a&gt; that will take a string (our post title) and replace characters with their lookalikes.&lt;/p&gt;
&lt;p&gt;In your Eleventy config:&lt;/p&gt;
&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;eleventyConfig&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;addFilter&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;replaceStrippedCharacters&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;title&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;	&lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; title&lt;br /&gt;		&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;replace&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token regex&quot;&gt;&lt;span class=&quot;token regex-delimiter&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;token regex-source language-regex&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token regex-delimiter&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;token regex-flags&quot;&gt;g&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;‹&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;		&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;replace&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token regex&quot;&gt;&lt;span class=&quot;token regex-delimiter&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;token regex-source language-regex&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;token regex-delimiter&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;token regex-flags&quot;&gt;g&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;›&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;You can include any substitutions you need in this filter.&lt;/p&gt;
&lt;div class=&quot;heading-wrapper h2&quot;&gt;
&lt;h2 id=&quot;step-2-filter-titles-in-social-link-embeds&quot;&gt;Step 2: Filter Titles in Social Link Embeds&lt;/h2&gt;
&lt;a class=&quot;tdbc-anchor&quot; href=&quot;https://11ty.rocks/tips/filter-titles-for-rss-and-social-shares/#step-2-filter-titles-in-social-link-embeds&quot; aria-labelledby=&quot;step-2-filter-titles-in-social-link-embeds&quot;&gt;&lt;span hidden=&quot;&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;Go to your layout where you have your meta tags. You likely have a meta tag that looks like this:&lt;/p&gt;
&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;meta&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;property&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;og:title&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;content&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;{{ title }}&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;/&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Update this tag so that it passes your post&#39;s &lt;code&gt;title&lt;/code&gt; through your new &lt;code&gt;replaceStrippedCharacters&lt;/code&gt; filter:&lt;/p&gt;
&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;meta&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;property&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;og:title&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;content&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;{{ title | replaceStrippedCharacters }}&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;/&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Now whenever your link is shared on social media, the link embeds will display your character substitutions. You can validate this works using tools like &lt;a href=&quot;https://cards-dev.twitter.com/validator&quot;&gt;Twitter&#39;s card validator&lt;/a&gt;.&lt;/p&gt;
&lt;div class=&quot;heading-wrapper h2&quot;&gt;
&lt;h2 id=&quot;step-3-filter-titles-in-rss-feeds&quot;&gt;Step 3: Filter Titles in RSS Feeds&lt;/h2&gt;
&lt;a class=&quot;tdbc-anchor&quot; href=&quot;https://11ty.rocks/tips/filter-titles-for-rss-and-social-shares/#step-3-filter-titles-in-rss-feeds&quot; aria-labelledby=&quot;step-3-filter-titles-in-rss-feeds&quot;&gt;&lt;span hidden=&quot;&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; This section assumes you&#39;re using the official &lt;code&gt;eleventy-plugin-rss&lt;/code&gt; plugin with the &lt;a href=&quot;https://www.11ty.dev/docs/plugins/rss/#sample-atom-feed-template&quot;&gt;recommended sample Atom feed template&lt;/a&gt; to generate your RSS feeds.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Find the RSS template file you created while setting up Eleventy&#39;s RSS plugin. This template file likely loops over a collection of posts, doing something like:&lt;/p&gt;
&lt;pre class=&quot;language-liquid&quot;&gt;&lt;code class=&quot;language-liquid&quot;&gt;&lt;span class=&quot;token liquid language-liquid&quot;&gt;&lt;span class=&quot;token delimiter punctuation&quot;&gt;{%-&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;for&lt;/span&gt; post &lt;span class=&quot;token keyword&quot;&gt;in&lt;/span&gt; collections&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;posts &lt;span class=&quot;token delimiter punctuation&quot;&gt;%}&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token liquid language-liquid&quot;&gt;&lt;span class=&quot;token delimiter punctuation&quot;&gt;{%&lt;/span&gt; set absolutePostUrl &lt;span class=&quot;token delimiter punctuation&quot;&gt;%}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token liquid language-liquid&quot;&gt;&lt;span class=&quot;token delimiter punctuation&quot;&gt;{{&lt;/span&gt; post&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;url &lt;span class=&quot;token operator&quot;&gt;|&lt;/span&gt; &lt;span class=&quot;token function filter&quot;&gt;url&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;|&lt;/span&gt; &lt;span class=&quot;token function filter&quot;&gt;absoluteUrl&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;metadata&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;url&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token delimiter punctuation&quot;&gt;}}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token liquid language-liquid&quot;&gt;&lt;span class=&quot;token delimiter punctuation&quot;&gt;{%&lt;/span&gt; endset &lt;span class=&quot;token delimiter punctuation&quot;&gt;%}&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;entry&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;title&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token liquid language-liquid&quot;&gt;&lt;span class=&quot;token delimiter punctuation&quot;&gt;{{&lt;/span&gt; post&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;data&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;title &lt;span class=&quot;token delimiter punctuation&quot;&gt;}}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;title&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;link&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;href&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;token liquid language-liquid&quot;&gt;&lt;span class=&quot;token delimiter punctuation&quot;&gt;{{&lt;/span&gt; absolutePostUrl &lt;span class=&quot;token delimiter punctuation&quot;&gt;}}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;/&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;updated&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token liquid language-liquid&quot;&gt;&lt;span class=&quot;token delimiter punctuation&quot;&gt;{{&lt;/span&gt; post&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token object&quot;&gt;date&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;|&lt;/span&gt; &lt;span class=&quot;token function filter&quot;&gt;dateToRfc3339&lt;/span&gt; &lt;span class=&quot;token delimiter punctuation&quot;&gt;}}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;updated&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;id&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token liquid language-liquid&quot;&gt;&lt;span class=&quot;token delimiter punctuation&quot;&gt;{{&lt;/span&gt; absolutePostUrl &lt;span class=&quot;token delimiter punctuation&quot;&gt;}}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;id&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;content&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;type&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;html&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token liquid language-liquid&quot;&gt;&lt;span class=&quot;token delimiter punctuation&quot;&gt;{{&lt;/span&gt; post&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;templateContent &lt;span class=&quot;token operator&quot;&gt;|&lt;/span&gt; &lt;span class=&quot;token function filter&quot;&gt;htmlToAbsoluteUrls&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;absolutePostUrl&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token delimiter punctuation&quot;&gt;}}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;content&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;entry&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token liquid language-liquid&quot;&gt;&lt;span class=&quot;token delimiter punctuation&quot;&gt;{%-&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;endfor&lt;/span&gt; &lt;span class=&quot;token delimiter punctuation&quot;&gt;%}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Pass the &lt;code&gt;&amp;lt;entry&amp;gt;&lt;/code&gt;&#39;s &lt;code&gt;&amp;lt;title&amp;gt;&lt;/code&gt; through the &lt;code&gt;replaceStrippedCharacters&lt;/code&gt; filter:&lt;/p&gt;
&lt;pre class=&quot;language-liquid&quot;&gt;&lt;code class=&quot;language-liquid&quot;&gt;&lt;span class=&quot;token liquid language-liquid&quot;&gt;&lt;span class=&quot;token delimiter punctuation&quot;&gt;{%-&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;for&lt;/span&gt; post &lt;span class=&quot;token keyword&quot;&gt;in&lt;/span&gt; collections&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;posts &lt;span class=&quot;token delimiter punctuation&quot;&gt;%}&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token liquid language-liquid&quot;&gt;&lt;span class=&quot;token delimiter punctuation&quot;&gt;{%&lt;/span&gt; set absolutePostUrl &lt;span class=&quot;token delimiter punctuation&quot;&gt;%}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token liquid language-liquid&quot;&gt;&lt;span class=&quot;token delimiter punctuation&quot;&gt;{{&lt;/span&gt; post&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;url &lt;span class=&quot;token operator&quot;&gt;|&lt;/span&gt; &lt;span class=&quot;token function filter&quot;&gt;url&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;|&lt;/span&gt; &lt;span class=&quot;token function filter&quot;&gt;absoluteUrl&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;metadata&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;url&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token delimiter punctuation&quot;&gt;}}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token liquid language-liquid&quot;&gt;&lt;span class=&quot;token delimiter punctuation&quot;&gt;{%&lt;/span&gt; endset &lt;span class=&quot;token delimiter punctuation&quot;&gt;%}&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;entry&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;title&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token liquid language-liquid&quot;&gt;&lt;span class=&quot;token delimiter punctuation&quot;&gt;{{&lt;/span&gt; post&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;data&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;title &lt;span class=&quot;token operator&quot;&gt;|&lt;/span&gt; &lt;span class=&quot;token function filter&quot;&gt;replaceStrippedCharacters&lt;/span&gt; &lt;span class=&quot;token delimiter punctuation&quot;&gt;}}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;title&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;link&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;href&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;token liquid language-liquid&quot;&gt;&lt;span class=&quot;token delimiter punctuation&quot;&gt;{{&lt;/span&gt; absolutePostUrl &lt;span class=&quot;token delimiter punctuation&quot;&gt;}}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;/&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;updated&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token liquid language-liquid&quot;&gt;&lt;span class=&quot;token delimiter punctuation&quot;&gt;{{&lt;/span&gt; post&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token object&quot;&gt;date&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;|&lt;/span&gt; &lt;span class=&quot;token function filter&quot;&gt;dateToRfc3339&lt;/span&gt; &lt;span class=&quot;token delimiter punctuation&quot;&gt;}}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;updated&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;id&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token liquid language-liquid&quot;&gt;&lt;span class=&quot;token delimiter punctuation&quot;&gt;{{&lt;/span&gt; absolutePostUrl &lt;span class=&quot;token delimiter punctuation&quot;&gt;}}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;id&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;content&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;type&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;html&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token liquid language-liquid&quot;&gt;&lt;span class=&quot;token delimiter punctuation&quot;&gt;{{&lt;/span&gt; post&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;templateContent &lt;span class=&quot;token operator&quot;&gt;|&lt;/span&gt; &lt;span class=&quot;token function filter&quot;&gt;htmlToAbsoluteUrls&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;absolutePostUrl&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token delimiter punctuation&quot;&gt;}}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;content&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;entry&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token liquid language-liquid&quot;&gt;&lt;span class=&quot;token delimiter punctuation&quot;&gt;{%-&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;endfor&lt;/span&gt; &lt;span class=&quot;token delimiter punctuation&quot;&gt;%}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
</content>
	</entry>
	
	
	<entry>
		<title>Plugin: Object-Fit Focal Point</title>
		<link href="https://www.npmjs.com/package/@11tyrocks/eleventy-plugin-objectfit-focalpoint"/>
		<updated>2021-08-07T00:00:00Z</updated>
		<id>https://www.npmjs.com/package/@11tyrocks/eleventy-plugin-objectfit-focalpoint</id>
		<content type="html">&lt;p&gt;This plugin adds an Eleventy Nunjucks shortcode to provide the functionality of generating an image&#39;s object-position value in order to keep the focal point in view when setting CSS &lt;code&gt;aspect-ratio&lt;/code&gt; and &lt;code&gt;object-fit: cover&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://objectfit-focalpoint.netlify.app/&quot;&gt;Test drive the results&lt;/a&gt; by using the utility app.&lt;/p&gt;
&lt;a href=&quot;https://www.npmjs.com/package/@11tyrocks/eleventy-plugin-objectfit-focalpoint&quot;&gt;Docs for Object-Fit Focal Point&lt;/a&gt;</content>
	</entry>
	
	
	<entry>
		<title>11ty RSS Reader Starter</title>
		<link href="https://github.com/5t3ph/eleventy-rss-reader"/>
		<updated>2021-06-24T00:00:00Z</updated>
		<id>https://github.com/5t3ph/eleventy-rss-reader</id>
		<content type="html">&lt;p&gt;Provide permalinks to your favorite RSS feeds to populate a personalized RSS reader Jamstack application using Eleventy.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Bonus&lt;/strong&gt;: This application was built on Twitch livestream, and recordings will be available on the &lt;a href=&quot;https://www.youtube.com/playlist?list=PLwr1RpQE3HoAHyahSwmE5HTgMKZaufJ_2&quot;&gt;11ty Rocks YouTube channel&lt;/a&gt;. The course covers advanced 11ty templating.&lt;/p&gt;
&lt;a href=&quot;https://github.com/5t3ph/eleventy-rss-reader&quot;&gt;Get the RSS Starter&lt;/a&gt;</content>
	</entry>
	
	
	<entry>
		<title>Twitch Scenes 11ty Starter Template</title>
		<link href="https://github.com/5t3ph/11ty-twitch-scenes"/>
		<updated>2021-05-02T00:00:00Z</updated>
		<id>https://github.com/5t3ph/11ty-twitch-scenes</id>
		<content type="html">&lt;p&gt;&lt;a href=&quot;https://github.com/5t3ph/11ty-twitch-scenes#scene-previews&quot;&gt;Scenes&lt;/a&gt; are optimal at 1280x720, and are included for:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Preshow, postshow, and break messages&lt;/li&gt;
&lt;li&gt;Main scene with large capture area and host webcam capture&lt;/li&gt;
&lt;li&gt;bonus slideshow layout&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;All scenes include a lower third for stream details, which also features embedded chat.&lt;/p&gt;
&lt;a href=&quot;https://github.com/5t3ph/11ty-twitch-scenes&quot;&gt;Get the Scenes Template&lt;/a&gt;</content>
	</entry>
	
	
	<entry>
		<title>Layout Templating</title>
		<link href="https://11ty.rocks/tips/layout-templating/"/>
		<updated>2021-04-16T00:00:00Z</updated>
		<id>https://11ty.rocks/tips/layout-templating/</id>
		<content type="html">&lt;div class=&quot;heading-wrapper h2&quot;&gt;
&lt;h2 id=&quot;body-classes-for-pages-and-layouts&quot;&gt;Body Classes for Pages and Layouts&lt;/h2&gt;
&lt;a class=&quot;tdbc-anchor&quot; href=&quot;https://11ty.rocks/tips/layout-templating/#body-classes-for-pages-and-layouts&quot; aria-labelledby=&quot;body-classes-for-pages-and-layouts&quot;&gt;&lt;span hidden=&quot;&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;A trick I originally learned from WordPress templates is to add a class on the body to identify the page being viewed. This helps you have page-specific style rules.&lt;/p&gt;
&lt;p&gt;The &lt;code&gt;{{ page.fileSlug }}&lt;/code&gt; is an Eleventy provided data variable that will be the original file name without the extension.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;This will be the file name only, not the path. So &lt;code&gt;/blog/post-one.md&lt;/code&gt; would render &lt;code&gt;post-one&lt;/code&gt;.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Our logic includes the class of &amp;quot;home&amp;quot; when there is no &lt;code&gt;fileSlug&lt;/code&gt; available since the the main &lt;code&gt;index&lt;/code&gt; will not compute a &lt;code&gt;fileSlug&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&quot;language-twig&quot;&gt;&lt;code class=&quot;language-twig&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;body&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;page--&lt;span class=&quot;token twig language-twig&quot;&gt;&lt;span class=&quot;token delimiter punctuation&quot;&gt;{%&lt;/span&gt; &lt;span class=&quot;token tag-name keyword&quot;&gt;if&lt;/span&gt; page&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;fileSlug &lt;span class=&quot;token delimiter punctuation&quot;&gt;%}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token twig language-twig&quot;&gt;&lt;span class=&quot;token delimiter punctuation&quot;&gt;{{&lt;/span&gt; page&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;fileSlug &lt;span class=&quot;token delimiter punctuation&quot;&gt;}}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token twig language-twig&quot;&gt;&lt;span class=&quot;token delimiter punctuation&quot;&gt;{%&lt;/span&gt; &lt;span class=&quot;token tag-name keyword&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;token delimiter punctuation&quot;&gt;%}&lt;/span&gt;&lt;/span&gt;home&lt;span class=&quot;token twig language-twig&quot;&gt;&lt;span class=&quot;token delimiter punctuation&quot;&gt;{%&lt;/span&gt; &lt;span class=&quot;token tag-name keyword&quot;&gt;endif&lt;/span&gt; &lt;span class=&quot;token delimiter punctuation&quot;&gt;%}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;You may also add the layout in a similar way:&lt;/p&gt;
&lt;pre class=&quot;language-twig&quot;&gt;&lt;code class=&quot;language-twig&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;body&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;layout--&lt;span class=&quot;token twig language-twig&quot;&gt;&lt;span class=&quot;token delimiter punctuation&quot;&gt;{{&lt;/span&gt; layout &lt;span class=&quot;token delimiter punctuation&quot;&gt;}}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;blockquote&gt;
&lt;p&gt;Note: If layouts are chained, then &lt;code&gt;{{ layout }}&lt;/code&gt; will render out the &lt;em&gt;lowest&lt;/em&gt; layout in the chain. So if &lt;code&gt;blog.njk&lt;/code&gt; chains to &lt;code&gt;base.njk&lt;/code&gt;, it will select &lt;code&gt;blog&lt;/code&gt;.&lt;/p&gt;
&lt;/blockquote&gt;
</content>
	</entry>
	
	
	<entry>
		<title>Use Eleventy Templating To Include Static Code Demos</title>
		<link href="https://11ty.rocks/posts/eleventy-templating-static-code-demos/"/>
		<updated>2021-04-02T00:00:00Z</updated>
		<id>https://11ty.rocks/posts/eleventy-templating-static-code-demos/</id>
		<content type="html">&lt;blockquote&gt;
&lt;p&gt;This post assumes a foundational familiarity with Eleventy. If you&#39;re new to 11ty - welcome! You may want to &lt;a href=&quot;https://11ty.rocks/posts/create-your-first-basic-11ty-website/&quot;&gt;start here&lt;/a&gt;.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;This tutorial will showcase many features of Nunjucks templating. So, even if the tutorial&#39;s goal doesn&#39;t match your use case, you&#39;ll get more familair with using it as a templating language!&lt;/p&gt;
&lt;div class=&quot;heading-wrapper h2&quot;&gt;
&lt;h2 id=&quot;project-brief&quot;&gt;Project Brief&lt;/h2&gt;
&lt;a class=&quot;tdbc-anchor&quot; href=&quot;https://11ty.rocks/posts/eleventy-templating-static-code-demos/#project-brief&quot; aria-labelledby=&quot;project-brief&quot;&gt;&lt;span hidden=&quot;&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;The goal of this Eleventy project is to create a single-page site that displays live code demos, like the setup on &lt;a href=&quot;https://smolcss.dev/&quot;&gt;SmolCSS.dev&lt;/a&gt;. And we&#39;ll see how to extend it to a scoped context like is used for &lt;a href=&quot;https://moderncss.dev/developing-for-imperfect-future-proofing-css-styles/&quot;&gt;this ModernCSS.dev tutorial&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Here are the base requirements:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;ease of managing demo content&lt;/li&gt;
&lt;li&gt;demo code lives with demo content&lt;/li&gt;
&lt;li&gt;each demo is an independent file&lt;/li&gt;
&lt;li&gt;allow custom ordering of demos vs. date-based&lt;/li&gt;
&lt;li&gt;RSS feed for demos&lt;/li&gt;
&lt;li&gt;&amp;quot;Open in CodePen&amp;quot; functionality&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&quot;heading-wrapper h2&quot;&gt;
&lt;h2 id=&quot;base-project-configuration&quot;&gt;Base Project Configuration&lt;/h2&gt;
&lt;a class=&quot;tdbc-anchor&quot; href=&quot;https://11ty.rocks/posts/eleventy-templating-static-code-demos/#base-project-configuration&quot; aria-labelledby=&quot;base-project-configuration&quot;&gt;&lt;span hidden=&quot;&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;We&#39;re starting from an empty project with Eleventy installed and ready to run.&lt;/p&gt;
&lt;p&gt;This tutorial will assume a customized &lt;code&gt;input&lt;/code&gt; directory of &lt;code&gt;src&lt;/code&gt;, and that you&#39;ve created an &lt;code&gt;index&lt;/code&gt; file where we&#39;ll eventually add the demo content.&lt;/p&gt;
&lt;p&gt;If you&#39;re unsure how to do those things, follow my tutorial on &lt;a href=&quot;https://11ty.rocks/posts/create-your-first-basic-11ty-website/&quot;&gt;creating your first 11ty site&lt;/a&gt; up until the &lt;em&gt;Create the Blog&lt;/em&gt; step, and then come back to continue! 😊&lt;/p&gt;
&lt;p&gt;You may also want to do the &amp;quot;Create a CSS File&amp;quot; and &amp;quot;Link to Stylesheet&amp;quot; sections in that tutorial if you are unfamiliar with how to do that with Eleventy.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Setup your index as &lt;code&gt;index.njk&lt;/code&gt; as we&#39;ll primary be using Nunjucks for this tutorial.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;div class=&quot;heading-wrapper h2&quot;&gt;
&lt;h2 id=&quot;base-eleventy-setup-for-single-page-content&quot;&gt;Base Eleventy Setup for Single-Page Content&lt;/h2&gt;
&lt;a class=&quot;tdbc-anchor&quot; href=&quot;https://11ty.rocks/posts/eleventy-templating-static-code-demos/#base-eleventy-setup-for-single-page-content&quot; aria-labelledby=&quot;base-eleventy-setup-for-single-page-content&quot;&gt;&lt;span hidden=&quot;&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;My favorite thing about Eleventy is the flexible content modeling. And most projects I do definitely benefit from the filesystem page creation, but for this project we&#39;ll need to disable that functionality.&lt;/p&gt;
&lt;p&gt;So, our first step is to create a location for our code demos to live. Add &lt;code&gt;src/demos&lt;/code&gt;, and then create the file &lt;code&gt;demos.json&lt;/code&gt; with the following contents:&lt;/p&gt;
&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token string-property property&quot;&gt;&quot;tags&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;demos&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token string-property property&quot;&gt;&quot;permalink&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token boolean&quot;&gt;false&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This is a &lt;em&gt;directory data file&lt;/em&gt; and we define &lt;code&gt;tags&lt;/code&gt; to create the &lt;code&gt;demos&lt;/code&gt; collection. Then we set &lt;code&gt;permalink&lt;/code&gt; to &lt;code&gt;false&lt;/code&gt; to prevent page generation. These values will apply to all content within the directory, although you could still set front matter to override them for specific content.&lt;/p&gt;
&lt;div class=&quot;heading-wrapper h2&quot;&gt;
&lt;h2 id=&quot;create-a-demo-file&quot;&gt;Create a Demo File&lt;/h2&gt;
&lt;a class=&quot;tdbc-anchor&quot; href=&quot;https://11ty.rocks/posts/eleventy-templating-static-code-demos/#create-a-demo-file&quot; aria-labelledby=&quot;create-a-demo-file&quot;&gt;&lt;span hidden=&quot;&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;Let&#39;s create our first demo. Add &lt;code&gt;demo/centering.njk&lt;/code&gt; with the following content:&lt;/p&gt;
&lt;pre class=&quot;language-md&quot;&gt;&lt;code class=&quot;language-md&quot;&gt;&lt;span class=&quot;token front-matter-block&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;---&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token front-matter yaml language-yaml&quot;&gt;&lt;span class=&quot;token key atrule&quot;&gt;title&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;CSS Centering&quot;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token key atrule&quot;&gt;order&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token key atrule&quot;&gt;date&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token datetime number&quot;&gt;2021-03-31&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token key atrule&quot;&gt;templateEngineOverride&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; njk&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; md&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;---&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;We include an &lt;code&gt;order&lt;/code&gt; property that we&#39;ll use to order our demos within our single page rather than relying on Eleventy&#39;s default of date-based ordering. This is because we may create multiples on the same day, and on publish they may change order from what we see locally.&lt;/p&gt;
&lt;p&gt;There is also a date included for purposes of correctly updating the RSS feed we&#39;ll be adding.&lt;/p&gt;
&lt;p&gt;Finally, we add &lt;code&gt;templateEngineOverride: njk, md&lt;/code&gt; because we will be mixing Markdown with Nunjucks content in this file and we want both to be processed correctly.&lt;/p&gt;
&lt;div class=&quot;heading-wrapper h2&quot;&gt;
&lt;h2 id=&quot;demo-partial-and-code-content&quot;&gt;Demo Partial and Code Content&lt;/h2&gt;
&lt;a class=&quot;tdbc-anchor&quot; href=&quot;https://11ty.rocks/posts/eleventy-templating-static-code-demos/#demo-partial-and-code-content&quot; aria-labelledby=&quot;demo-partial-and-code-content&quot;&gt;&lt;span hidden=&quot;&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;You may be wondering why we didn&#39;t add any content in the previous step. Instead of directly outputting the content within the demo Nunjucks file, we&#39;re going to populate Nunjucks variables to pass into a partial. This will enable consistency among our code demos and allow enhanced functionality.&lt;/p&gt;
&lt;p&gt;Create &lt;code&gt;src/_includes/demo.njk&lt;/code&gt; which will be our partial.&lt;/p&gt;
&lt;p&gt;Let&#39;s determine the parts we need to output for each demo:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;a title&lt;/li&gt;
&lt;li&gt;a description&lt;/li&gt;
&lt;li&gt;HTML&lt;/li&gt;
&lt;li&gt;CSS&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Now, since this is a case study of &lt;a href=&quot;https://smolcss.dev/&quot;&gt;SmolCSS.dev&lt;/a&gt;, we&#39;re going to focus on showing the CSS as highlighted code. You can extend the following ideas to also show the HTML, or perhaps only the HTML, or even add JavaScript into the mix.&lt;/p&gt;
&lt;p&gt;Within &lt;code&gt;demo.njk&lt;/code&gt; let&#39;s populate our demo template:&lt;/p&gt;
&lt;pre class=&quot;language-twig&quot;&gt;&lt;code class=&quot;language-twig&quot;&gt;&lt;span class=&quot;token twig language-twig&quot;&gt;&lt;span class=&quot;token delimiter punctuation&quot;&gt;{{&lt;/span&gt; description &lt;span class=&quot;token operator&quot;&gt;|&lt;/span&gt; safe &lt;span class=&quot;token delimiter punctuation&quot;&gt;}}&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;style&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token style&quot;&gt;&lt;span class=&quot;token language-css&quot;&gt;&lt;br /&gt;&lt;span class=&quot;token twig language-twig&quot;&gt;&lt;span class=&quot;token delimiter punctuation&quot;&gt;{{&lt;/span&gt; css &lt;span class=&quot;token operator&quot;&gt;|&lt;/span&gt; safe &lt;span class=&quot;token delimiter punctuation&quot;&gt;}}&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;style&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;details&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;summary&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;CSS for &quot;&lt;span class=&quot;token twig language-twig&quot;&gt;&lt;span class=&quot;token delimiter punctuation&quot;&gt;{{&lt;/span&gt; title &lt;span class=&quot;token delimiter punctuation&quot;&gt;}}&lt;/span&gt;&lt;/span&gt;&quot;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;summary&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;  &lt;span class=&quot;token twig language-twig&quot;&gt;&lt;span class=&quot;token delimiter punctuation&quot;&gt;{%&lt;/span&gt; &lt;span class=&quot;token tag-name keyword&quot;&gt;highlight&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;css&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token delimiter punctuation&quot;&gt;%}&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token twig language-twig&quot;&gt;&lt;span class=&quot;token delimiter punctuation&quot;&gt;{{-&lt;/span&gt; css &lt;span class=&quot;token operator&quot;&gt;|&lt;/span&gt; safe &lt;span class=&quot;token delimiter punctuation&quot;&gt;}}&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token twig language-twig&quot;&gt;&lt;span class=&quot;token delimiter punctuation&quot;&gt;{%&lt;/span&gt; &lt;span class=&quot;token tag-name keyword&quot;&gt;endhighlight&lt;/span&gt; &lt;span class=&quot;token delimiter punctuation&quot;&gt;%}&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;details&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;div&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;demo&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token twig language-twig&quot;&gt;&lt;span class=&quot;token delimiter punctuation&quot;&gt;{{&lt;/span&gt; html &lt;span class=&quot;token operator&quot;&gt;|&lt;/span&gt; safe &lt;span class=&quot;token delimiter punctuation&quot;&gt;}}&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;div&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Now this partial accepts the following variables:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;title&lt;/code&gt; - used within the &lt;code&gt;summary&lt;/code&gt; element since we&#39;re going to use the native HTML &lt;code&gt;details&lt;/code&gt; element to enable collapsing the demo code&lt;/li&gt;
&lt;li&gt;&lt;code&gt;description&lt;/code&gt; - included with the &lt;code&gt;safe&lt;/code&gt; filter because the content will be pre-compiled from Markdown into HTML&lt;/li&gt;
&lt;li&gt;&lt;code&gt;css&lt;/code&gt; - added twice so that it can be output as actual CSS within &lt;code&gt;style&lt;/code&gt; tags, and also within a &lt;code&gt;highlight&lt;/code&gt; block that will become the demo&#39;s sample code&lt;/li&gt;
&lt;li&gt;&lt;code&gt;html&lt;/code&gt; - added within a &lt;code&gt;div.demo&lt;/code&gt; so that we can style the demo container around the passed HTML content&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Let&#39;s go back to our first demo file and add the content within these variables:&lt;/p&gt;
&lt;pre class=&quot;language-twig&quot;&gt;&lt;code class=&quot;language-twig&quot;&gt;&lt;span class=&quot;token twig language-twig&quot;&gt;&lt;span class=&quot;token delimiter punctuation&quot;&gt;{%&lt;/span&gt; &lt;span class=&quot;token tag-name keyword&quot;&gt;set&lt;/span&gt; description &lt;span class=&quot;token delimiter punctuation&quot;&gt;%}&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;**Put down the CSS centering jokes**! This modern update is often the solution you&#39;re looking for to solve your centering woes.&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token twig language-twig&quot;&gt;&lt;span class=&quot;token delimiter punctuation&quot;&gt;{%&lt;/span&gt; &lt;span class=&quot;token tag-name keyword&quot;&gt;endset&lt;/span&gt; &lt;span class=&quot;token delimiter punctuation&quot;&gt;%}&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token twig language-twig&quot;&gt;&lt;span class=&quot;token delimiter punctuation&quot;&gt;{%&lt;/span&gt; &lt;span class=&quot;token tag-name keyword&quot;&gt;set&lt;/span&gt; css &lt;span class=&quot;token delimiter punctuation&quot;&gt;%}&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;.centering {&lt;br /&gt;  display: grid;&lt;br /&gt;  place-content: center;&lt;br /&gt;}&lt;br /&gt;&lt;span class=&quot;token twig language-twig&quot;&gt;&lt;span class=&quot;token delimiter punctuation&quot;&gt;{%&lt;/span&gt; &lt;span class=&quot;token tag-name keyword&quot;&gt;endset&lt;/span&gt; &lt;span class=&quot;token delimiter punctuation&quot;&gt;%}&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token twig language-twig&quot;&gt;&lt;span class=&quot;token delimiter punctuation&quot;&gt;{%&lt;/span&gt; &lt;span class=&quot;token tag-name keyword&quot;&gt;set&lt;/span&gt; html &lt;span class=&quot;token delimiter punctuation&quot;&gt;%}&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;div&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;centering&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;span&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;Feeling Centered&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;span&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;div&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token twig language-twig&quot;&gt;&lt;span class=&quot;token delimiter punctuation&quot;&gt;{%&lt;/span&gt; &lt;span class=&quot;token tag-name keyword&quot;&gt;endset&lt;/span&gt; &lt;span class=&quot;token delimiter punctuation&quot;&gt;%}&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token twig language-twig&quot;&gt;&lt;span class=&quot;token delimiter punctuation&quot;&gt;{%&lt;/span&gt; &lt;span class=&quot;token tag-name keyword&quot;&gt;include&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;demo.njk&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token delimiter punctuation&quot;&gt;%}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This sets the variables, and also includes the &lt;code&gt;demo&lt;/code&gt; partial. For each demo file you create, continue this pattern of setting variables and including the partial.&lt;/p&gt;
&lt;p&gt;Before we see some example output, this also assumes you are using &lt;a href=&quot;https://www.11ty.dev/docs/plugins/syntaxhighlight/&quot;&gt;eleventy-plugin-syntaxhighlight&lt;/a&gt; and have pre-included a &lt;a href=&quot;https://github.com/PrismJS/prism-themes&quot;&gt;prism theme&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Here&#39;s some starting CSS for the &lt;code&gt;details&lt;/code&gt;, &lt;code&gt;summary&lt;/code&gt;, and &lt;code&gt;.demo&lt;/code&gt;:&lt;/p&gt;
&lt;pre class=&quot;language-css&quot;&gt;&lt;code class=&quot;language-css&quot;&gt;&lt;span class=&quot;token selector&quot;&gt;details&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token property&quot;&gt;margin&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 2rem 0 0&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token selector&quot;&gt;details pre[class*=&quot;language-&quot;]&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token property&quot;&gt;margin&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 0&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token selector&quot;&gt;summary&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token property&quot;&gt;padding&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 0.15em 0.5em&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token property&quot;&gt;background-color&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; #0d3233&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token property&quot;&gt;color&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; #fff&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token property&quot;&gt;cursor&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; pointer&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token selector&quot;&gt;summary:focus&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token property&quot;&gt;outline&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 2px solid #0d3233&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token property&quot;&gt;outline-offset&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 2px&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token selector&quot;&gt;.demo&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token property&quot;&gt;min-height&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 30vh&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token property&quot;&gt;padding&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 1rem&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token property&quot;&gt;border&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 2px dashed currentColor&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;div class=&quot;heading-wrapper h3&quot;&gt;
&lt;h3 id=&quot;example-code-demo-output&quot;&gt;Example Code Demo Output&lt;/h3&gt;
&lt;a class=&quot;tdbc-anchor&quot; href=&quot;https://11ty.rocks/posts/eleventy-templating-static-code-demos/#example-code-demo-output&quot; aria-labelledby=&quot;example-code-demo-output&quot;&gt;&lt;span hidden=&quot;&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;&lt;strong&gt;Put down the CSS centering jokes&lt;/strong&gt;! This modern update is often the solution you&#39;re looking for to solve your centering woes.&lt;/p&gt;
&lt;details&gt;
  &lt;summary&gt;CSS for &quot;Demo Output&quot;&lt;/summary&gt;
  &lt;pre class=&quot;language-css&quot;&gt;&lt;code class=&quot;language-css&quot;&gt;&lt;span class=&quot;token selector&quot;&gt;.centering&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token property&quot;&gt;display&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; grid&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token property&quot;&gt;place-content&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; center&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token property&quot;&gt;min-height&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 30vh&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token selector&quot;&gt;.centering span&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token property&quot;&gt;padding&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; .5em&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token property&quot;&gt;outline&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 2px solid&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/details&gt;
&lt;style&gt;
.centering-190 {
  display: grid;
  place-content: center;
  min-height: 30vh;
}

.centering-190 span {
  padding: .5em;
  outline: 2px solid;
}
&lt;/style&gt;
&lt;div class=&quot;demo&quot;&gt;
&lt;div class=&quot;centering-190&quot;&gt;
  &lt;span&gt;Feeling Centered&lt;/span&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;heading-wrapper h3&quot;&gt;
&lt;h3 id=&quot;extend-the-code-partial&quot;&gt;Extend the Code Partial&lt;/h3&gt;
&lt;a class=&quot;tdbc-anchor&quot; href=&quot;https://11ty.rocks/posts/eleventy-templating-static-code-demos/#extend-the-code-partial&quot; aria-labelledby=&quot;extend-the-code-partial&quot;&gt;&lt;span hidden=&quot;&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;The great thing about handling this via a partial that is passed variables to modify behavior is that you can build up &lt;em&gt;more&lt;/em&gt; variables to alter the output when needed.&lt;/p&gt;
&lt;p&gt;For example, maybe you don&#39;t &lt;em&gt;always&lt;/em&gt; have HTML and description output and just want to show the CSS. So, you could create and handle for a &lt;code&gt;hideDemo&lt;/code&gt; variable:&lt;/p&gt;
&lt;pre class=&quot;language-twig&quot;&gt;&lt;code class=&quot;language-twig&quot;&gt;&lt;span class=&quot;token twig language-twig&quot;&gt;&lt;span class=&quot;token delimiter punctuation&quot;&gt;{%&lt;/span&gt; &lt;span class=&quot;token tag-name keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;not&lt;/span&gt; hideDescription &lt;span class=&quot;token delimiter punctuation&quot;&gt;%}&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token twig language-twig&quot;&gt;&lt;span class=&quot;token delimiter punctuation&quot;&gt;{{&lt;/span&gt; description &lt;span class=&quot;token operator&quot;&gt;|&lt;/span&gt; safe &lt;span class=&quot;token delimiter punctuation&quot;&gt;}}&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token twig language-twig&quot;&gt;&lt;span class=&quot;token delimiter punctuation&quot;&gt;{%&lt;/span&gt; &lt;span class=&quot;token tag-name keyword&quot;&gt;endif&lt;/span&gt; &lt;span class=&quot;token delimiter punctuation&quot;&gt;%}&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token twig language-twig&quot;&gt;&lt;span class=&quot;token delimiter punctuation&quot;&gt;{%&lt;/span&gt; &lt;span class=&quot;token tag-name keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;not&lt;/span&gt; hideDemo &lt;span class=&quot;token delimiter punctuation&quot;&gt;%}&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;div&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;demo&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token twig language-twig&quot;&gt;&lt;span class=&quot;token delimiter punctuation&quot;&gt;{{&lt;/span&gt; html &lt;span class=&quot;token operator&quot;&gt;|&lt;/span&gt; safe &lt;span class=&quot;token delimiter punctuation&quot;&gt;}}&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;div&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token twig language-twig&quot;&gt;&lt;span class=&quot;token delimiter punctuation&quot;&gt;{%&lt;/span&gt; &lt;span class=&quot;token tag-name keyword&quot;&gt;endif&lt;/span&gt; &lt;span class=&quot;token delimiter punctuation&quot;&gt;%}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Which would be set as follows within your code file:&lt;/p&gt;
&lt;pre class=&quot;language-twig&quot;&gt;&lt;code class=&quot;language-twig&quot;&gt;&lt;span class=&quot;token twig language-twig&quot;&gt;&lt;span class=&quot;token delimiter punctuation&quot;&gt;{%&lt;/span&gt; &lt;span class=&quot;token tag-name keyword&quot;&gt;set&lt;/span&gt; hideDescription &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token boolean&quot;&gt;true&lt;/span&gt; &lt;span class=&quot;token delimiter punctuation&quot;&gt;%}&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token twig language-twig&quot;&gt;&lt;span class=&quot;token delimiter punctuation&quot;&gt;{%&lt;/span&gt; &lt;span class=&quot;token tag-name keyword&quot;&gt;set&lt;/span&gt; hideDemo &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token boolean&quot;&gt;true&lt;/span&gt; &lt;span class=&quot;token delimiter punctuation&quot;&gt;%}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Resulting in only the details/summary appearing:&lt;/p&gt;
&lt;details&gt;
  &lt;summary&gt;CSS for &quot;Demo Output&quot;&lt;/summary&gt;
  &lt;pre class=&quot;language-css&quot;&gt;&lt;code class=&quot;language-css&quot;&gt;&lt;span class=&quot;token selector&quot;&gt;.centering&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token property&quot;&gt;display&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; grid&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token property&quot;&gt;place-content&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; center&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token property&quot;&gt;min-height&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 30vh&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token selector&quot;&gt;.centering span&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token property&quot;&gt;padding&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; .5em&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token property&quot;&gt;outline&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 2px solid&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/details&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Challenge&lt;/strong&gt;: Extend this to make the &lt;code&gt;open&lt;/code&gt; property for &lt;code&gt;details&lt;/code&gt; a variable so that you have the option to set the &lt;code&gt;details&lt;/code&gt; to visible instead of collapsed&lt;/p&gt;
&lt;/blockquote&gt;
&lt;div class=&quot;heading-wrapper h2&quot;&gt;
&lt;h2 id=&quot;ordering-and-output-of-the-demos-collection&quot;&gt;Ordering and Output of the &lt;code&gt;demos&lt;/code&gt; Collection&lt;/h2&gt;
&lt;a class=&quot;tdbc-anchor&quot; href=&quot;https://11ty.rocks/posts/eleventy-templating-static-code-demos/#ordering-and-output-of-the-demos-collection&quot; aria-labelledby=&quot;ordering-and-output-of-the-demos-collection&quot;&gt;&lt;span hidden=&quot;&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;Now that we have our demo code files and partial figured out, it&#39;s time to figure out how to display this content. Remember - we turned off the default file system individual page creation.&lt;/p&gt;
&lt;p&gt;We also had created a collection called &lt;code&gt;demos&lt;/code&gt; when we defined the directory data file by assigning all of the files the tag of &lt;code&gt;demos&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;However, that collection will currently be date based as is the 11ty default. Since we want it based off the &lt;code&gt;order&lt;/code&gt; front matter, we need to create a custom collection.&lt;/p&gt;
&lt;p&gt;Add the following within &lt;code&gt;.eleventy.js&lt;/code&gt; above the previous customization that updated the input/output directories:&lt;/p&gt;
&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;eleventyConfig&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;addCollection&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;orderedDemos&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;collection&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; collection&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;getFilteredByTag&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;demos&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;sort&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;a&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; b&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; a&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;data&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;order &lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt; b&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;data&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;order&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This takes the &lt;code&gt;demos&lt;/code&gt; collection and reorders it by our custom &lt;code&gt;order&lt;/code&gt; key and returns a new collection called &lt;code&gt;orderedDemos&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Now we can loop through the new collection to output it within our main index:&lt;/p&gt;
&lt;pre class=&quot;language-twig&quot;&gt;&lt;code class=&quot;language-twig&quot;&gt;&lt;span class=&quot;token twig language-twig&quot;&gt;&lt;span class=&quot;token delimiter punctuation&quot;&gt;{%&lt;/span&gt; &lt;span class=&quot;token tag-name keyword&quot;&gt;for&lt;/span&gt; demo &lt;span class=&quot;token operator&quot;&gt;in&lt;/span&gt; collections&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;orderedDemos &lt;span class=&quot;token delimiter punctuation&quot;&gt;%}&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;article&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;h2&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;token twig language-twig&quot;&gt;&lt;span class=&quot;token delimiter punctuation&quot;&gt;{{&lt;/span&gt; demo&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;fileSlug &lt;span class=&quot;token delimiter punctuation&quot;&gt;}}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token twig language-twig&quot;&gt;&lt;span class=&quot;token delimiter punctuation&quot;&gt;{{&lt;/span&gt; demo&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;data&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;title &lt;span class=&quot;token delimiter punctuation&quot;&gt;}}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;h2&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token twig language-twig&quot;&gt;&lt;span class=&quot;token delimiter punctuation&quot;&gt;{{&lt;/span&gt; demo&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;templateContent &lt;span class=&quot;token operator&quot;&gt;|&lt;/span&gt; safe &lt;span class=&quot;token delimiter punctuation&quot;&gt;}}&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;article&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token twig language-twig&quot;&gt;&lt;span class=&quot;token delimiter punctuation&quot;&gt;{%&lt;/span&gt; &lt;span class=&quot;token tag-name keyword&quot;&gt;endfor&lt;/span&gt; &lt;span class=&quot;token delimiter punctuation&quot;&gt;%}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This is a minimal example where we are adding fully compiled demo &lt;code&gt;templateContent&lt;/code&gt; within an &lt;code&gt;article&lt;/code&gt;. We also pass in the main demo front matter &lt;code&gt;title&lt;/code&gt; within an &lt;code&gt;h2&lt;/code&gt; that includes an &lt;code&gt;id&lt;/code&gt; set to the demo&#39;s file slug in case you&#39;d like to enable anchor links to each demo.&lt;/p&gt;
&lt;div class=&quot;heading-wrapper h2&quot;&gt;
&lt;h2 id=&quot;rss-feed&quot;&gt;RSS Feed&lt;/h2&gt;
&lt;a class=&quot;tdbc-anchor&quot; href=&quot;https://11ty.rocks/posts/eleventy-templating-static-code-demos/#rss-feed&quot; aria-labelledby=&quot;rss-feed&quot;&gt;&lt;span hidden=&quot;&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;To setup an RSS feed, install the &lt;code&gt;eleventy-plugin-rss&lt;/code&gt; plugin and follow the instructions and use the example code from &lt;a href=&quot;https://www.11ty.dev/docs/plugins/rss/&quot;&gt;the RSS plugin docs&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;The only alteration is to change from the &lt;code&gt;posts&lt;/code&gt; collection to use our &lt;code&gt;orderedDemos&lt;/code&gt; collection to correctly order the feed. In addition, you&#39;ll need to pass the &lt;code&gt;reverse&lt;/code&gt; filter, resulting in the following start of the feed loop:&lt;/p&gt;
&lt;pre class=&quot;language-twig&quot;&gt;&lt;code class=&quot;language-twig&quot;&gt;&lt;span class=&quot;token twig language-twig&quot;&gt;&lt;span class=&quot;token delimiter punctuation&quot;&gt;{%-&lt;/span&gt; &lt;span class=&quot;token tag-name keyword&quot;&gt;for&lt;/span&gt; item &lt;span class=&quot;token operator&quot;&gt;in&lt;/span&gt; collections&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;orderedDemos &lt;span class=&quot;token operator&quot;&gt;|&lt;/span&gt; reverse &lt;span class=&quot;token delimiter punctuation&quot;&gt;%}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;div class=&quot;heading-wrapper h2&quot;&gt;
&lt;h2 id=&quot;open-in-codepen&quot;&gt;&amp;quot;Open in CodePen&amp;quot;&lt;/h2&gt;
&lt;a class=&quot;tdbc-anchor&quot; href=&quot;https://11ty.rocks/posts/eleventy-templating-static-code-demos/#open-in-codepen&quot; aria-labelledby=&quot;open-in-codepen&quot;&gt;&lt;span hidden=&quot;&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;A bit of functionality that provides a valuable extra resource for our readers is the ability to export the demo code to CodePen.&lt;/p&gt;
&lt;p&gt;I&#39;ve abstracted my solution as used on SmolCSS.dev and ModernCSS.dev into the plugin &lt;a href=&quot;https://www.npmjs.com/package/@11tyrocks/eleventy-plugin-open-in-codepen&quot;&gt;&lt;code&gt;@11tyrocks/eleventy-plugin-open-in-codepen&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Here&#39;s an example of configuring the plugin:&lt;/p&gt;
&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; openInCodepen &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;require&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;@11tyrocks/eleventy-plugin-open-in-codepen&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;module&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function-variable function&quot;&gt;exports&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;eleventyConfig&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;  eleventyConfig&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;addPlugin&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;openInCodepen&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token literal-property property&quot;&gt;siteUrl&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;YourSite.dev&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token literal-property property&quot;&gt;siteTitle&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;Your Site&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token literal-property property&quot;&gt;siteTag&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;yoursite&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token literal-property property&quot;&gt;buttonClass&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;your-button-class&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token literal-property property&quot;&gt;buttonIconClass&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;your-button-icon-class&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Which would then make the shortcode &lt;code&gt;postToCodepen&lt;/code&gt; available within your partial. You can include the button with the following updates:&lt;/p&gt;
&lt;pre class=&quot;language-twig&quot;&gt;&lt;code class=&quot;language-twig&quot;&gt;// Set in your code demo file&lt;br /&gt;&lt;span class=&quot;token twig language-twig&quot;&gt;&lt;span class=&quot;token delimiter punctuation&quot;&gt;{%&lt;/span&gt; &lt;span class=&quot;token tag-name keyword&quot;&gt;set&lt;/span&gt; slug &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; page&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;url &lt;span class=&quot;token delimiter punctuation&quot;&gt;%}&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;// Add where you&#39;d like it to appear in the partial&lt;br /&gt;&lt;span class=&quot;token twig language-twig&quot;&gt;&lt;span class=&quot;token delimiter punctuation&quot;&gt;{%&lt;/span&gt; &lt;span class=&quot;token tag-name keyword&quot;&gt;postToCodepen&lt;/span&gt; title&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; slug&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; css&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; html &lt;span class=&quot;token delimiter punctuation&quot;&gt;%}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Here is a working example of the button created by the shortcode (and including customizations specific to 11ty Rocks!) that will export the demo that we set up in this tutorial:&lt;/p&gt;
&lt;form action=&quot;https://codepen.io/pen/define&quot; method=&quot;POST&quot; target=&quot;_blank&quot;&gt;
        &lt;input type=&quot;hidden&quot; name=&quot;data&quot; value=&#39;{&quot;title&quot;:&quot;11ty Rocks! - Demo Output&quot;,&quot;description&quot;:&quot;Generated from: 11ty.Rocks/posts/eleventy-templating-static-code-demos/&quot;,&quot;tags&quot;:[&quot;11tyrocks&quot;],&quot;editors&quot;:&quot;110&quot;,&quot;layout&quot;:&quot;left&quot;,&quot;html&quot;:&quot;&lt;!-- 11ty Rocks! - Demo Output\nGenerated from: 11ty.Rocks/posts/eleventy-templating-static-code-demos/ --&gt;\n\n&lt;div class=\&quot;centering\&quot;&gt;\n  &lt;span&gt;Feeling Centered&lt;/span&gt;\n&lt;/div&gt;\n&quot;,&quot;html_pre_processor&quot;:&quot;none&quot;,&quot;css&quot;:&quot;/* Box sizing rules */\n*,\n*::before,\n*::after {\n  box-sizing: border-box;\n}\n\n/* Remove default margin */\nbody,\nh1,\nh2,\nh3,\nh4,\np {\n  margin: 0;\n}\n\n/* Set core body defaults */\nbody {\n  min-height: 100vh;\n  text-rendering: optimizeSpeed;\n  line-height: 1.5;\n  font-family: system-ui, sans-serif;\n}\n\n/* Make images easier to work with */\nimg {\n  display: block;\n  max-width: 100%;\n}\n\n/***\n 🟣 11ty Rocks! Demo Styles\n */\n\n.centering {\n  display: grid;\n  place-content: center;\n  min-height: 30vh;\n}\n\n.centering span {\n  padding: .5em;\n  outline: 2px solid;\n}\n&quot;,&quot;css_pre_processor&quot;:&quot;scss&quot;,&quot;css_starter&quot;:&quot;neither&quot;,&quot;css_prefix&quot;:&quot;autoprefixer&quot;,&quot;head&quot;:&quot;&lt;meta name=&amp;apos;viewport&amp;apos; content=&amp;apos;width=device-width, initial-scale=1&amp;apos;&gt;&quot;}&#39; /&gt;
        &lt;button class=&quot;tdbc-button tdbc-button--secondary&quot; type=&quot;submit&quot; data-name=&quot;Demo Output&quot; aria-label=&quot;Open Demo Output in CodePen&quot;&gt;&lt;span class=&quot;tdbc-button__icon&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; viewBox=&quot;0 0 32 32&quot; aria-hidden=&quot;true&quot; focusable=&quot;false&quot;&gt;
      &lt;path d=&quot;M32 10.909l-0.024-0.116-0.023-0.067c-0.013-0.032-0.024-0.067-0.040-0.1-0.004-0.024-0.020-0.045-0.027-0.067l-0.047-0.089-0.040-0.067-0.059-0.080-0.061-0.060-0.080-0.060-0.061-0.040-0.080-0.059-0.059-0.053-0.020-0.027-14.607-9.772c-0.463-0.309-1.061-0.309-1.523 0l-14.805 9.883-0.051 0.053-0.067 0.075-0.049 0.060-0.067 0.080c-0.027 0.023-0.040 0.040-0.040 0.061l-0.067 0.080-0.027 0.080c-0.027 0.013-0.027 0.053-0.040 0.093l-0.013 0.067c-0.025 0.041-0.025 0.081-0.025 0.121v9.996c0 0.059 0.004 0.12 0.013 0.18l0.013 0.061c0.007 0.040 0.013 0.080 0.027 0.115l0.020 0.067c0.013 0.036 0.021 0.071 0.036 0.1l0.029 0.067c0 0.013 0.020 0.053 0.040 0.080l0.040 0.053c0.020 0.013 0.040 0.053 0.060 0.080l0.040 0.053 0.053 0.053c0.013 0.017 0.013 0.040 0.040 0.040l0.080 0.056 0.053 0.040 0.013 0.019 14.627 9.773c0.219 0.16 0.5 0.217 0.76 0.217s0.52-0.080 0.76-0.24l14.877-9.875 0.069-0.077 0.044-0.060 0.053-0.080 0.040-0.067 0.040-0.093 0.021-0.069 0.040-0.103 0.020-0.060 0.040-0.107v-10c0-0.067 0-0.127-0.021-0.187l-0.019-0.060 0.059 0.004zM16.013 19.283l-4.867-3.253 4.867-3.256 4.867 3.253-4.867 3.253zM14.635 10.384l-5.964 3.987-4.817-3.221 10.781-7.187v6.424zM6.195 16.028l-3.443 2.307v-4.601l3.443 2.301zM8.671 17.695l5.964 3.987v6.427l-10.781-7.188 4.824-3.223v-0.005zM17.387 21.681l5.965-3.973 4.817 3.227-10.783 7.187v-6.427zM25.827 16.041l3.444-2.293v4.608l-3.444-2.307zM23.353 14.388l-5.964-3.988v-6.44l10.78 7.187-4.816 3.224z&quot;&gt;&lt;/path&gt;
    &lt;/svg&gt;&lt;/span&gt; Open in CodePen&lt;/button&gt;
        &lt;/form&gt;
&lt;div class=&quot;heading-wrapper h2&quot;&gt;
&lt;h2 id=&quot;prevent-global-affects-on-demo-css&quot;&gt;Prevent Global Affects on Demo CSS&lt;/h2&gt;
&lt;a class=&quot;tdbc-anchor&quot; href=&quot;https://11ty.rocks/posts/eleventy-templating-static-code-demos/#prevent-global-affects-on-demo-css&quot; aria-labelledby=&quot;prevent-global-affects-on-demo-css&quot;&gt;&lt;span hidden=&quot;&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;If your use case is to populate demos within a context where you don&#39;t want your site&#39;s global CSS to cascade and affect your demo CSS, we can add a shortcode to help scope the styles.&lt;/p&gt;
&lt;p&gt;But first, here&#39;s a starting set of styles for our &lt;code&gt;.demo&lt;/code&gt; contents to reset most cascaded properties. You may find you need to add more properties here depending on what elements you are using in the demo. The goal is to prevent most global styles leaking through (and demo styles leaking out!) so that the demo styles are closer to being fresh from a native browser style base. If you are using a style reset, those rules may still come through for certain elements which is likely desireable.&lt;/p&gt;
&lt;pre class=&quot;language-css&quot;&gt;&lt;code class=&quot;language-css&quot;&gt;&lt;span class=&quot;token selector&quot;&gt;.demo *&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token property&quot;&gt;margin&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 0&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token property&quot;&gt;padding&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; unset&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token property&quot;&gt;border&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; unset&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token property&quot;&gt;border-radius&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; unset&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token property&quot;&gt;color&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; unset&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token property&quot;&gt;font&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; unset&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token property&quot;&gt;font-family&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; system-ui&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; sans-serif&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Next, we&#39;ll create the shortcode. A shortcode can output content, and we&#39;ll actually use it to output both the &lt;code&gt;&amp;lt;style&amp;gt;&lt;/code&gt; and &lt;code&gt;.demo&lt;/code&gt; blocks, replacing what we previously had for the HTML in the partial.&lt;/p&gt;
&lt;p&gt;Here is the content of the &lt;code&gt;codeDemo&lt;/code&gt; shortcode, which intakes the &lt;code&gt;css&lt;/code&gt; and &lt;code&gt;html&lt;/code&gt; (if available). Then it finds the CSS class names, and replaces them with a version that has a &amp;quot;hash&amp;quot; (just a simple random number string for this context). Following that, it traverses the HTML and updates the matched CSS class names so that the hashed CSS selector matches the demo HTML.&lt;/p&gt;
&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;eleventyConfig&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;addShortcode&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;codeDemo&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;css&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; html&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;!&lt;/span&gt;html&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;length&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;  &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;!&lt;/span&gt;css&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token template-string&quot;&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&lt;br /&gt;&amp;lt;div class=&quot;demo&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;${&lt;/span&gt;html&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&lt;br /&gt;&amp;lt;/div&gt;&lt;/span&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;  &lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; hash &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; Math&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;floor&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;Math&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;random&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;100&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;*&lt;/span&gt; Math&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;floor&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;999&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;  &lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; cssRE &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;RegExp&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token regex&quot;&gt;&lt;span class=&quot;token regex-delimiter&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;token regex-source language-regex&quot;&gt;(?&amp;lt;=\.)([\w|-]+)(?=\s|,)&lt;/span&gt;&lt;span class=&quot;token regex-delimiter&quot;&gt;/&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;gm&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; cssCode &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; css&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;replace&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;cssRE&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token template-string&quot;&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;$1-&lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;${&lt;/span&gt;hash&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;  &lt;span class=&quot;token keyword&quot;&gt;let&lt;/span&gt; htmlCode &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; html&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;  css&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;match&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;cssRE&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;forEach&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;match&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token comment&quot;&gt;// prettier-ignore&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; htmlPattern &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; match&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;replace&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;-&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;\\-&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; htmlRE &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;RegExp&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token template-string&quot;&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;${&lt;/span&gt;htmlPattern&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;)(?=\\s|&quot;)&lt;/span&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;gm&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    htmlCode &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; htmlCode&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;replace&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;htmlRE&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token template-string&quot;&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;${&lt;/span&gt;match&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;${&lt;/span&gt;hash&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;  &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token template-string&quot;&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&lt;br /&gt;&amp;lt;style&gt;&lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;${&lt;/span&gt;cssCode&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&amp;lt;/style&gt;&lt;br /&gt;&amp;lt;div class=&quot;demo&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;${&lt;/span&gt;htmlCode&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&lt;br /&gt;&amp;lt;/div&gt;&lt;/span&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;A couple notes:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;the indentation isn&#39;t an accident but necessary since we have setup our demo to process &lt;em&gt;both&lt;/em&gt; Markdown and Nunjucks, and if those blocks are indented it fouls up that processing&lt;/li&gt;
&lt;li&gt;this scoping method requires you to use class selectors, which means if you are using element selectors you will have to prefix them with a class which must exist in the passed HTML&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Then in the partial, remove our previous block that output the HTML &lt;code&gt;.demo&lt;/code&gt; and replace it with the following:&lt;/p&gt;
&lt;pre class=&quot;language-twig&quot;&gt;&lt;code class=&quot;language-twig&quot;&gt;&lt;span class=&quot;token twig language-twig&quot;&gt;&lt;span class=&quot;token delimiter punctuation&quot;&gt;{%&lt;/span&gt; &lt;span class=&quot;token tag-name keyword&quot;&gt;set&lt;/span&gt; htmlCode &lt;span class=&quot;token delimiter punctuation&quot;&gt;%}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token twig language-twig&quot;&gt;&lt;span class=&quot;token delimiter punctuation&quot;&gt;{{&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&#39;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; hideDemo else html &lt;span class=&quot;token operator&quot;&gt;|&lt;/span&gt; safe &lt;span class=&quot;token delimiter punctuation&quot;&gt;}}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token twig language-twig&quot;&gt;&lt;span class=&quot;token delimiter punctuation&quot;&gt;{%&lt;/span&gt; &lt;span class=&quot;token tag-name keyword&quot;&gt;endset&lt;/span&gt; &lt;span class=&quot;token delimiter punctuation&quot;&gt;%}&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token twig language-twig&quot;&gt;&lt;span class=&quot;token delimiter punctuation&quot;&gt;{%&lt;/span&gt; &lt;span class=&quot;token tag-name keyword&quot;&gt;codeDemo&lt;/span&gt; css&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; htmlCode &lt;span class=&quot;token delimiter punctuation&quot;&gt;%}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This still takes into account the &lt;em&gt;option&lt;/em&gt; to hide the demo.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Important note about Nunjucks variables&lt;/strong&gt;: They will pass through multiple instances of a partial if you include the partial multiple times within one file. If you are writing a tutorial and set the &lt;code&gt;html&lt;/code&gt; variable at the top of the file, you can repeatedly update the &lt;code&gt;css&lt;/code&gt; variable only prior to including the partial again and it will use the original HTML up until you update the &lt;code&gt;html&lt;/code&gt; variable. This is super useful for tutorials showing how to progressively build something. In fact, this technique was created for exactly that purpose over on this &lt;a href=&quot;https://moderncss.dev/developing-for-imperfect-future-proofing-css-styles/&quot;&gt;tutorial for ModernCSS.dev&lt;/a&gt;.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Phew! That was a lot to learn about Nunjucks templating 😊 I&#39;d love to know if this was helpful to you and see what you make with it! Reach out to &lt;a href=&quot;https://twitter.com/5t3ph&quot;&gt;@5t3ph on Twitter&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;
</content>
	</entry>
	
	
	<entry>
		<title>A Deep Dive Into Eleventy Static Site Generator</title>
		<link href="https://11ty.rocks/posts/deep-dive-eleventy-static-site-generator/"/>
		<updated>2021-03-24T00:00:00Z</updated>
		<id>https://11ty.rocks/posts/deep-dive-eleventy-static-site-generator/</id>
		<content type="html">&lt;blockquote&gt;
&lt;p&gt;&lt;a href=&quot;https://11ty.dev/&quot;&gt;Eleventy (aka 11ty)&lt;/a&gt; is rising in the ranks among static site generators. This Node-based builder is attractive due to its zero-config starting point, purely static output, and ease of achieving the coveted top Lighthouse performance score of four perfect 100s.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;In my article on Smashing Magazine, I&#39;ve written about things that I would have found helpful to understand when I was getting started with Eleventy. It covers:&lt;/p&gt;
&lt;!-- prettier-ignore --&gt;
&lt;ul&gt;
&lt;li&gt;A brief intro to static site generators (SSG)&lt;/li&gt;
&lt;li&gt;What makes it unique from other SSG&lt;/li&gt;
&lt;li&gt;Getting started&lt;/li&gt;
&lt;li&gt;Layouts&lt;/li&gt;
&lt;li&gt;Templates&lt;/li&gt;
&lt;li&gt;Filters&lt;/li&gt;
&lt;li&gt;Shortcodes&lt;/li&gt;
&lt;li&gt;Collections&lt;/li&gt;
&lt;li&gt;Custom data&lt;/li&gt;
&lt;li&gt;Pagination&lt;/li&gt;
&lt;li&gt;Eleventy plugins&lt;/li&gt;
&lt;li&gt;Starters&lt;/li&gt;
&lt;li&gt;Is Eleventy a right fit for you and your project&lt;/li&gt;
&lt;/ul&gt;
&lt;blockquote&gt;
&lt;p&gt;Read the rest of &lt;em&gt;&lt;a href=&quot;https://www.smashingmagazine.com/2021/03/eleventy-static-site-generator/&quot;&gt;A Deep Dive Into Eleventy Static Site Generator&lt;/a&gt;&lt;/em&gt; on Smashing Magazine&lt;/p&gt;
&lt;/blockquote&gt;
</content>
	</entry>
	
	
	<entry>
		<title>Essential Navigation Snippet</title>
		<link href="https://11ty.rocks/tips/essential-navigation-snippet/"/>
		<updated>2021-03-09T00:00:00Z</updated>
		<id>https://11ty.rocks/tips/essential-navigation-snippet/</id>
		<content type="html">&lt;p&gt;The following snippet uses Nunjucks and could be added directly in a layout, or created as a layout partial - ex: &lt;code&gt;nav.njk&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;First, we set the variable of &lt;code&gt;currentUrl&lt;/code&gt; to contain the current page URL, and if it matches the the nav item&#39;s URL, we add the appropriate aria to identify it as the current page.&lt;/p&gt;
&lt;p&gt;In this example we are looping through the &lt;code&gt;pages&lt;/code&gt; collection, which you may need to adjust to match your desired navigation content.&lt;/p&gt;
&lt;pre class=&quot;language-twig&quot;&gt;&lt;code class=&quot;language-twig&quot;&gt;&lt;br /&gt;&lt;span class=&quot;token twig language-twig&quot;&gt;&lt;span class=&quot;token delimiter punctuation&quot;&gt;{%&lt;/span&gt; &lt;span class=&quot;token tag-name keyword&quot;&gt;set&lt;/span&gt; currentUrl &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; page&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;url &lt;span class=&quot;token delimiter punctuation&quot;&gt;%}&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;nav&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;ul&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;role&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;list&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;li&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;a&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;&lt;span class=&quot;token twig language-twig&quot;&gt;&lt;span class=&quot;token delimiter punctuation&quot;&gt;{%&lt;/span&gt; &lt;span class=&quot;token tag-name keyword&quot;&gt;if&lt;/span&gt; currentUrl &lt;span class=&quot;token operator&quot;&gt;==&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&#39;&lt;/span&gt;/&lt;span class=&quot;token punctuation&quot;&gt;&#39;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token delimiter punctuation&quot;&gt;%}&lt;/span&gt;&lt;/span&gt;aria-current&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;page&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token attr-name&quot;&gt;&lt;span class=&quot;token twig language-twig&quot;&gt;&lt;span class=&quot;token delimiter punctuation&quot;&gt;{%&lt;/span&gt; &lt;span class=&quot;token tag-name keyword&quot;&gt;endif&lt;/span&gt; &lt;span class=&quot;token delimiter punctuation&quot;&gt;%}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;href&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;/&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;Home&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;a&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;li&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    &lt;span class=&quot;token twig language-twig&quot;&gt;&lt;span class=&quot;token delimiter punctuation&quot;&gt;{%&lt;/span&gt; &lt;span class=&quot;token tag-name keyword&quot;&gt;for&lt;/span&gt; link &lt;span class=&quot;token operator&quot;&gt;in&lt;/span&gt; collections&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;pages &lt;span class=&quot;token delimiter punctuation&quot;&gt;%}&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;li&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;a&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token attr-name&quot;&gt;&lt;span class=&quot;token twig language-twig&quot;&gt;&lt;span class=&quot;token delimiter punctuation&quot;&gt;{%&lt;/span&gt; &lt;span class=&quot;token tag-name keyword&quot;&gt;if&lt;/span&gt; currentUrl &lt;span class=&quot;token operator&quot;&gt;==&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; link&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;url &lt;span class=&quot;token delimiter punctuation&quot;&gt;%}&lt;/span&gt;&lt;/span&gt;aria-current&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;page&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token attr-name&quot;&gt;&lt;span class=&quot;token twig language-twig&quot;&gt;&lt;span class=&quot;token delimiter punctuation&quot;&gt;{%&lt;/span&gt; &lt;span class=&quot;token tag-name keyword&quot;&gt;endif&lt;/span&gt; &lt;span class=&quot;token delimiter punctuation&quot;&gt;%}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token attr-name&quot;&gt;href&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;token twig language-twig&quot;&gt;&lt;span class=&quot;token delimiter punctuation&quot;&gt;{{&lt;/span&gt; link&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;url &lt;span class=&quot;token delimiter punctuation&quot;&gt;}}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;          &lt;span class=&quot;token twig language-twig&quot;&gt;&lt;span class=&quot;token delimiter punctuation&quot;&gt;{{&lt;/span&gt; link&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;data&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;title &lt;span class=&quot;token delimiter punctuation&quot;&gt;}}&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;a&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;li&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token twig language-twig&quot;&gt;&lt;span class=&quot;token delimiter punctuation&quot;&gt;{%-&lt;/span&gt; &lt;span class=&quot;token tag-name keyword&quot;&gt;endfor&lt;/span&gt; &lt;span class=&quot;token delimiter punctuation&quot;&gt;%}&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;ul&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;nav&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;blockquote&gt;
&lt;p&gt;This navigation strategy is in use for my &lt;a href=&quot;https://smol-11ty-starter.netlify.app/&quot;&gt;Smol 11ty Starter&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;&lt;strong&gt;Bonus tip&lt;/strong&gt;: Attach styles to the current item by using the CSS selector &lt;code&gt;[aria-current=&amp;quot;page&amp;quot;]&lt;/code&gt; to for example bold the current item, or change its color.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;For deeper hierarchies and more complex navigation, you may want to use the official plugin: &lt;a href=&quot;https://11ty.rocks/tips/essential-navigation-snippet/&quot;&gt;&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;
</content>
	</entry>
	
	
	<entry>
		<title>Smol 11ty Starter</title>
		<link href="https://github.com/5t3ph/smol-11ty-starter"/>
		<updated>2021-03-09T00:00:00Z</updated>
		<id>https://github.com/5t3ph/smol-11ty-starter</id>
		<content type="html">&lt;p&gt;An extremely minimal Eleventy starter to kickstart a simple multi-page site that provides a nearly opinionless foundation to continue building on.&lt;/p&gt;
&lt;p&gt;You can &lt;a href=&quot;https://smol-11ty-starter.netlify.app/&quot;&gt;preview this starter&lt;/a&gt; or jump right to the repo.&lt;/p&gt;
&lt;a href=&quot;https://github.com/5t3ph/smol-11ty-starter&quot;&gt;Use Smol Starter&lt;/a&gt;</content>
	</entry>
	
	
	<entry>
		<title>Custom BrowserSync Options</title>
		<link href="https://11ty.rocks/eleventyjs/browsersync/"/>
		<updated>2021-02-25T00:00:00Z</updated>
		<id>https://11ty.rocks/eleventyjs/browsersync/</id>
		<content type="html">&lt;div class=&quot;heading-wrapper h2&quot;&gt;
&lt;h2 id=&quot;including-opening-a-browser-on-launch&quot;&gt;Including Opening a Browser on Launch&lt;/h2&gt;
&lt;a class=&quot;tdbc-anchor&quot; href=&quot;https://11ty.rocks/eleventyjs/browsersync/#including-opening-a-browser-on-launch&quot; aria-labelledby=&quot;including-opening-a-browser-on-launch&quot;&gt;&lt;span hidden=&quot;&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;By default, Eleventy has the BrowserSync option to open a browser set to &lt;code&gt;false&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Fortunately, it also provides a way to override the BrowserSync settings, so we can allow opening a browser with the following:&lt;/p&gt;
&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;eleventyConfig&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;setBrowserSyncConfig&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token literal-property property&quot;&gt;open&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token boolean&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;If you use VSCode, you may also be interested in &lt;a href=&quot;https://dev.to/5t3ph/automatically-start-scripts-on-launch-in-vscode-6ak&quot;&gt;creating a launch task&lt;/a&gt; to enable running your Eleventy start command when you open your project.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Review the &lt;a href=&quot;https://www.11ty.dev/docs/watch-serve/#override-browsersync-server-options&quot;&gt;official 11ty docs on BrowserSync&lt;/a&gt; for more info.&lt;/p&gt;
&lt;/blockquote&gt;
</content>
	</entry>
	
	
	<entry>
		<title>11ty.Rocks on Youtube</title>
		<link href="https://www.youtube.com/channel/UCTuSQg_Ol4shhSYQ1EfpHiQ?sub_confirmation=1"/>
		<updated>2021-02-20T00:00:00Z</updated>
		<id>https://www.youtube.com/channel/UCTuSQg_Ol4shhSYQ1EfpHiQ?sub_confirmation=1</id>
		<content type="html">&lt;p&gt;11ty Rocks is now on YouTube! Subscribe today so you don&#39;t miss a video. Content will be in support of topics explored here on 11ty.Rocks.&lt;/p&gt;
&lt;a href=&quot;https://www.youtube.com/channel/UCTuSQg_Ol4shhSYQ1EfpHiQ?sub_confirmation=1&quot;&gt;Subscribe to 11ty Rocks&lt;/a&gt;</content>
	</entry>
	
	
	<entry>
		<title>VSCode Settings</title>
		<link href="https://11ty.rocks/tips/vscode/"/>
		<updated>2021-02-15T00:00:00Z</updated>
		<id>https://11ty.rocks/tips/vscode/</id>
		<content type="html">&lt;blockquote&gt;
&lt;p&gt;The following are intended to be added within your VSCode &lt;code&gt;settings.json&lt;/code&gt;.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;div class=&quot;heading-wrapper h2&quot;&gt;
&lt;h2 id=&quot;extend-emmet-for-nunjucks&quot;&gt;Extend Emmet for Nunjucks&lt;/h2&gt;
&lt;a class=&quot;tdbc-anchor&quot; href=&quot;https://11ty.rocks/tips/vscode/#extend-emmet-for-nunjucks&quot; aria-labelledby=&quot;extend-emmet-for-nunjucks&quot;&gt;&lt;span hidden=&quot;&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;There are two steps to getting Emmet to work for Nunjucks.&lt;/p&gt;
&lt;p&gt;First, if you haven&#39;t already, install the &lt;a href=&quot;https://marketplace.visualstudio.com/items?itemName=ronnidc.nunjucks&quot;&gt;Nunjucks syntax highlighting extension&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Next, add the following to specifically extend Emmet to Nunjucks:&lt;/p&gt;
&lt;pre class=&quot;language-json&quot;&gt;&lt;code class=&quot;language-json&quot;&gt;&lt;span class=&quot;token property&quot;&gt;&quot;emmet.includeLanguages&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token property&quot;&gt;&quot;nunjucks&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;html&quot;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;blockquote&gt;
&lt;p&gt;You can also use this setting to extend to Liquid or other file types.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;div class=&quot;heading-wrapper h2&quot;&gt;
&lt;h2 id=&quot;language-specific-editor-settings&quot;&gt;Language Specific Editor Settings&lt;/h2&gt;
&lt;a class=&quot;tdbc-anchor&quot; href=&quot;https://11ty.rocks/tips/vscode/#language-specific-editor-settings&quot; aria-labelledby=&quot;language-specific-editor-settings&quot;&gt;&lt;span hidden=&quot;&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;For myself, I have the following overrides for Markdown and Nunjucks which override my standard setting of &lt;code&gt;80&lt;/code&gt; characters per column:&lt;/p&gt;
&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token string-property property&quot;&gt;&quot;[markdown]&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token string-property property&quot;&gt;&quot;editor.wordWrapColumn&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;100&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token string-property property&quot;&gt;&quot;editor.wordWrap&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;bounded&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token comment&quot;&gt;// Turned off to prevent Emmet when writing code fenced blocks&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token string-property property&quot;&gt;&quot;editor.quickSuggestions&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token boolean&quot;&gt;false&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token string-property property&quot;&gt;&quot;[nunjucks]&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token string-property property&quot;&gt;&quot;editor.wordWrapColumn&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;100&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token string-property property&quot;&gt;&quot;editor.wordWrap&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;bounded&quot;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;blockquote&gt;
&lt;p&gt;You can extend these to other templating languages you may be using.&lt;/p&gt;
&lt;/blockquote&gt;
</content>
	</entry>
	
	
	<entry>
		<title>Site Metadata</title>
		<link href="https://11ty.rocks/tips/site-metadata/"/>
		<updated>2021-02-15T00:00:00Z</updated>
		<id>https://11ty.rocks/tips/site-metadata/</id>
		<content type="html">&lt;p&gt;The &lt;code&gt;_data&lt;/code&gt; directory is an expected location for various data sources for your Eleventy site.&lt;/p&gt;
&lt;p&gt;A convention you&#39;ll see variations of in several starters is a data file to hold site metadata. This concept is useful for creating extendable solutions so that certain template bits don&#39;t need repeated or started from scratch everytime.&lt;/p&gt;
&lt;p&gt;Here&#39;s the one that&#39;s included in my &lt;a href=&quot;https://11ty-netlify-jumpstart.netlify.app/&quot;&gt;11ty Netlify Jumpstart&lt;/a&gt; which you can adapt to your own needs:&lt;/p&gt;
&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;// Located in _data/meta.js&lt;/span&gt;&lt;br /&gt;module&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;exports &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token comment&quot;&gt;// NOTE: `process.env.URL` is provided by Netlify, and may need&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token comment&quot;&gt;// adjusted pending your host&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token literal-property property&quot;&gt;url&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; process&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;env&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token constant&quot;&gt;URL&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;||&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;http://localhost:8080&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token literal-property property&quot;&gt;siteName&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token literal-property property&quot;&gt;siteDescription&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token literal-property property&quot;&gt;authorName&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token literal-property property&quot;&gt;twitterUsername&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// no `@`&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Then, you can access that data in templates and content by using the filename first, followed by the data key of what you&#39;d like using dot notation.&lt;/p&gt;
&lt;p&gt;For example, if I wanted the &lt;code&gt;siteName&lt;/code&gt; I could access it within Nunjucks as:&lt;/p&gt;
&lt;pre class=&quot;language-twig&quot;&gt;&lt;code class=&quot;language-twig&quot;&gt;&lt;span class=&quot;token twig language-twig&quot;&gt;&lt;span class=&quot;token delimiter punctuation&quot;&gt;{{&lt;/span&gt; meta&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;siteName &lt;span class=&quot;token delimiter punctuation&quot;&gt;}}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;blockquote&gt;
&lt;p&gt;See this idea in use for the &lt;a href=&quot;https://github.com/5t3ph/11ty-netlify-jumpstart/blob/main/src/_includes/base.njk&quot;&gt;11ty Netlify Jumpstart &lt;code&gt;base&lt;/code&gt; template&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;
</content>
	</entry>
	
	
	<entry>
		<title>Modifying Permalinks</title>
		<link href="https://11ty.rocks/tips/permalinks/"/>
		<updated>2021-02-15T00:00:00Z</updated>
		<id>https://11ty.rocks/tips/permalinks/</id>
		<content type="html">&lt;blockquote&gt;
&lt;p&gt;Often permalinks are changed via front matter, but you may wish to apply permalink changes in a &lt;a href=&quot;https://11ty.rocks/tips/data-directory-file/&quot;&gt;directory data file&lt;/a&gt; so that the change will apply to all content within a directory at once.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;div class=&quot;heading-wrapper h2&quot;&gt;
&lt;h2 id=&quot;remove-directory-prefix&quot;&gt;Remove Directory Prefix&lt;/h2&gt;
&lt;a class=&quot;tdbc-anchor&quot; href=&quot;https://11ty.rocks/tips/permalinks/#remove-directory-prefix&quot; aria-labelledby=&quot;remove-directory-prefix&quot;&gt;&lt;span hidden=&quot;&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;As noted in the &lt;a href=&quot;https://11ty.rocks/tips/data-directory-file/&quot;&gt;directory data file tips&lt;/a&gt;, you may wish for content contained in a directory to actually appear to live off of root:&lt;/p&gt;
&lt;pre class=&quot;language-twig&quot;&gt;&lt;code class=&quot;language-twig&quot;&gt;permalink: &quot;/&lt;span class=&quot;token twig language-twig&quot;&gt;&lt;span class=&quot;token delimiter punctuation&quot;&gt;{{&lt;/span&gt; page&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;fileSlug &lt;span class=&quot;token delimiter punctuation&quot;&gt;}}&lt;/span&gt;&lt;/span&gt;/&quot;&lt;/code&gt;&lt;/pre&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;code&gt;page&lt;/code&gt; is provided by 11ty and you can learn more about the &lt;a href=&quot;https://www.11ty.dev/docs/data-eleventy-supplied/&quot;&gt;page variable in the official docs&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;div class=&quot;heading-wrapper h2&quot;&gt;
&lt;h2 id=&quot;add-date&quot;&gt;Add Date&lt;/h2&gt;
&lt;a class=&quot;tdbc-anchor&quot; href=&quot;https://11ty.rocks/tips/permalinks/#add-date&quot; aria-labelledby=&quot;add-date&quot;&gt;&lt;span hidden=&quot;&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;The following will keep the existing structure based on directory location (provided by &lt;code&gt;page.filePathStem&lt;/code&gt;), but prepend it with the content&#39;s &lt;code&gt;date&lt;/code&gt;:&lt;/p&gt;
&lt;pre class=&quot;language-twig&quot;&gt;&lt;code class=&quot;language-twig&quot;&gt;permalink: &quot;/&lt;span class=&quot;token twig language-twig&quot;&gt;&lt;span class=&quot;token delimiter punctuation&quot;&gt;{{&lt;/span&gt; page&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;date &lt;span class=&quot;token delimiter punctuation&quot;&gt;}}&lt;/span&gt;&lt;/span&gt;/&lt;span class=&quot;token twig language-twig&quot;&gt;&lt;span class=&quot;token delimiter punctuation&quot;&gt;{{&lt;/span&gt; page&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;filePathStem &lt;span class=&quot;token delimiter punctuation&quot;&gt;}}&lt;/span&gt;&lt;/span&gt;/&quot;&lt;/code&gt;&lt;/pre&gt;
&lt;blockquote&gt;
&lt;p&gt;Take a minute to learn about &lt;a href=&quot;https://www.11ty.dev/docs/dates/&quot;&gt;date handling in 11ty&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;div class=&quot;heading-wrapper h2&quot;&gt;
&lt;h2 id=&quot;create-permalink-from-title&quot;&gt;Create Permalink From Title&lt;/h2&gt;
&lt;a class=&quot;tdbc-anchor&quot; href=&quot;https://11ty.rocks/tips/permalinks/#create-permalink-from-title&quot; aria-labelledby=&quot;create-permalink-from-title&quot;&gt;&lt;span hidden=&quot;&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;You may want to use your post title for creating the permalink instead of the default of the file path/filename.&lt;/p&gt;
&lt;p&gt;Conveniently, front matter data is available to &lt;code&gt;permalink&lt;/code&gt; so you can actually use &lt;em&gt;any&lt;/em&gt; front matter to modify the permalinks structure.&lt;/p&gt;
&lt;p&gt;However - you need to use it alongside the &lt;code&gt;slug&lt;/code&gt; filter to ensure it&#39;s URL-formatted.&lt;/p&gt;
&lt;pre class=&quot;language-twig&quot;&gt;&lt;code class=&quot;language-twig&quot;&gt;permalink: &quot;/&lt;span class=&quot;token twig language-twig&quot;&gt;&lt;span class=&quot;token delimiter punctuation&quot;&gt;{{&lt;/span&gt; title &lt;span class=&quot;token operator&quot;&gt;|&lt;/span&gt; slug &lt;span class=&quot;token delimiter punctuation&quot;&gt;}}&lt;/span&gt;&lt;/span&gt;/&quot;&lt;/code&gt;&lt;/pre&gt;
&lt;blockquote&gt;
&lt;p&gt;If you tend to use code formatting or perhaps emojis in your titles (like I do) you may want to &lt;a href=&quot;https://11ty.rocks/eleventyjs/slugs-anchors/#slug-filter-extension&quot;&gt;modify the &lt;code&gt;slug&lt;/code&gt; filter&lt;/a&gt;.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;div class=&quot;heading-wrapper h2&quot;&gt;
&lt;h2 id=&quot;excluding-and-moving-content&quot;&gt;Excluding and Moving Content&lt;/h2&gt;
&lt;a class=&quot;tdbc-anchor&quot; href=&quot;https://11ty.rocks/tips/permalinks/#excluding-and-moving-content&quot; aria-labelledby=&quot;excluding-and-moving-content&quot;&gt;&lt;span hidden=&quot;&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;Permalinks can also be used to &lt;a href=&quot;https://11ty.rocks/tips/excluding-content-output/&quot;&gt;prevent content output&lt;/a&gt;, or &lt;a href=&quot;https://11ty.rocks/tips/changing-content-output/&quot;&gt;change it&#39;s location&lt;/a&gt;.&lt;/p&gt;
</content>
	</entry>
	
	
	<entry>
		<title>Excluding Content Output</title>
		<link href="https://11ty.rocks/tips/excluding-content-output/"/>
		<updated>2021-02-15T00:00:00Z</updated>
		<id>https://11ty.rocks/tips/excluding-content-output/</id>
		<content type="html">&lt;div class=&quot;heading-wrapper h2&quot;&gt;
&lt;h2 id=&quot;prevent-page-generation-output&quot;&gt;Prevent Page Generation Output&lt;/h2&gt;
&lt;a class=&quot;tdbc-anchor&quot; href=&quot;https://11ty.rocks/tips/excluding-content-output/#prevent-page-generation-output&quot; aria-labelledby=&quot;prevent-page-generation-output&quot;&gt;&lt;span hidden=&quot;&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;Sometimes you may want to create content using your preferred templating language but not actually output an individual page.&lt;/p&gt;
&lt;p&gt;The preferred way to do this is via permalink:&lt;/p&gt;
&lt;pre class=&quot;language-md&quot;&gt;&lt;code class=&quot;language-md&quot;&gt;permalink: false&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;If you want this to apply to an entire collection, you can do this in a &lt;a href=&quot;https://11ty.rocks/tips/data-directory-file&quot;&gt;directory data file&lt;/a&gt;. This example is used for this very site to create the resource content on the home page:&lt;/p&gt;
&lt;pre class=&quot;language-json&quot;&gt;&lt;code class=&quot;language-json&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token property&quot;&gt;&quot;tags&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;resources&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token property&quot;&gt;&quot;permalink&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token boolean&quot;&gt;false&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;blockquote&gt;
&lt;p&gt;Read more about &lt;a href=&quot;https://www.11ty.dev/docs/permalinks/#permalink-false&quot;&gt;setting permalink to &lt;code&gt;false&lt;/code&gt;&lt;/a&gt; in the official docs&lt;/p&gt;
&lt;/blockquote&gt;
&lt;div class=&quot;heading-wrapper h2&quot;&gt;
&lt;h2 id=&quot;excluding-content-from-collections&quot;&gt;Excluding Content From Collections&lt;/h2&gt;
&lt;a class=&quot;tdbc-anchor&quot; href=&quot;https://11ty.rocks/tips/excluding-content-output/#excluding-content-from-collections&quot; aria-labelledby=&quot;excluding-content-from-collections&quot;&gt;&lt;span hidden=&quot;&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;Within a directory intended to be content for a collection, you may have content, such as the index, that you do not want included in the collection itself.&lt;/p&gt;
&lt;p&gt;To &lt;em&gt;entirely&lt;/em&gt; exclude the content from &lt;em&gt;any&lt;/em&gt; collection, set &lt;code&gt;eleventyExcludeFromCollections&lt;/code&gt; to &lt;code&gt;true&lt;/code&gt;:&lt;/p&gt;
&lt;pre class=&quot;language-md&quot;&gt;&lt;code class=&quot;language-md&quot;&gt;eleventyExcludeFromCollections: true&lt;/code&gt;&lt;/pre&gt;
</content>
	</entry>
	
	
	<entry>
		<title>Directory Data File</title>
		<link href="https://11ty.rocks/tips/data-directory-file/"/>
		<updated>2021-02-15T00:00:00Z</updated>
		<id>https://11ty.rocks/tips/data-directory-file/</id>
		<content type="html">&lt;div class=&quot;heading-wrapper h2&quot;&gt;
&lt;h2 id=&quot;create-a-directory-data-file&quot;&gt;Create a Directory Data File&lt;/h2&gt;
&lt;a class=&quot;tdbc-anchor&quot; href=&quot;https://11ty.rocks/tips/data-directory-file/#create-a-directory-data-file&quot; aria-labelledby=&quot;create-a-directory-data-file&quot;&gt;&lt;span hidden=&quot;&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;To create a directory data file, add a &lt;code&gt;json&lt;/code&gt; file within your directory with the same name as the directory.&lt;/p&gt;
&lt;p&gt;For example, within &lt;code&gt;/posts/&lt;/code&gt; create &lt;code&gt;posts.json&lt;/code&gt;.&lt;/p&gt;
&lt;div class=&quot;heading-wrapper h2&quot;&gt;
&lt;h2 id=&quot;assign-tags-and-layout&quot;&gt;Assign Tags and Layout&lt;/h2&gt;
&lt;a class=&quot;tdbc-anchor&quot; href=&quot;https://11ty.rocks/tips/data-directory-file/#assign-tags-and-layout&quot; aria-labelledby=&quot;assign-tags-and-layout&quot;&gt;&lt;span hidden=&quot;&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;Most often, I use directory data files to quickly create collections via &lt;code&gt;tags&lt;/code&gt; and also to assign all the directory content to a layout.&lt;/p&gt;
&lt;pre class=&quot;language-json&quot;&gt;&lt;code class=&quot;language-json&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token property&quot;&gt;&quot;tags&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;posts&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token property&quot;&gt;&quot;layout&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;post&quot;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;blockquote&gt;
&lt;p&gt;If needed, you can still override these values within the front matter of individual files.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;div class=&quot;heading-wrapper h2&quot;&gt;
&lt;h2 id=&quot;change-permalink-structure&quot;&gt;Change Permalink Structure&lt;/h2&gt;
&lt;a class=&quot;tdbc-anchor&quot; href=&quot;https://11ty.rocks/tips/data-directory-file/#change-permalink-structure&quot; aria-labelledby=&quot;change-permalink-structure&quot;&gt;&lt;span hidden=&quot;&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;Another very handy feature is the ability to change the &lt;code&gt;permalink&lt;/code&gt; structure for all content within directory.&lt;/p&gt;
&lt;p&gt;Here&#39;s one example of assigning content to live off the root instead of retaining the directory as a prefix:&lt;/p&gt;
&lt;pre class=&quot;language-json&quot;&gt;&lt;code class=&quot;language-json&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token property&quot;&gt;&quot;permalink&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;/{{ {{ page.fileSlug }} }}&quot;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;blockquote&gt;
&lt;p&gt;Review more &lt;a href=&quot;https://11ty.rocks/tips/permalinks/&quot;&gt;permalink structure tips&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;
</content>
	</entry>
	
	
	<entry>
		<title>Changing Content Output</title>
		<link href="https://11ty.rocks/tips/changing-content-output/"/>
		<updated>2021-02-15T00:00:00Z</updated>
		<id>https://11ty.rocks/tips/changing-content-output/</id>
		<content type="html">&lt;blockquote&gt;
&lt;p&gt;The following techniques are applied via front matter.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;The &lt;strong&gt;base file&lt;/strong&gt; that you are using to create the altered content can use any of Eleventy&#39;s templating languages, and use all the features that language provides. For example, you could use Nunjucks or Liquid and loop through a collection to create JSON output.&lt;/p&gt;
&lt;div class=&quot;heading-wrapper h2&quot;&gt;
&lt;h2 id=&quot;change-contents-output-file-type&quot;&gt;Change Content&#39;s Output File Type&lt;/h2&gt;
&lt;a class=&quot;tdbc-anchor&quot; href=&quot;https://11ty.rocks/tips/changing-content-output/#change-contents-output-file-type&quot; aria-labelledby=&quot;change-contents-output-file-type&quot;&gt;&lt;span hidden=&quot;&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;One of Eleventy&#39;s super powers that allows you to &lt;a href=&quot;https://11ty.rocks/posts/going-beyond-static-with-eleventy/&quot;&gt;exceed the traditional limits of static&lt;/a&gt; is in using templating to create &lt;em&gt;any&lt;/em&gt; file type output.&lt;/p&gt;
&lt;p&gt;This is often used to create &lt;a href=&quot;https://github.com/5t3ph/11ty-netlify-jumpstart/blob/main/src/_generate/sitemap.njk&quot;&gt;sitemaps&lt;/a&gt; and &lt;a href=&quot;https://github.com/5t3ph/11ty-netlify-jumpstart/blob/main/src/_generate/feed.njk&quot;&gt;RSS feeds&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Changing the file type is done by simply appending the desired extension via the &lt;code&gt;permalink&lt;/code&gt;:&lt;/p&gt;
&lt;pre class=&quot;language-twig&quot;&gt;&lt;code class=&quot;language-twig&quot;&gt;permalink: &quot;/&lt;span class=&quot;token twig language-twig&quot;&gt;&lt;span class=&quot;token delimiter punctuation&quot;&gt;{{&lt;/span&gt; page&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;fileSlug &lt;span class=&quot;token delimiter punctuation&quot;&gt;}}&lt;/span&gt;&lt;/span&gt;.txt&quot;&lt;/code&gt;&lt;/pre&gt;
&lt;blockquote&gt;
&lt;p&gt;Learn more &lt;a href=&quot;https://11ty.rocks/tips/permalinks/&quot;&gt;tips for constructing permalinks&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;div class=&quot;heading-wrapper h2&quot;&gt;
&lt;h2 id=&quot;output-content-outside-the-eleventy-filesystem&quot;&gt;Output Content Outside the Eleventy Filesystem&lt;/h2&gt;
&lt;a class=&quot;tdbc-anchor&quot; href=&quot;https://11ty.rocks/tips/changing-content-output/#output-content-outside-the-eleventy-filesystem&quot; aria-labelledby=&quot;output-content-outside-the-eleventy-filesystem&quot;&gt;&lt;span hidden=&quot;&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;This is again done via &lt;code&gt;permalink&lt;/code&gt;, and requires also setting &lt;code&gt;permalinkBypassOutputDir: true&lt;/code&gt; which allows making our permalink relative to &lt;em&gt;the project root&lt;/em&gt; using &lt;code&gt;./&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&quot;language-md&quot;&gt;&lt;code class=&quot;language-md&quot;&gt;permalink: ./functions/{{ page.fileSlug }}.txt&lt;br /&gt;permalinkBypassOutputDir: true&lt;br /&gt;eleventyExcludeFromCollections: true&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Notice we&#39;re also excluding it from all collections since we are intentionally creating it for purposes outside of our main site structure.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;This technique is used to create page data for use by my &lt;a href=&quot;https://www.npmjs.com/package/@11tyrocks/eleventy-plugin-social-images&quot;&gt;social image plugin&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;
</content>
	</entry>
	
	
	<entry>
		<title>Single-Page Setup &lt;small&gt;(recorded livestream)&lt;/small&gt;</title>
		<link href="https://www.youtube.com/watch?v=nIiOwNb7KR4"/>
		<updated>2021-02-15T00:00:00Z</updated>
		<id>https://www.youtube.com/watch?v=nIiOwNb7KR4</id>
		<content type="html">&lt;p&gt;I joined &lt;a href=&quot;https://twitter.com/colbyfayock&quot;&gt;Colby Fayock&lt;/a&gt; on Twitch in a slightly chaotic hour where I began building &lt;a href=&quot;https://smolcss.dev/&quot;&gt;SmolCSS.dev&lt;/a&gt; with Eleventy.&lt;/p&gt;
&lt;p&gt;Check out the recording and learn more about setting up Eleventy content for use in a single-page site, including advanced template and layout features using Nunjucks.&lt;/p&gt;
&lt;a href=&quot;https://www.youtube.com/watch?v=nIiOwNb7KR4&quot;&gt;Watch Recording&lt;/a&gt;</content>
	</entry>
	
	
	<entry>
		<title>11ty Quick Tips</title>
		<link href="/tips/"/>
		<updated>2021-02-15T00:00:00Z</updated>
		<id>/tips/</id>
		<content type="html">&lt;p&gt;Useful snippets and ideas for managing and creating 11ty projects.&lt;/p&gt;
&lt;p&gt;Includes tips on VSCode settings, site metadata, permalinks, and more!&lt;/p&gt;
&lt;a href=&quot;/tips/&quot;&gt;View All Tips&lt;/a&gt;</content>
	</entry>
	
	
	<entry>
		<title>Using Template Content as Data for 11ty</title>
		<link href="https://11ty.rocks/posts/using-template-content-as-data/"/>
		<updated>2021-02-15T00:00:00Z</updated>
		<id>https://11ty.rocks/posts/using-template-content-as-data/</id>
		<content type="html">&lt;p&gt;This tutorial describes a technique I&#39;ve used in several of my 20+ Eleventy projects to push Eleventy to &lt;a href=&quot;https://11ty.rocks/posts/going-beyond-static-with-eleventy/&quot;&gt;exceed the traditional limits of static&lt;/a&gt;.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;New to Eleventy?&lt;/strong&gt; Start with my &lt;a href=&quot;https://11ty.rocks/posts/create-your-first-basic-11ty-website/&quot;&gt;written tutorial&lt;/a&gt; or &lt;a href=&quot;https://5t3ph.dev/learn-11ty&quot;&gt;20 minute video course&lt;/a&gt;.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;div class=&quot;heading-wrapper h2&quot;&gt;
&lt;h2 id=&quot;creating-content-as-data&quot;&gt;Creating Content as Data&lt;/h2&gt;
&lt;a class=&quot;tdbc-anchor&quot; href=&quot;https://11ty.rocks/posts/using-template-content-as-data/#creating-content-as-data&quot; aria-labelledby=&quot;creating-content-as-data&quot;&gt;&lt;span hidden=&quot;&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;One way we can create data in Eleventy is via &lt;a href=&quot;https://www.11ty.dev/docs/data-global/&quot;&gt;the &lt;code&gt;_data&lt;/code&gt; directory&lt;/a&gt;, which is great for small arrays or for pulling in content from a CMS. Content contained in &lt;code&gt;_data&lt;/code&gt; is then available for either &lt;a href=&quot;https://www.11ty.dev/docs/pagination/#paginate-a-global-or-local-data-file&quot;&gt;pagination&lt;/a&gt; or directly for uses such as looping to output content.&lt;/p&gt;
&lt;p&gt;But what if your content will all be local and intended to output on a single page, and you would like to use templating or other rich features that would be cumbersome inside JSON? This is the type of scenario where you want to create &amp;quot;content as data.&amp;quot;&lt;/p&gt;
&lt;div class=&quot;heading-wrapper h2&quot;&gt;
&lt;h2 id=&quot;step-one-create-a-collection&quot;&gt;Step One: Create a Collection&lt;/h2&gt;
&lt;a class=&quot;tdbc-anchor&quot; href=&quot;https://11ty.rocks/posts/using-template-content-as-data/#step-one-create-a-collection&quot; aria-labelledby=&quot;step-one-create-a-collection&quot;&gt;&lt;span hidden=&quot;&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;Let&#39;s imagine our scenario is a site where we&#39;ll provide book reviews.&lt;/p&gt;
&lt;p&gt;For ease of accessing our review content data, we&#39;ll create a collection.&lt;/p&gt;
&lt;p&gt;In your input directory, create the &lt;code&gt;reviews&lt;/code&gt; directory, and then inside of that create the file &lt;code&gt;reviews.json&lt;/code&gt; which will be a &lt;a href=&quot;https://11ty.rocks/tips/data-directory-file/&quot;&gt;directory data file&lt;/a&gt;.&lt;/p&gt;
&lt;pre class=&quot;language-json&quot;&gt;&lt;code class=&quot;language-json&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token property&quot;&gt;&quot;tags&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;reviews&quot;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This is now creating the &lt;code&gt;reviews&lt;/code&gt; collection by assigning it as a &amp;quot;tag&amp;quot; (the standard Eleventy way to create a collection) for all content that will live in this directory.&lt;/p&gt;
&lt;div class=&quot;heading-wrapper h2&quot;&gt;
&lt;h2 id=&quot;step-two-prevent-page-generation&quot;&gt;Step Two: Prevent Page Generation&lt;/h2&gt;
&lt;a class=&quot;tdbc-anchor&quot; href=&quot;https://11ty.rocks/posts/using-template-content-as-data/#step-two-prevent-page-generation&quot; aria-labelledby=&quot;step-two-prevent-page-generation&quot;&gt;&lt;span hidden=&quot;&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;With only the previous step in place, if Eleventy is running and you add a file - such as &lt;code&gt;firstreview.md&lt;/code&gt; - in the &lt;code&gt;reviews&lt;/code&gt; directory, you will have &lt;code&gt;reviews/firstreview.html&lt;/code&gt; created as a page in your site&#39;s output directory.&lt;/p&gt;
&lt;p&gt;Since our intention is to use this content as data, we need to prevent this page generation.&lt;/p&gt;
&lt;p&gt;Preventing generation of files in the site&#39;s &lt;code&gt;output&lt;/code&gt; directory is handled by setting &lt;code&gt;permalink: false&lt;/code&gt;, so we&#39;ll update our directory data file:&lt;/p&gt;
&lt;pre class=&quot;language-json&quot;&gt;&lt;code class=&quot;language-json&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token property&quot;&gt;&quot;tags&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;reviews&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token property&quot;&gt;&quot;permalink&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token boolean&quot;&gt;false&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;div class=&quot;heading-wrapper h2&quot;&gt;
&lt;h2 id=&quot;step-three-create-collection-content&quot;&gt;Step Three: Create Collection Content&lt;/h2&gt;
&lt;a class=&quot;tdbc-anchor&quot; href=&quot;https://11ty.rocks/posts/using-template-content-as-data/#step-three-create-collection-content&quot; aria-labelledby=&quot;step-three-create-collection-content&quot;&gt;&lt;span hidden=&quot;&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;Now you can create files using any supported templating language within the &lt;code&gt;reviews&lt;/code&gt; directory and take advantage of all the templating features it offers.&lt;/p&gt;
&lt;p&gt;For example, here&#39;s a possible setup for our book review content type using Markdown:&lt;/p&gt;
&lt;pre class=&quot;language-md&quot;&gt;&lt;code class=&quot;language-md&quot;&gt;&lt;span class=&quot;token front-matter-block&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;---&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token front-matter yaml language-yaml&quot;&gt;&lt;span class=&quot;token key atrule&quot;&gt;title&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;Paddington Bear&quot;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token key atrule&quot;&gt;author&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;Michael Bond&quot;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token key atrule&quot;&gt;rating&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;4.5&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token key atrule&quot;&gt;buyLink&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;/&quot;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;---&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;I enjoyed this book very much, and so did my 3 year old.&lt;/code&gt;&lt;/pre&gt;
&lt;div class=&quot;heading-wrapper h2&quot;&gt;
&lt;h2 id=&quot;step-four-output-collection-content&quot;&gt;Step Four: Output Collection Content&lt;/h2&gt;
&lt;a class=&quot;tdbc-anchor&quot; href=&quot;https://11ty.rocks/posts/using-template-content-as-data/#step-four-output-collection-content&quot; aria-labelledby=&quot;step-four-output-collection-content&quot;&gt;&lt;span hidden=&quot;&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;Once you have some content available, and since we&#39;ve created it within a collection, we can now easily access it for output within a loop.&lt;/p&gt;
&lt;p&gt;You may choose to create this loop within your index file, such as &lt;code&gt;index.njk&lt;/code&gt;, or perhaps you would rather it be part of the layout that your index uses, such as &lt;code&gt;base.njk&lt;/code&gt;.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;You can choose another templating language to loop over your content, but we&#39;re going to stick with Nunjucks for this example.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Our Nunjucks loop might then look as follows for accessing the book reviews:&lt;/p&gt;
&lt;pre class=&quot;language-twig&quot;&gt;&lt;code class=&quot;language-twig&quot;&gt;&lt;span class=&quot;token twig language-twig&quot;&gt;&lt;span class=&quot;token delimiter punctuation&quot;&gt;{%&lt;/span&gt; &lt;span class=&quot;token tag-name keyword&quot;&gt;for&lt;/span&gt; review &lt;span class=&quot;token operator&quot;&gt;in&lt;/span&gt; collections&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;reviews &lt;span class=&quot;token delimiter punctuation&quot;&gt;%}&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;article&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;h2&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;a&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;href&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;token twig language-twig&quot;&gt;&lt;span class=&quot;token delimiter punctuation&quot;&gt;{{&lt;/span&gt; review&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;data&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;buyLink &lt;span class=&quot;token delimiter punctuation&quot;&gt;}}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token twig language-twig&quot;&gt;&lt;span class=&quot;token delimiter punctuation&quot;&gt;{{&lt;/span&gt; review&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;data&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;title &lt;span class=&quot;token delimiter punctuation&quot;&gt;}}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;a&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;h2&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;ul&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;li&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;strong&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;Author&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;strong&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;: &lt;span class=&quot;token twig language-twig&quot;&gt;&lt;span class=&quot;token delimiter punctuation&quot;&gt;{{&lt;/span&gt; review&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;data&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;author &lt;span class=&quot;token delimiter punctuation&quot;&gt;}}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;li&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;li&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;strong&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;Rating&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;strong&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;: &lt;span class=&quot;token twig language-twig&quot;&gt;&lt;span class=&quot;token delimiter punctuation&quot;&gt;{{&lt;/span&gt; review&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;data&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;rating &lt;span class=&quot;token delimiter punctuation&quot;&gt;}}&lt;/span&gt;&lt;/span&gt;/5&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;li&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;ul&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token twig language-twig&quot;&gt;&lt;span class=&quot;token delimiter punctuation&quot;&gt;{{&lt;/span&gt; review&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;templateContent &lt;span class=&quot;token operator&quot;&gt;|&lt;/span&gt; safe &lt;span class=&quot;token delimiter punctuation&quot;&gt;}}&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;article&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token twig language-twig&quot;&gt;&lt;span class=&quot;token delimiter punctuation&quot;&gt;{%&lt;/span&gt; &lt;span class=&quot;token tag-name keyword&quot;&gt;endfor&lt;/span&gt; &lt;span class=&quot;token delimiter punctuation&quot;&gt;%}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Let&#39;s examine a few key aspects of that loop for successfully accessing and outputting the data as content:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Front matter values are accessed off of the &lt;code&gt;data&lt;/code&gt; nested object&lt;/li&gt;
&lt;li&gt;The compiled non-front matter content is available within &lt;code&gt;templateContent&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;To ensure any HTML in the compiled template is rendered and not escaped (which would cause it to appear as additional text on the page), we also use the &lt;code&gt;safe&lt;/code&gt; built-in filter&lt;/li&gt;
&lt;li&gt;Avoid wrapping the &lt;code&gt;templateContent&lt;/code&gt; within a paragraph since it arrives compiled and already includes HTML elements as appropriate&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;And with that you&#39;ve successfully created and output content as data!&lt;/p&gt;
&lt;div class=&quot;heading-wrapper h2&quot;&gt;
&lt;h2 id=&quot;further-reading-and-resources&quot;&gt;Further Reading and Resources&lt;/h2&gt;
&lt;a class=&quot;tdbc-anchor&quot; href=&quot;https://11ty.rocks/posts/using-template-content-as-data/#further-reading-and-resources&quot; aria-labelledby=&quot;further-reading-and-resources&quot;&gt;&lt;span hidden=&quot;&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;Check out these related quick tips to extend this solution even more:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://11ty.rocks/tips/changing-content-output/&quot;&gt;Changing Content Output&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://11ty.rocks/tips/excluding-content-output/&quot;&gt;Excluding Content Output&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://11ty.rocks/tips/permalinks/&quot;&gt;Managing Permalinks&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;And checkout &lt;a href=&quot;https://www.youtube.com/watch?v=nIiOwNb7KR4&quot;&gt;this livestream I did with Colby Fayock&lt;/a&gt; where we use this same &amp;quot;content as data&amp;quot; idea when we start a site from scratch, but with a bit more templating features attached.&lt;/p&gt;
</content>
	</entry>
	
	
	<entry>
		<title>Going Beyond Static Sites With Eleventy</title>
		<link href="https://11ty.rocks/posts/going-beyond-static-with-eleventy/"/>
		<updated>2021-01-28T00:00:00Z</updated>
		<id>https://11ty.rocks/posts/going-beyond-static-with-eleventy/</id>
		<content type="html">&lt;p&gt;&lt;em&gt;The following is the written version of my talk at &lt;a href=&quot;https://cfe.dev/events/the-jam-2021/&quot;&gt;TheJam.dev 2021&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;
&lt;div class=&quot;tdbc-video&quot;&gt;&lt;iframe src=&quot;https://slides.com/st3ph/going-beyond-static-with-eleventy/embed?token=s13kGbJt&quot; scrolling=&quot;no&quot; frameborder=&quot;0&quot; webkitallowfullscreen=&quot;&quot; mozallowfullscreen=&quot;&quot; allowfullscreen=&quot;&quot;&gt;&lt;/iframe&gt;&lt;/div&gt;
&lt;div class=&quot;heading-wrapper h2&quot;&gt;
&lt;h2 id=&quot;key-eleventy-features&quot;&gt;Key Eleventy Features&lt;/h2&gt;
&lt;a class=&quot;tdbc-anchor&quot; href=&quot;https://11ty.rocks/posts/going-beyond-static-with-eleventy/#key-eleventy-features&quot; aria-labelledby=&quot;key-eleventy-features&quot;&gt;&lt;span hidden=&quot;&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;heading-wrapper h3&quot;&gt;
&lt;h3 id=&quot;100percent-static-output&quot;&gt;100% Static Output&lt;/h3&gt;
&lt;a class=&quot;tdbc-anchor&quot; href=&quot;https://11ty.rocks/posts/going-beyond-static-with-eleventy/#100percent-static-output&quot; aria-labelledby=&quot;100percent-static-output&quot;&gt;&lt;span hidden=&quot;&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;First, I was very drawn to it being able to be purely static. At it&#39;s most essential level, it can be a drop-in replacement for tools like Gulp, and can be built with good ole HTML and CSS.&lt;/p&gt;
&lt;p&gt;A huge selling point for me was that there is zero boilerplate client-side JavaScript.&lt;/p&gt;
&lt;div class=&quot;heading-wrapper h3&quot;&gt;
&lt;h3 id=&quot;developer-mode-conveniences&quot;&gt;Developer-Mode Conveniences&lt;/h3&gt;
&lt;a class=&quot;tdbc-anchor&quot; href=&quot;https://11ty.rocks/posts/going-beyond-static-with-eleventy/#developer-mode-conveniences&quot; aria-labelledby=&quot;developer-mode-conveniences&quot;&gt;&lt;span hidden=&quot;&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;Eleventy includes BrowserSync when using the &lt;code&gt;--serve&lt;/code&gt; flag which provides hot-reload as you make changes. There&#39;s also full console logging of what was changed or had errors, and the option to quiet this output.&lt;/p&gt;
&lt;div class=&quot;heading-wrapper h3&quot;&gt;
&lt;h3 id=&quot;minimal-opinions-highly-configurable&quot;&gt;Minimal Opinions, Highly Configurable&lt;/h3&gt;
&lt;a class=&quot;tdbc-anchor&quot; href=&quot;https://11ty.rocks/posts/going-beyond-static-with-eleventy/#minimal-opinions-highly-configurable&quot; aria-labelledby=&quot;minimal-opinions-highly-configurable&quot;&gt;&lt;span hidden=&quot;&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;Technically, the only requirement besides Eleventy is an &lt;code&gt;index&lt;/code&gt; file which can be created in any of the languages. Mine is usually Markdown that feeds into a Nunjucks layout which we&#39;ll talk about in a bit.&lt;/p&gt;
&lt;p&gt;Once you get a feel for how things work, you can begin to add your own opinions by updating the config, which is expected to be a root file called &lt;code&gt;.eleventy.js&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;Here you can do things like customize your input and output directory, and add other watch directories. It&#39;s also the entry point for plugins, and where you&#39;ll hook in additional templating, data, and content features.&lt;/p&gt;
&lt;div class=&quot;heading-wrapper h3&quot;&gt;
&lt;h3 id=&quot;10-templating-languages&quot;&gt;10 Templating Languages&lt;/h3&gt;
&lt;a class=&quot;tdbc-anchor&quot; href=&quot;https://11ty.rocks/posts/going-beyond-static-with-eleventy/#10-templating-languages&quot; aria-labelledby=&quot;10-templating-languages&quot;&gt;&lt;span hidden=&quot;&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;With 10 templating languages available, an early realization was that I could re-purpose some of my organization preferences from both my React and WordPress days to create templates and components. I&#39;ve grown a preference for a stack of HTML, Nunjucks, and Markdown.&lt;/p&gt;
&lt;p&gt;The extra languages are a nice to have, and can be added in as you find a need for them.&lt;/p&gt;
&lt;div class=&quot;heading-wrapper h3&quot;&gt;
&lt;h3 id=&quot;templating-features&quot;&gt;Templating Features&lt;/h3&gt;
&lt;a class=&quot;tdbc-anchor&quot; href=&quot;https://11ty.rocks/posts/going-beyond-static-with-eleventy/#templating-features&quot; aria-labelledby=&quot;templating-features&quot;&gt;&lt;span hidden=&quot;&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;As I mentioned, my preferred stack with Eleventy is HTML, Nunjucks and Markdown. Here&#39;s the full list of currently available templating languages:&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://www.11ty.dev/docs/languages/&quot;&gt;&lt;img src=&quot;https://11ty.rocks/img/beyond-static/11ty-langs.jpg&quot; alt=&quot;A gif of interacting with the template navigation on the 11ty docs&quot; /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;The first &amp;quot;a-ha&amp;quot; moment that made me really excited about Eleventy was the ability to mix templating languages.&lt;/p&gt;
&lt;p&gt;This takes two primary forms:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Mix in the same file (ex. Nunjucks and Markdown)&lt;/li&gt;
&lt;li&gt;Mix between layouts (Markdown file uses Nunjucks template)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Layouts are special templates that can be used to wrap other content. An example of this is having &lt;code&gt;index.md&lt;/code&gt; contain your home page text content and Frontmatter for the page &lt;code&gt;title&lt;/code&gt;, and have it point to the layout of &lt;code&gt;base.njk&lt;/code&gt; which is an HTML5 boilerplate and uses template tags to display the &lt;code&gt;title&lt;/code&gt; value and the Markdown content.&lt;/p&gt;
&lt;p&gt;Eleventy also has a feature called layout chaining. So, you could create an &lt;code&gt;article&lt;/code&gt; content type and a &lt;code&gt;news&lt;/code&gt; content type that both chain to a &lt;code&gt;page&lt;/code&gt; layout, and the &lt;code&gt;page&lt;/code&gt; layout could chain to the &lt;code&gt;base&lt;/code&gt; layout.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://11ty.rocks/img/beyond-static/layout-chaining.jpg&quot; alt=&quot;Illustration showing the scenario described in the prior paragraph of the two content types using the page layout, and that using the base layout&quot; /&gt;&lt;/p&gt;
&lt;p&gt;Within layouts and templates, you can use the syntax of the language you choose to include other files as partials. Or, you can create reusable content with shortcodes and manipulate content with filters. We don&#39;t quite have time to go through those features today, but the key point is that they allow even more customization and flexibility within your layouts and templates. You can review that info by visiting the &lt;a href=&quot;https://www.11ty.dev/docs/config/&quot;&gt;11ty docs on configuration&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;One of the most powerful features related to templating is being able to define overrides for the template engine which you can do &lt;em&gt;per file&lt;/em&gt; or in the Eleventy config*.*&lt;/p&gt;
&lt;p&gt;On a per-file basis, we can place it in Frontmatter. Here we define that the template should be first consumed as Nunjucks, then Markdown. Eleventy will work for basic loops that mix languages, but adding filters or formatting can cause issues that the template engine override will resolve.&lt;/p&gt;
&lt;pre class=&quot;language-md&quot;&gt;&lt;code class=&quot;language-md&quot;&gt;&lt;span class=&quot;token front-matter-block&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;---&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token front-matter yaml language-yaml&quot;&gt;&lt;span class=&quot;token key atrule&quot;&gt;templateEngineOverride&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; njk&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; md&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;---&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token title important&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;##&lt;/span&gt; Featured Person&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;{% for name in people | randomPerson %}&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token list punctuation&quot;&gt;-&lt;/span&gt; {{ name }}&lt;br /&gt;&lt;br /&gt;{% endfor %}&lt;/code&gt;&lt;/pre&gt;
&lt;div class=&quot;heading-wrapper h3&quot;&gt;
&lt;h3 id=&quot;data&quot;&gt;Data&lt;/h3&gt;
&lt;a class=&quot;tdbc-anchor&quot; href=&quot;https://11ty.rocks/posts/going-beyond-static-with-eleventy/#data&quot; aria-labelledby=&quot;data&quot;&gt;&lt;span hidden=&quot;&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;The example that was just shown actually was setup to use what Eleventy calls &amp;quot;custom data&amp;quot;.&lt;/p&gt;
&lt;p&gt;An optional directory can be included called &lt;code&gt;_data&lt;/code&gt; and in there you can put things like JSON or JavaScript module exports. The name of the file is then made available throughout Eleventy to access that data. So in the &amp;quot;Featured Person&amp;quot; example, there is a file located in &lt;code&gt;_data/people.js&lt;/code&gt; that exports a simple array, and we can then access that in any template by the filename of &amp;quot;people&amp;quot;.&lt;/p&gt;
&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;module&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;exports &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;Mary&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;Claire&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;Steph&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;Andy&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;But you&#39;re not restricted to flat or simple local data. You can also perform a fetch for external data and import any needed functionality to get and format the data you want Eleventy to use.&lt;/p&gt;
&lt;p&gt;Here&#39;s a simple example fetching a path from a random cat picture API:&lt;/p&gt;
&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; axios &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;require&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;axios&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;module&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function-variable function&quot;&gt;exports&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;async&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; result &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;await&lt;/span&gt; axios&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;get&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;https://aws.random.cat/meow&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;  &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; result&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;data&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;file&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token comment&quot;&gt;// Ex: https:\/\/purr.objects-us-east-1.dream.io\/i\/image1-4.jpg&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The important note here is that the fetch is done at build time, not client-side. For fetching from a CMS this is highly desireable. For content you want to keep more fresh, you can use services like IFTTT to do a periodic request if your site host provides webhooks to trigger a build. Of course, that is a static site limitation that is not unique to Eleventy.&lt;/p&gt;
&lt;p&gt;We&#39;ll talk a bit more about data handling when we get to our examples.&lt;/p&gt;
&lt;div class=&quot;heading-wrapper h3&quot;&gt;
&lt;h3 id=&quot;content-management&quot;&gt;Content Management&lt;/h3&gt;
&lt;a class=&quot;tdbc-anchor&quot; href=&quot;https://11ty.rocks/posts/going-beyond-static-with-eleventy/#content-management&quot; aria-labelledby=&quot;content-management&quot;&gt;&lt;span hidden=&quot;&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;A key feature for content in Eleventy is &amp;quot;collections&amp;quot;. If you come from the WordPress world like I do, you can think of these similair to how adding tags creates sets of content. In fact, Eleventy uses the same convention of tags as one way to create a collection.&lt;/p&gt;
&lt;p&gt;Tags can be added in Frontmatter, either as a single string or as an array.&lt;/p&gt;
&lt;p&gt;But the slickest way is to create a directory data file. The directory data file needs to be named the same as the directory, and can be either JSON or JavaScript. It can hold any values that you would otherwise have to repeat in Frontmatter for all related content.&lt;/p&gt;
&lt;p&gt;So in this example located in our &lt;code&gt;posts&lt;/code&gt; directory, we create &lt;code&gt;posts.json&lt;/code&gt; and define the tags as well as the layout:&lt;/p&gt;
&lt;pre class=&quot;language-json&quot;&gt;&lt;code class=&quot;language-json&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token property&quot;&gt;&quot;layout&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;post.njk&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token property&quot;&gt;&quot;tags&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;posts&quot;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Now, we can access the &lt;code&gt;posts&lt;/code&gt; collection within any of our templates:&lt;/p&gt;
&lt;pre class=&quot;language-twig&quot;&gt;&lt;code class=&quot;language-twig&quot;&gt;&lt;span class=&quot;token twig language-twig&quot;&gt;&lt;span class=&quot;token delimiter punctuation&quot;&gt;{%&lt;/span&gt; &lt;span class=&quot;token tag-name keyword&quot;&gt;for&lt;/span&gt; post &lt;span class=&quot;token operator&quot;&gt;in&lt;/span&gt; collections&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;post &lt;span class=&quot;token delimiter punctuation&quot;&gt;-%}&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;- [&lt;span class=&quot;token twig language-twig&quot;&gt;&lt;span class=&quot;token delimiter punctuation&quot;&gt;{{&lt;/span&gt; post&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;data&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;title &lt;span class=&quot;token delimiter punctuation&quot;&gt;}}&lt;/span&gt;&lt;/span&gt;](&lt;span class=&quot;token twig language-twig&quot;&gt;&lt;span class=&quot;token delimiter punctuation&quot;&gt;{{&lt;/span&gt; post&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;url &lt;span class=&quot;token delimiter punctuation&quot;&gt;}}&lt;/span&gt;&lt;/span&gt;)&lt;br /&gt;&lt;span class=&quot;token twig language-twig&quot;&gt;&lt;span class=&quot;token delimiter punctuation&quot;&gt;{%&lt;/span&gt; &lt;span class=&quot;token tag-name keyword&quot;&gt;endfor&lt;/span&gt; &lt;span class=&quot;token delimiter punctuation&quot;&gt;%}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;div class=&quot;heading-wrapper h2&quot;&gt;
&lt;h2 id=&quot;feature-integration&quot;&gt;Feature Integration&lt;/h2&gt;
&lt;a class=&quot;tdbc-anchor&quot; href=&quot;https://11ty.rocks/posts/going-beyond-static-with-eleventy/#feature-integration&quot; aria-labelledby=&quot;feature-integration&quot;&gt;&lt;span hidden=&quot;&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;As we saw with the data example that used axios for fetching, another benefit of Eleventy is that it is built with Node. And you can use anything in the Node and JavaScript ecosystem at build time.&lt;/p&gt;
&lt;p&gt;Let&#39;s look a classic issue that is solved by having access to JavaScript at build time: making sure your footer has the correct copyright year.&lt;/p&gt;
&lt;p&gt;In Eleventy, we could export this as data, but we can also create what is called a shortcode to be able to output it. This snippet actually comes direct from my &lt;a href=&quot;https://11ty.rocks/eleventyjs/dates/&quot;&gt;11ty.Rocks&lt;/a&gt; config samples, and likely looks very familiar to those of you who frequently write JavaScript:&lt;/p&gt;
&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;eleventyConfig&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;addShortcode&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;year&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token template-string&quot;&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Date&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;getFullYear&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This snippet gets placed in the &lt;code&gt;.eleventy.js&lt;/code&gt; config, and then you can use it in your templates.&lt;/p&gt;
&lt;p&gt;There is also a fledging plugin ecosystem. Plugins come in as packages, and are included via the config as well. They range in complexity, but most provide access to shortcodes, filters, or other types of transforms that have the advantage of already being aware of how Eleventy works.&lt;/p&gt;
&lt;p&gt;A bonus benefit in my journey with Eleventy was finally publishing a package since I wanted to release an Eleventy plugin, and now I have two:&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://www.npmjs.com/search?q=%4011tyrocks&quot;&gt;&lt;img src=&quot;https://11ty.rocks/img/beyond-static/steph-11ty-plugins.jpg&quot; alt=&quot;Preview of my two plugins: @11tyrocks/eleventy-plugin-emoji-readtime and @11tyrocks/eleventy-plugin-social-images&quot; /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;The best way currently to discover all Eleventy plugins is to &lt;a href=&quot;https://www.npmjs.com/search?q=eleventy-plugin&quot;&gt;search by the tag &lt;code&gt;eleventy-plugin&lt;/code&gt; on npm&lt;/a&gt;.&lt;/p&gt;
&lt;div class=&quot;heading-wrapper h3&quot;&gt;
&lt;h3 id=&quot;flexible-output&quot;&gt;Flexible Output&lt;/h3&gt;
&lt;a class=&quot;tdbc-anchor&quot; href=&quot;https://11ty.rocks/posts/going-beyond-static-with-eleventy/#flexible-output&quot; aria-labelledby=&quot;flexible-output&quot;&gt;&lt;span hidden=&quot;&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;I&#39;m hoping you&#39;ve heard a few things that have you interested in Eleventy, but this next feature is what opened the door to the examples I&#39;ll be sharing shortly.&lt;/p&gt;
&lt;p&gt;By default, Eleventy works as you would expect from other similair static site generators. You create a file using whichever template language type and it ultimately outputs HTML.&lt;/p&gt;
&lt;p&gt;But Eleventy, by way of defining permalinks, allows you to change the file type and place the resulting file anyway in the system.&lt;/p&gt;
&lt;p&gt;A small example of this being useful is in creating the site&#39;s RSS feed, which is actually demonstrated by &lt;a href=&quot;https://github.com/11ty/eleventy-base-blog&quot;&gt;the official Eleventy blog starter&lt;/a&gt; and supported by an official plugin which provides some filters to assist in producing things like absolute URLs and correctly formatted dates.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://github.com/11ty/eleventy-base-blog/blob/master/feed/feed.njk&quot;&gt;&lt;img src=&quot;https://11ty.rocks/img/beyond-static/11ty-rss.jpg&quot; alt=&quot;Screenshot of the Eleventy base blog starter&#39;s RSS feed file&quot; /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;An additional way to use this feature is to be able to create a JSON file of page data that is actually constructed within a Nunjucks template and accesses an existing collection. The benefit of this is that you have the compiled template content available if say the page content itself was created in Markdown.&lt;/p&gt;
&lt;p&gt;And using permalinks, we can both change it to be the &lt;code&gt;.json&lt;/code&gt; file type but also place it outside of the src directory, thus excluding it from the site output but making it available for other processes.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://11ty.rocks/img/beyond-static/flexible-output.jpg&quot; alt=&quot;Illustration showing the scenario described in the prior paragraphs of markdown feeding into a Nunjucks layout that outputs JSON&quot; /&gt;&lt;/p&gt;
&lt;p&gt;What I&#39;ve just described is how I was able to create a dynamic and synced data file that is used to create social media images. In that process, I kick the JSON file to a &lt;code&gt;functions&lt;/code&gt; directory in which there is a Node Puppeteer script that loops through that data and loads it into an HTML template to take a snapshot and save the image.&lt;/p&gt;
&lt;div class=&quot;heading-wrapper h2&quot;&gt;
&lt;h2 id=&quot;community&quot;&gt;Community&lt;/h2&gt;
&lt;a class=&quot;tdbc-anchor&quot; href=&quot;https://11ty.rocks/posts/going-beyond-static-with-eleventy/#community&quot; aria-labelledby=&quot;community&quot;&gt;&lt;span hidden=&quot;&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;Before we move on to examples, I wanted to note that despite Eleventy being just at three years old, there is an active, passionate community.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://twitter.com/search?q=%22built%20with%20eleventy%22&amp;amp;src=typed_query&amp;amp;f=live&quot;&gt;Search the phrase &amp;quot;built with eleventy&amp;quot; on Twitter&lt;/a&gt; and you&#39;ll get enthusiastic folx telling you all about it, often with a blog post about their experience.&lt;/p&gt;
&lt;p&gt;Where some platforms have the concept of themes, Eleventy uses the term &amp;quot;starter&amp;quot; and there is &lt;a href=&quot;https://www.11ty.dev/docs/starter/&quot;&gt;a growing collection to choose from&lt;/a&gt;. With 10 templating languages available, there are many opinions of how things should be done, so you&#39;re sure to find one to help get you off the ground.&lt;/p&gt;
&lt;p&gt;The market for content about Eleventy is still young, which I find exciting and have personally embraced. But when you really can&#39;t find the answer, you can tag &lt;a href=&quot;https://twitter.com/eleven_ty&quot;&gt;the offical @eleven_ty account on Twitter&lt;/a&gt; and Eleventy&#39;s creator, Zach Leatherman, will often answer or RT for reach to the community. He&#39;s also quick to amplify blog posts and other things made by and for Eleventy if you tag the account.&lt;/p&gt;
&lt;hr /&gt;
&lt;div class=&quot;heading-wrapper h2&quot;&gt;
&lt;h2 id=&quot;create-an-eleventy-site-in-3-minutes&quot;&gt;Create an Eleventy Site in 3 Minutes&lt;/h2&gt;
&lt;a class=&quot;tdbc-anchor&quot; href=&quot;https://11ty.rocks/posts/going-beyond-static-with-eleventy/#create-an-eleventy-site-in-3-minutes&quot; aria-labelledby=&quot;create-an-eleventy-site-in-3-minutes&quot;&gt;&lt;span hidden=&quot;&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;blockquote&gt;
&lt;p&gt;These steps are also very similar to what is described in my tutorial on &lt;a href=&quot;https://11ty.rocks/posts/create-your-first-basic-11ty-website&quot;&gt;building your first 11ty site&lt;/a&gt; which includes code samples for all steps.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;&lt;strong&gt;This 3 minute video is followed by the transcript and a few code samples&lt;/strong&gt;:&lt;/p&gt;
&lt;div class=&quot;tdbc-video&quot;&gt;&lt;iframe title=&quot;YouTube video: Build an 11ty Site in 3 Minutes&quot; src=&quot;https://www.youtube-nocookie.com/embed/BKdQEXqfFA0?rel=0&quot; frameborder=&quot;0&quot; allow=&quot;accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture&quot; allowfullscreen=&quot;&quot;&gt;&lt;/iframe&gt;&lt;/div&gt;
&lt;p&gt;Ok! So I hope you&#39;re excited and maybe even have a project in mind to try to build with Eleventy!&lt;/p&gt;
&lt;p&gt;So now we&#39;re going to build an Eleventy site in 3 minutes and following that we&#39;ll see the features we talked about in action and will follow this with some examples of going beyond static with Eleventy.&lt;/p&gt;
&lt;p&gt;The first important lesson after we init a new project and get ready to install Eleventy is that it is a scoped package, so you install it with &lt;code&gt;@11ty/eleventy&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Once the installs complete, we&#39;ll open package.json and update the default scripts section. This enables a start command to run 11ty with hot-reload, which is provided by Browsersync that comes bundled as part of 11ty&#39;s &lt;code&gt;--serve&lt;/code&gt; directive.&lt;/p&gt;
&lt;pre class=&quot;language-json&quot;&gt;&lt;code class=&quot;language-json&quot;&gt;&lt;span class=&quot;token property&quot;&gt;&quot;scripts&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token property&quot;&gt;&quot;start&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;npx @11ty/eleventy --serve&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token property&quot;&gt;&quot;build&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;npx @11ty/eleventy&quot;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Next, we create the config file to perform an optional step which is to update our input and output directory, my preference being &lt;code&gt;src&lt;/code&gt; for &amp;quot;input&amp;quot; and &lt;code&gt;public&lt;/code&gt; for the output.&lt;/p&gt;
&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;module&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function-variable function&quot;&gt;exports&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;eleventyConfig&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token literal-property property&quot;&gt;dir&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;token literal-property property&quot;&gt;input&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;src&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;token literal-property property&quot;&gt;output&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;public&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Then we need to create a &lt;strong&gt;layout&lt;/strong&gt; file and an &lt;strong&gt;index&lt;/strong&gt; file. You can certainly combine these steps, but to take full advantage of templating features, I recommend using layouts from the start.&lt;/p&gt;
&lt;p&gt;Eleventy expects layouts to be located in the &lt;code&gt;_includes&lt;/code&gt; directory, and we&#39;ll create a Nunjucks file called &lt;code&gt;base&lt;/code&gt;. Our layout will use the HTML5 boilerplate, and we&#39;ll prepare it for the incoming content by adding the variable of &lt;code&gt;{{ title }}&lt;/code&gt; which will be provided by frontmatter. We&#39;ll also stub out a nice semantic starting point for the body, adding the &lt;code&gt;title&lt;/code&gt; again as the &lt;code&gt;h1&lt;/code&gt; and use the template variable for &lt;code&gt;content&lt;/code&gt; followed by the &lt;code&gt;safe&lt;/code&gt; filter to say we expect and want to allow any HTML content here.&lt;/p&gt;
&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token doctype&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;!&lt;/span&gt;&lt;span class=&quot;token doctype-tag&quot;&gt;DOCTYPE&lt;/span&gt; &lt;span class=&quot;token name&quot;&gt;html&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;html&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;lang&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;en&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;head&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;meta&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;charset&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;UTF-8&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;/&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;meta&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;viewport&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;content&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;width=device-width, initial-scale=1.0&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;/&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;title&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;Going Beyond Static Sites With Eleventy&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;title&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;head&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;body&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;header&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;h1&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;Going Beyond Static Sites With Eleventy&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;h1&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;header&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;main&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;main&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;body&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;html&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Now in our &lt;code&gt;src&lt;/code&gt; we&#39;ll create &lt;code&gt;index.md&lt;/code&gt; and add the frontmatter key of &lt;code&gt;title&lt;/code&gt; with a nice &amp;quot;Hello World&amp;quot;, and a small message to make sure our content is working. We&#39;ll also attach it to our layout with the frontmatter key of &lt;code&gt;layout&lt;/code&gt; and set the value to the filename of &lt;code&gt;base.njk&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&quot;language-md&quot;&gt;&lt;code class=&quot;language-md&quot;&gt;&lt;span class=&quot;token front-matter-block&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;---&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token front-matter yaml language-yaml&quot;&gt;&lt;span class=&quot;token key atrule&quot;&gt;title&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; Hello World&lt;br /&gt;&lt;span class=&quot;token key atrule&quot;&gt;layout&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;base.njk&quot;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;---&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Hello Jamstack fam!&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Finally, we&#39;ll open Terminal and run the &lt;code&gt;npm start&lt;/code&gt; command we setup which launches a local server. We do still have to open this in a browser ourselves, but you&#39;ll see that we have successfully created our first page.&lt;/p&gt;
&lt;p&gt;We&#39;d like a little style for this, so let&#39;s create &lt;code&gt;style.css&lt;/code&gt;. The one trick here is we need to make Eleventy aware of this CSS file as it&#39;s not presently included, but first we&#39;ll link to it in our base layout. Then back in our config we&#39;ll add &lt;code&gt;style.css&lt;/code&gt; as a passthrough copy target, and now we have a lovely sans-serif theme kicked off.&lt;/p&gt;
&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;// Add within .eleventy.js&lt;/span&gt;&lt;br /&gt;eleventyConfig&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;addPassthroughCopy&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;./src/style.css&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Finally, to add a blog, we&#39;ll create a &lt;code&gt;posts&lt;/code&gt; directory and add &lt;code&gt;my-first-post&lt;/code&gt; with a title and a bit of content, then a directory data file using the directory name as the filename, to send it to the &lt;code&gt;base&lt;/code&gt; layout and add the tags to create the&lt;code&gt;posts&lt;/code&gt; collection.&lt;/p&gt;
&lt;p&gt;And back in our &lt;code&gt;index&lt;/code&gt; we&#39;ll loop over the new &lt;code&gt;posts&lt;/code&gt; collection.&lt;/p&gt;
&lt;pre class=&quot;language-twig&quot;&gt;&lt;code class=&quot;language-twig&quot;&gt;&lt;span class=&quot;token twig language-twig&quot;&gt;&lt;span class=&quot;token delimiter punctuation&quot;&gt;{%&lt;/span&gt; &lt;span class=&quot;token tag-name keyword&quot;&gt;for&lt;/span&gt; post &lt;span class=&quot;token operator&quot;&gt;in&lt;/span&gt; collections&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;post &lt;span class=&quot;token delimiter punctuation&quot;&gt;-%}&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;- [&lt;span class=&quot;token twig language-twig&quot;&gt;&lt;span class=&quot;token delimiter punctuation&quot;&gt;{{&lt;/span&gt; post&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;data&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;title &lt;span class=&quot;token delimiter punctuation&quot;&gt;}}&lt;/span&gt;&lt;/span&gt;](&lt;span class=&quot;token twig language-twig&quot;&gt;&lt;span class=&quot;token delimiter punctuation&quot;&gt;{{&lt;/span&gt; post&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;url &lt;span class=&quot;token delimiter punctuation&quot;&gt;}}&lt;/span&gt;&lt;/span&gt;)&lt;br /&gt;&lt;span class=&quot;token twig language-twig&quot;&gt;&lt;span class=&quot;token delimiter punctuation&quot;&gt;{%&lt;/span&gt; &lt;span class=&quot;token tag-name keyword&quot;&gt;endfor&lt;/span&gt; &lt;span class=&quot;token delimiter punctuation&quot;&gt;%}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;And there we have essential basics of getting started with Eleventy.&lt;/p&gt;
&lt;hr /&gt;
&lt;div class=&quot;heading-wrapper h2&quot;&gt;
&lt;h2 id=&quot;going-beyond-static&quot;&gt;Going Beyond Static&lt;/h2&gt;
&lt;a class=&quot;tdbc-anchor&quot; href=&quot;https://11ty.rocks/posts/going-beyond-static-with-eleventy/#going-beyond-static&quot; aria-labelledby=&quot;going-beyond-static&quot;&gt;&lt;span hidden=&quot;&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;With Eleventy, I can go from idea to publish in a matter of hours, with only the speed of typing in my way. 😉 It&#39;s made me feel the magic of web development again.&lt;/p&gt;
&lt;p&gt;So I&#39;d like to share some of those projects as examples of going beyond static, which to me means using the features we discussed to their full capability to extend beyond &lt;em&gt;just&lt;/em&gt; HTML output from static, local content.&lt;/p&gt;
&lt;div class=&quot;heading-wrapper h3&quot;&gt;
&lt;h3 id=&quot;style-stage-non-cms-community-contributions&quot;&gt;Style Stage - Non-CMS Community Contributions&lt;/h3&gt;
&lt;a class=&quot;tdbc-anchor&quot; href=&quot;https://11ty.rocks/posts/going-beyond-static-with-eleventy/#style-stage-non-cms-community-contributions&quot; aria-labelledby=&quot;style-stage-non-cms-community-contributions&quot;&gt;&lt;span hidden=&quot;&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;My first large project with Eleventy was &lt;a href=&quot;https://stylestage.dev/&quot;&gt;StyleStage.dev&lt;/a&gt; which is a modern CSS showcase styled by community contributions.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://stylestage.dev/&quot;&gt;&lt;img src=&quot;https://11ty.rocks/img/beyond-static/stylestage.png&quot; alt=&quot;Preview of the StyleStage.dev home page&quot; /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;The key here is that anyone can contribute a stylesheet.&lt;/p&gt;
&lt;p&gt;The way that is setup is by allowing contributors to add their own JSON file within the &lt;code&gt;_data&lt;/code&gt; directory. Those then get globbed together to create the collection for use on the site, and also a JSON file is created to generate social share images like I described earlier.&lt;/p&gt;
&lt;p&gt;Eleventy in this instance enables a simple mechanism for contributors that doesn&#39;t require managing a CMS or worrying about other forms of authorization because GitHub helps provide that layer. Coupled with Netlify, any new PR gets it&#39;s own deployed branch to enable me to reveiw submissions to ensure they meet the guidelines and help work with the contributor to resolve any issues or bugs.&lt;/p&gt;
&lt;p&gt;This has enabled contributors of many skill levels, and &lt;a href=&quot;https://stylestage.dev/styles/&quot;&gt;there are 50+ styles available&lt;/a&gt; for review on the site today.&lt;/p&gt;
&lt;div class=&quot;heading-wrapper h2&quot;&gt;
&lt;h2 id=&quot;generators&quot;&gt;Generators&lt;/h2&gt;
&lt;a class=&quot;tdbc-anchor&quot; href=&quot;https://11ty.rocks/posts/going-beyond-static-with-eleventy/#generators&quot; aria-labelledby=&quot;generators&quot;&gt;&lt;span hidden=&quot;&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;Next we&#39;ll go a bit more outside the box with a series of generators that are intended to:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;produce an asset, or&lt;/li&gt;
&lt;li&gt;provide an environment instead of a static site for publish&lt;/li&gt;
&lt;/ol&gt;
&lt;div class=&quot;heading-wrapper h3&quot;&gt;
&lt;h3 id=&quot;email-generator&quot;&gt;Email Generator&lt;/h3&gt;
&lt;a class=&quot;tdbc-anchor&quot; href=&quot;https://11ty.rocks/posts/going-beyond-static-with-eleventy/#email-generator&quot; aria-labelledby=&quot;email-generator&quot;&gt;&lt;span hidden=&quot;&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;First up is the example of an email generator.&lt;/p&gt;
&lt;p&gt;In this case, front matter is heavily leveraged to populate areas of the table-based template layout, but Markdown is used for the main content.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://11ty.rocks/img/beyond-static/11ty-email.jpg&quot; alt=&quot;Preview of the email design created in this generator, showing part of the hero image, a headline, and some body copy&quot; /&gt;&lt;/p&gt;
&lt;p&gt;The generator is setup to allow initial email styling with Sass. With the build command, the compiled template content is fed through a filter that hooks in the juice package which provides the style inlining functionality that is required for the best email style compatibility.&lt;/p&gt;
&lt;p&gt;So the output in this case is the compiled email template, but during the build Eleventy provides a comfortable environment where I can tuck away the fact that ultimately an email is comprised of tables for layout.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;a href=&quot;https://github.com/5t3ph/11ty-email-generator&quot;&gt;Get the email generator&lt;/a&gt; on GitHub!&lt;/p&gt;
&lt;/blockquote&gt;
&lt;div class=&quot;heading-wrapper h3&quot;&gt;
&lt;h3 id=&quot;web-component-generator&quot;&gt;Web Component Generator&lt;/h3&gt;
&lt;a class=&quot;tdbc-anchor&quot; href=&quot;https://11ty.rocks/posts/going-beyond-static-with-eleventy/#web-component-generator&quot; aria-labelledby=&quot;web-component-generator&quot;&gt;&lt;span hidden=&quot;&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;This year I also started learning about web components. But I found them a bit uncomfortable to build as a hobbyist who was looking for a couple small use components versus building a whole system.&lt;/p&gt;
&lt;p&gt;I thought I may not quite be able to accomplish compiling a web component with Eleventy, but two hours later I had a proof of concept deployed. The resulting environment allows generating web components in a way that separates concerns, and enables including them in pages to test the component during build out.&lt;/p&gt;
&lt;p&gt;To accomplish this, the generator exploits the layout functionality to inject the web component&#39;s scripts and styles into the required location to create the final JavaScript file.&lt;/p&gt;
&lt;p&gt;The web component&#39;s HTML template is created as Nunjucks file, and the associated script and style is created in the &lt;code&gt;_includes&lt;/code&gt; as if they were layout partials. To dynamically tie it all together, the generator expects that the Nunjucks template and the directory for the scripts and styles in &lt;code&gt;_includes&lt;/code&gt; share the same kebab-cased filename.&lt;/p&gt;
&lt;p&gt;Any created web component is fed into a unified &lt;code&gt;components&lt;/code&gt; Nunjucks template that allows bringing all the pieces together to be ready for what is ultimately output as a JavaScript file ready to be used as a web component.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://11ty.rocks/img/beyond-static/web-components.jpg&quot; alt=&quot;Illustration showing the scenario described in the prior paragraphs of the Nunjucks template, a script file, and a CSS file being fed into the Nunucks template that will output the web component JavaScript&quot; /&gt;&lt;/p&gt;
&lt;p&gt;In this case, the site could theoretically both create and consume the web components if the author so desired. Since this is still a POC, there&#39;s room to improve by adding a transpiler or enabling Sass in addition to vanilla CSS.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Learn more and &lt;a href=&quot;https://11ty-web-component-generator.netlify.app/&quot;&gt;demo the generator&lt;/a&gt; and clone it for your own use!&lt;/p&gt;
&lt;/blockquote&gt;
&lt;div class=&quot;heading-wrapper h2&quot;&gt;
&lt;h2 id=&quot;css-houdini-worklet-generator&quot;&gt;CSS Houdini Worklet Generator&lt;/h2&gt;
&lt;a class=&quot;tdbc-anchor&quot; href=&quot;https://11ty.rocks/posts/going-beyond-static-with-eleventy/#css-houdini-worklet-generator&quot; aria-labelledby=&quot;css-houdini-worklet-generator&quot;&gt;&lt;span hidden=&quot;&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;Next up is probably my most unusual idea to date.&lt;/p&gt;
&lt;p&gt;One area of CSS I hadn&#39;t had the opportunity to explore until recently was Houdini.&lt;/p&gt;
&lt;p&gt;When I went to try to understand it better, I found many wonderful resources but no existing starting environment to build from.&lt;/p&gt;
&lt;p&gt;In the case of CSS Houdini, it is actually a requirement to be running on a secure or local server. The file used for Houdini is called a worklet and is created with JavaScript. There are a few flavors of Houdini available but the currently best supported version is the Paint API. This API will look familiar to those of you who have used canvas. And a disclaimer here: everything that I just said and am about to show you was new to me, so there is ample room for improvement!&lt;/p&gt;
&lt;p&gt;Presently, this generator is setup to only create one worklet, because ultimately the idea is that the produced files can be published as a package to be available for wider consumption. However, it could be extended to create a set of related worklets.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://11ty.rocks/img/beyond-static/houdini-worklet.png&quot; alt=&quot;Preview of the generator demo Houdini worklet which draws a rectangle within the elements box at the requested coordinates, in this case a magenta rectangle over the top left behind the words &#39;Hello World&#39;&quot; /&gt;&lt;/p&gt;
&lt;p&gt;For this generator, the worklet is created all in itself, unlike the email or web component generators which compile files together.&lt;/p&gt;
&lt;p&gt;But Eleventy helps provdie the local server, and the base template to serve the worklet as well as the currently required polyfill to enable testing. Plus since Eleventy runs on Node and therefore we&#39;ve already got a &lt;code&gt;package&lt;/code&gt; file available, it made it easy to prepare it as an all-in-one solution to publish the final package from.&lt;/p&gt;
&lt;p&gt;For this generator, the benefit of Eleventy was providing a slim environment that provided the required local server and no extra fluff beyond that.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Learn more and get &lt;a href=&quot;https://github.com/5t3ph/11ty-css-houdini&quot;&gt;the CSS Houdini Generator&lt;/a&gt; on GitHub!&lt;/p&gt;
&lt;/blockquote&gt;
&lt;div class=&quot;heading-wrapper h3&quot;&gt;
&lt;h3 id=&quot;buttonbuddy&quot;&gt;ButtonBuddy&lt;/h3&gt;
&lt;a class=&quot;tdbc-anchor&quot; href=&quot;https://11ty.rocks/posts/going-beyond-static-with-eleventy/#buttonbuddy&quot; aria-labelledby=&quot;buttonbuddy&quot;&gt;&lt;span hidden=&quot;&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;Cool, so we&#39;ve talked about features inherit to Eleventy that allow us to do things beyond generate a simple static site.&lt;/p&gt;
&lt;p&gt;But what if you do need some client-side JavaScript?&lt;/p&gt;
&lt;p&gt;For most of my projects, I either really don&#39;t need any JS, or a small enough bit that I could write it vanilla with no worries about compatibility. But then I had the idea for a client-side generator that I really needed to include functionality from available packages.&lt;/p&gt;
&lt;p&gt;My web app, &lt;a href=&quot;https://buttonbuddy.dev/&quot;&gt;ButtonBuddy&lt;/a&gt;, helps you check or create an accessible color palette for your buttons, and the main package I needed to include was to do the calculations to determine the contrast ratio.&lt;/p&gt;
&lt;p&gt;With this project, I learned there were many ways folx were adding bundling or transpiling, but personally I was familiair with Parcel from projects in my previous work life.&lt;/p&gt;
&lt;p&gt;So here I need to give credit to Michelle Barker who created the &lt;a href=&quot;https://github.com/mbarker84/eleventy-parcel&quot;&gt;&lt;code&gt;eleventy-parcel&lt;/code&gt; starter&lt;/a&gt; which was a beautifully slim setup that hooked in Parcel minimally at the last step of the build process.&lt;/p&gt;
&lt;p&gt;Within no time, I was able to add in the necessary bits to my in-progress project and was off to the races using ES6 for ease of putting together the web app functionality. Did I mention Eleventy has a great community? 🙂&lt;/p&gt;
&lt;p&gt;I wanted to include this example if you have had concerns that Eleventy was going to lock you into only static without an easy plan to include modern, client-side JS when you really needed it. As I mentioned, I do have a history with React and Gatsby, and I&#39;ll say that Eleventy + Parcel got me precisely what I needed in a very efficient manner.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Check out this project at &lt;a href=&quot;https://buttonbuddy.dev/&quot;&gt;ButtonBuddy.dev&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;hr /&gt;
&lt;div class=&quot;heading-wrapper h2&quot;&gt;
&lt;h2 id=&quot;summary&quot;&gt;Summary&lt;/h2&gt;
&lt;a class=&quot;tdbc-anchor&quot; href=&quot;https://11ty.rocks/posts/going-beyond-static-with-eleventy/#summary&quot; aria-labelledby=&quot;summary&quot;&gt;&lt;span hidden=&quot;&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;Eleventy has given me a bit of a can&#39;t stop, won&#39;t stop attitude toward building for my own joy of the craft of web development. And these mini projects have been amazing for learning new things, getting feedback, and growing my network and connections to a whole new community of awesome web makers.&lt;/p&gt;
&lt;p&gt;So whether you&#39;re looking for a replacement for an older setup but otherwise content with truly static, or you&#39;re interested in upgrading your playground environment and exploiting some of the other features we talked about today, I encourage you to give Eleventy a try!&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Be sure to bookmark this site, or &lt;a href=&quot;https://11ty.rocks/feed/&quot;&gt;pick up the RSS feed&lt;/a&gt; to keep updated of new resources! &lt;a href=&quot;https://twitter.com/5t3ph&quot;&gt;Reach out on Twitter&lt;/a&gt; if you have questions or suggestions of topics to cover.&lt;/p&gt;
&lt;/blockquote&gt;
</content>
	</entry>
	
	
	<entry>
		<title>11ty CSS Houdini Worklet Generator</title>
		<link href="https://github.com/5t3ph/11ty-css-houdini"/>
		<updated>2020-12-15T00:00:00Z</updated>
		<id>https://github.com/5t3ph/11ty-css-houdini</id>
		<content type="html">&lt;p&gt;&lt;a href=&quot;https://houdini.how/&quot;&gt;CSS Houdini worklets&lt;/a&gt; require a server to run. While there are many ways to create an environment for developing and testing your worklet, as a static site generator, Eleventy provides a slim way to get setup and testing quickly so you can focus on creating your worklet!&lt;/p&gt;
&lt;p&gt;You can preview the included worklet example &lt;a href=&quot;https://codepen.io/5t3ph/pen/NWRpMbv&quot;&gt;on this CodePen&lt;/a&gt;.&lt;/p&gt;
&lt;a href=&quot;https://github.com/5t3ph/11ty-css-houdini&quot;&gt;Details and Template&lt;/a&gt;</content>
	</entry>
	
	
	<entry>
		<title>11ty Filters for Tags</title>
		<link href="https://11ty.rocks/eleventyjs/tags/"/>
		<updated>2020-11-24T00:00:00Z</updated>
		<id>https://11ty.rocks/eleventyjs/tags/</id>
		<content type="html">&lt;div class=&quot;heading-wrapper h2&quot;&gt;
&lt;h2 id=&quot;hastag-filter&quot;&gt;&lt;code&gt;hasTag&lt;/code&gt; Filter&lt;/h2&gt;
&lt;a class=&quot;tdbc-anchor&quot; href=&quot;https://11ty.rocks/eleventyjs/tags/#hastag-filter&quot; aria-labelledby=&quot;hastag-filter&quot;&gt;&lt;span hidden=&quot;&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;Useful when using a layout for multiple collection types, such as to provide a different call to action or link.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Usage&lt;/strong&gt; within a layout for a single page:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;{% if tags | hasTag(&#39;post&#39;) %}&lt;/code&gt;&lt;/p&gt;
&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;eleventyConfig&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;addFilter&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;hasTag&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;tags&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; tag&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;tags &lt;span class=&quot;token operator&quot;&gt;||&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;includes&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;tag&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;blockquote&gt;
&lt;p&gt;Could be genericized to &lt;code&gt;hasItem&lt;/code&gt; and used on &lt;em&gt;any&lt;/em&gt; array data type.&lt;/p&gt;
&lt;/blockquote&gt;
</content>
	</entry>
	
	
	<entry>
		<title>Filters for Data Arrays in 11ty</title>
		<link href="https://11ty.rocks/eleventyjs/data-arrays/"/>
		<updated>2020-11-24T00:00:00Z</updated>
		<id>https://11ty.rocks/eleventyjs/data-arrays/</id>
		<content type="html">&lt;blockquote&gt;
&lt;p&gt;These filters can be used on Eleventy collections or any custom data that presents as an array.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;div class=&quot;heading-wrapper h2&quot;&gt;
&lt;h2 id=&quot;randomitem-filter&quot;&gt;&lt;code&gt;randomItem&lt;/code&gt; Filter&lt;/h2&gt;
&lt;a class=&quot;tdbc-anchor&quot; href=&quot;https://11ty.rocks/eleventyjs/data-arrays/#randomitem-filter&quot; aria-labelledby=&quot;randomitem-filter&quot;&gt;&lt;span hidden=&quot;&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;Return a randomly picked item from a given array.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Usage&lt;/strong&gt;: &lt;code&gt;{{ for item in collections.all | randomItem }}&lt;/code&gt;&lt;/p&gt;
&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;eleventyConfig&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;addFilter&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;randomItem&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;arr&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;  arr&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;sort&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;0.5&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt; Math&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;random&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; arr&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;slice&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;div class=&quot;heading-wrapper h2&quot;&gt;
&lt;h2 id=&quot;limit-filter&quot;&gt;&lt;code&gt;limit&lt;/code&gt; Filter&lt;/h2&gt;
&lt;a class=&quot;tdbc-anchor&quot; href=&quot;https://11ty.rocks/eleventyjs/data-arrays/#limit-filter&quot; aria-labelledby=&quot;limit-filter&quot;&gt;&lt;span hidden=&quot;&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;Return a subset of array items limited to the passed number.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Usage&lt;/strong&gt;: &lt;code&gt;{{ for item in collections.all | limit(3) }}&lt;/code&gt;&lt;/p&gt;
&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;eleventyConfig&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;addFilter&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;limit&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;arr&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; limit&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; arr&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;slice&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; limit&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;div class=&quot;heading-wrapper h2&quot;&gt;
&lt;h2 id=&quot;randomlimit-filter&quot;&gt;&lt;code&gt;randomLimit&lt;/code&gt; Filter&lt;/h2&gt;
&lt;a class=&quot;tdbc-anchor&quot; href=&quot;https://11ty.rocks/eleventyjs/data-arrays/#randomlimit-filter&quot; aria-labelledby=&quot;randomlimit-filter&quot;&gt;&lt;span hidden=&quot;&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;Given a collection and a limit in addition to the current &lt;code&gt;page.url&lt;/code&gt;, returns the requested number of items excluding the current one. This is useful for showing additional posts without the current one being repeated in the list.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Usage&lt;/strong&gt;: &lt;code&gt;{{ for item in collections.all | randomLimit(3, page.url) }}&lt;/code&gt;&lt;/p&gt;
&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;eleventyConfig&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;addFilter&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;randomLimit&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;arr&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; limit&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; currPage&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token comment&quot;&gt;// Filters out current page&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; pageArr &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; arr&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;filter&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;page&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; page&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;url &lt;span class=&quot;token operator&quot;&gt;!==&lt;/span&gt; currPage&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;  &lt;span class=&quot;token comment&quot;&gt;// Randomizes remaining items&lt;/span&gt;&lt;br /&gt;  pageArr&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;sort&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;0.5&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt; Math&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;random&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;  &lt;span class=&quot;token comment&quot;&gt;// Returns array items up to limit&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; pageArr&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;slice&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; limit&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;div class=&quot;heading-wrapper h2&quot;&gt;
&lt;h2 id=&quot;pluck-filter&quot;&gt;&lt;code&gt;pluck&lt;/code&gt; Filter&lt;/h2&gt;
&lt;a class=&quot;tdbc-anchor&quot; href=&quot;https://11ty.rocks/eleventyjs/data-arrays/#pluck-filter&quot; aria-labelledby=&quot;pluck-filter&quot;&gt;&lt;span hidden=&quot;&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;The &lt;code&gt;pluck&lt;/code&gt; filter is useful if you want to return a subset of an array based on some known attribute values, such as given an array of titles.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Version 1: Check against a value array&lt;/strong&gt;:&lt;/p&gt;
&lt;pre class=&quot;language-twig&quot;&gt;&lt;code class=&quot;language-twig&quot;&gt;&lt;span class=&quot;token twig language-twig&quot;&gt;&lt;span class=&quot;token delimiter punctuation&quot;&gt;{%-&lt;/span&gt; &lt;span class=&quot;token tag-name keyword&quot;&gt;set&lt;/span&gt; pickedPosts &lt;span class=&quot;token delimiter punctuation&quot;&gt;%}&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;[&quot;Title A&quot;, &quot;Title B&quot;]&lt;br /&gt;&lt;span class=&quot;token twig language-twig&quot;&gt;&lt;span class=&quot;token delimiter punctuation&quot;&gt;{%-&lt;/span&gt; &lt;span class=&quot;token tag-name keyword&quot;&gt;endset&lt;/span&gt; &lt;span class=&quot;token delimiter punctuation&quot;&gt;-%}&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token twig language-twig&quot;&gt;&lt;span class=&quot;token delimiter punctuation&quot;&gt;{%&lt;/span&gt; &lt;span class=&quot;token tag-name keyword&quot;&gt;for&lt;/span&gt; post &lt;span class=&quot;token operator&quot;&gt;in&lt;/span&gt; collections&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;all &lt;span class=&quot;token operator&quot;&gt;|&lt;/span&gt; pluck&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;pickedPosts&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&#39;&lt;/span&gt;title&lt;span class=&quot;token punctuation&quot;&gt;&#39;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token delimiter punctuation&quot;&gt;%}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;eleventyConfig&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;addFilter&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;pluck&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;arr&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; selections&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; attr&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token comment&quot;&gt;// Assumes this is receiving a collection, hence the `data`&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token comment&quot;&gt;// If custom array such as from _data, update accordingly&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; arr&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;filter&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;item&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; selections&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;includes&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;item&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;data&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;attr&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;Version 2: Check against a single attribute&lt;/strong&gt;&lt;/p&gt;
&lt;pre class=&quot;language-twig&quot;&gt;&lt;code class=&quot;language-twig&quot;&gt;// Useful for getting a subset based on a secondary data list&lt;br /&gt;&lt;span class=&quot;token twig language-twig&quot;&gt;&lt;span class=&quot;token delimiter punctuation&quot;&gt;{%&lt;/span&gt; &lt;span class=&quot;token tag-name keyword&quot;&gt;for&lt;/span&gt; category &lt;span class=&quot;token operator&quot;&gt;in&lt;/span&gt; categories &lt;span class=&quot;token delimiter punctuation&quot;&gt;%}&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;// Then pluck just items in that &quot;category&quot;&lt;br /&gt;&lt;span class=&quot;token twig language-twig&quot;&gt;&lt;span class=&quot;token delimiter punctuation&quot;&gt;{%&lt;/span&gt; &lt;span class=&quot;token tag-name keyword&quot;&gt;for&lt;/span&gt; post &lt;span class=&quot;token operator&quot;&gt;in&lt;/span&gt; collections&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;all &lt;span class=&quot;token operator&quot;&gt;|&lt;/span&gt; pluck&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;category&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&#39;&lt;/span&gt;category&lt;span class=&quot;token punctuation&quot;&gt;&#39;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token delimiter punctuation&quot;&gt;%}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;eleventyConfig&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;addFilter&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;pluck&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;arr&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; value&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; attr&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; arr&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;filter&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;item&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; item&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;data&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;attr&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;===&lt;/span&gt; value&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
</content>
	</entry>
	
	
	<entry>
		<title>Filters for 11ty Content</title>
		<link href="https://11ty.rocks/eleventyjs/content/"/>
		<updated>2020-11-24T00:00:00Z</updated>
		<id>https://11ty.rocks/eleventyjs/content/</id>
		<content type="html">&lt;div class=&quot;heading-wrapper h2&quot;&gt;
&lt;h2 id=&quot;markdown-filter&quot;&gt;&lt;code&gt;markdown&lt;/code&gt; Filter&lt;/h2&gt;
&lt;a class=&quot;tdbc-anchor&quot; href=&quot;https://11ty.rocks/eleventyjs/content/#markdown-filter&quot; aria-labelledby=&quot;markdown-filter&quot;&gt;&lt;span hidden=&quot;&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;Sometimes you want to convert a specific bit of content into Markdown. For example, if you have created content as JSON formatted custom data within &lt;code&gt;_data&lt;/code&gt;. In that case, you maybe don&#39;t want to use pagination to create pages but instead to loop through it somewhere.&lt;/p&gt;
&lt;p&gt;By tapping into the included &lt;code&gt;markdown-it&lt;/code&gt; Markdown parser that is used by Eleventy, we can create a filter to use adhoc on content:&lt;/p&gt;
&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;// Add above your Eleventy config&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; markdownIt &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;require&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;markdown-it&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token comment&quot;&gt;// Add within your config module&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; md &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;markdownIt&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token literal-property property&quot;&gt;html&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token boolean&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;eleventyConfig&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;addFilter&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;markdown&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;content&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; md&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;render&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;content&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;To use this filter, you&#39;ll also need to pass it through the Eleventy-included &lt;code&gt;safe&lt;/code&gt; filter to render insted of escape the compiled HTML:&lt;/p&gt;
&lt;pre class=&quot;language-twig&quot;&gt;&lt;code class=&quot;language-twig&quot;&gt;&lt;span class=&quot;token twig language-twig&quot;&gt;&lt;span class=&quot;token delimiter punctuation&quot;&gt;{{&lt;/span&gt; data&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;content &lt;span class=&quot;token operator&quot;&gt;|&lt;/span&gt; markdown &lt;span class=&quot;token operator&quot;&gt;|&lt;/span&gt; safe &lt;span class=&quot;token delimiter punctuation&quot;&gt;}}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt;: Since the Markdown conversion will include elements like paragraphs, don&#39;t place the line including that content within a &lt;code&gt;&amp;lt;p&amp;gt;&lt;/code&gt; or you will end up with extra paragraphs.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;div class=&quot;heading-wrapper h2&quot;&gt;
&lt;h2 id=&quot;excerpt-filter&quot;&gt;&lt;code&gt;excerpt&lt;/code&gt; Filter&lt;/h2&gt;
&lt;a class=&quot;tdbc-anchor&quot; href=&quot;https://11ty.rocks/eleventyjs/content/#excerpt-filter&quot; aria-labelledby=&quot;excerpt-filter&quot;&gt;&lt;span hidden=&quot;&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;This filter expects the full post content - &lt;em&gt;post-processing&lt;/em&gt; - which it will strip HTML tags from and then limit to approximately the first 200 characters. The function backtracks to the space prior to the 200th character to prevent splitting words.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Usage&lt;/strong&gt;: &lt;code&gt;&amp;lt;p&amp;gt;{{ post.templateContent | excerpt }}&amp;lt;/p&amp;gt;&lt;/code&gt;&lt;/p&gt;
&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;eleventyConfig&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;addFilter&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;excerpt&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;post&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; content &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; post&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;replace&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token regex&quot;&gt;&lt;span class=&quot;token regex-delimiter&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;token regex-source language-regex&quot;&gt;(&amp;lt;([^&gt;]+)&gt;)&lt;/span&gt;&lt;span class=&quot;token regex-delimiter&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;token regex-flags&quot;&gt;gi&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; content&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;substr&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; content&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;lastIndexOf&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot; &quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;200&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;...&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;div class=&quot;heading-wrapper h2&quot;&gt;
&lt;h2 id=&quot;addnbsp-filter&quot;&gt;&lt;code&gt;addNbsp&lt;/code&gt; Filter&lt;/h2&gt;
&lt;a class=&quot;tdbc-anchor&quot; href=&quot;https://11ty.rocks/eleventyjs/content/#addnbsp-filter&quot; aria-labelledby=&quot;addnbsp-filter&quot;&gt;&lt;span hidden=&quot;&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;blockquote&gt;
&lt;p&gt;This filter is already available to you are using the &lt;a href=&quot;https://www.npmjs.com/package/@11tyrocks/eleventy-plugin-social-images&quot;&gt;Social Images plugin&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;This filter intakes a string, such as for a page title, and inserts a non-breaking space - &lt;code&gt;nbsp;&lt;/code&gt; - between the last two words to prevent a single word dangling on the last line (called an &amp;quot;orphan&amp;quot; by typographers).&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Usage&lt;/strong&gt;: &lt;code&gt;{{ title | addNbsp }}&lt;/code&gt;&lt;/p&gt;
&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;eleventyConfig&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;addFilter&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;addNbsp&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;str&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;!&lt;/span&gt;str&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token keyword&quot;&gt;let&lt;/span&gt; title &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; str&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;replace&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token regex&quot;&gt;&lt;span class=&quot;token regex-delimiter&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;token regex-source language-regex&quot;&gt;((.*)\s(.*))$&lt;/span&gt;&lt;span class=&quot;token regex-delimiter&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;token regex-flags&quot;&gt;g&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;$2&amp;amp;nbsp;$3&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;  title &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; title&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;replace&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token regex&quot;&gt;&lt;span class=&quot;token regex-delimiter&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;token regex-source language-regex&quot;&gt;&quot;(.*)&quot;&lt;/span&gt;&lt;span class=&quot;token regex-delimiter&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;token regex-flags&quot;&gt;g&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;\\&quot;$1\\&quot;&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; title&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;div class=&quot;heading-wrapper h2&quot;&gt;
&lt;h2 id=&quot;stripfilename-filter&quot;&gt;&lt;code&gt;stripFilename&lt;/code&gt; Filter&lt;/h2&gt;
&lt;a class=&quot;tdbc-anchor&quot; href=&quot;https://11ty.rocks/eleventyjs/content/#stripfilename-filter&quot; aria-labelledby=&quot;stripfilename-filter&quot;&gt;&lt;span hidden=&quot;&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;Useful if using a value such as &lt;code&gt;layout&lt;/code&gt; - which returns the full filename - in an alternate scenario, such as for part of a class name as shown.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Usage&lt;/strong&gt;: &lt;code&gt;&amp;lt;body class=&amp;quot;layout--{{ layout | stripFilename }}&amp;quot;&amp;gt;&lt;/code&gt;&lt;/p&gt;
&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;eleventyConfig&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;addFilter&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;stripFilename&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;file&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; file&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;replace&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token regex&quot;&gt;&lt;span class=&quot;token regex-delimiter&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;token regex-source language-regex&quot;&gt;\.[^/.]+$&lt;/span&gt;&lt;span class=&quot;token regex-delimiter&quot;&gt;/&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt;: If actually using with &lt;code&gt;layout&lt;/code&gt;, and your layouts are chained, it will return the &amp;quot;last&amp;quot; layout in the chain. Ex: if the filter code lives in &lt;code&gt;base.njk&lt;/code&gt; but the page content is &lt;code&gt;post.njk&lt;/code&gt;, will return &lt;code&gt;post&lt;/code&gt; when using this filter.&lt;/p&gt;
&lt;/blockquote&gt;
</content>
	</entry>
	
	
	<entry>
		<title>Customizing 11ty Collections</title>
		<link href="https://11ty.rocks/eleventyjs/collections/"/>
		<updated>2020-11-24T00:00:00Z</updated>
		<id>https://11ty.rocks/eleventyjs/collections/</id>
		<content type="html">&lt;div class=&quot;heading-wrapper h2&quot;&gt;
&lt;h2 id=&quot;collections-from-custom-data&quot;&gt;Collections from Custom Data&lt;/h2&gt;
&lt;a class=&quot;tdbc-anchor&quot; href=&quot;https://11ty.rocks/eleventyjs/collections/#collections-from-custom-data&quot; aria-labelledby=&quot;collections-from-custom-data&quot;&gt;&lt;span hidden=&quot;&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;If you have custom data that you don&#39;t need paginated but do need to customize the returned items, here&#39;s how to create it as a collection.&lt;/p&gt;
&lt;p&gt;In this example, replace &lt;code&gt;customData&lt;/code&gt; with the filename of your custom data.&lt;/p&gt;
&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;eleventyConfig&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;addCollection&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;customDataCollection&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;collection&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; allItems &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; collection&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;getAll&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;data&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;customData&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;  &lt;span class=&quot;token comment&quot;&gt;// Filter or use another method to select the items you want&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token comment&quot;&gt;// for the collection&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; allItems&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;filter&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;item&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token comment&quot;&gt;// ...&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;div class=&quot;heading-wrapper h2&quot;&gt;
&lt;h2 id=&quot;randomizedposts-collection&quot;&gt;&lt;code&gt;randomizedPosts&lt;/code&gt; Collection&lt;/h2&gt;
&lt;a class=&quot;tdbc-anchor&quot; href=&quot;https://11ty.rocks/eleventyjs/collections/#randomizedposts-collection&quot; aria-labelledby=&quot;randomizedposts-collection&quot;&gt;&lt;span hidden=&quot;&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;Create a randomized version of a tag collection.&lt;/p&gt;
&lt;p&gt;As opposed to the &lt;a href=&quot;https://11ty.rocks/eleventyjs/data-arrays/&quot;&gt;random filters&lt;/a&gt;, a collection will persist throughout your site, whereas filters used on multiple pages will produce randomized results per page.&lt;/p&gt;
&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;eleventyConfig&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;addCollection&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;randomizedPosts&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;collection&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;br /&gt;    collection&lt;br /&gt;      &lt;span class=&quot;token comment&quot;&gt;// Change to the name of your tag&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;getFilteredByTag&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;post&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;sort&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;0.5&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt; Math&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;random&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;token comment&quot;&gt;// Optional limit, remove if unwanted&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;slice&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;div class=&quot;heading-wrapper h2&quot;&gt;
&lt;h2 id=&quot;collections-based-on-frontmatter&quot;&gt;Collections Based on Frontmatter&lt;/h2&gt;
&lt;a class=&quot;tdbc-anchor&quot; href=&quot;https://11ty.rocks/eleventyjs/collections/#collections-based-on-frontmatter&quot; aria-labelledby=&quot;collections-based-on-frontmatter&quot;&gt;&lt;span hidden=&quot;&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;Useful for when you may not want to create the collections by duplicating tags and instead use a custom frontmatter key.&lt;/p&gt;
&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;eleventyConfig&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;addCollection&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;specialCollection&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;collection&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; collection&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;getAll&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;filter&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;post&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; post&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;data&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;customKey&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
</content>
	</entry>
	
	
	<entry>
		<title>Managing `.env` Variables</title>
		<link href="https://11ty.rocks/tips/env-variables/"/>
		<updated>2020-11-23T00:00:00Z</updated>
		<id>https://11ty.rocks/tips/env-variables/</id>
		<content type="html">&lt;p&gt;Environment variables are a way to retrieve values that may come from build processes, and are sometimes sensitive, like API keys. For local development access, those are typically stored in a &lt;code&gt;.env&lt;/code&gt; file at the root of your site, and &lt;em&gt;not checked in&lt;/em&gt; to version control in order to keep them private.&lt;/p&gt;
&lt;div class=&quot;heading-wrapper h2&quot;&gt;
&lt;h2 id=&quot;creating-and-accessing-env-variables&quot;&gt;Creating and Accessing &lt;code&gt;.env&lt;/code&gt; Variables&lt;/h2&gt;
&lt;a class=&quot;tdbc-anchor&quot; href=&quot;https://11ty.rocks/tips/env-variables/#creating-and-accessing-env-variables&quot; aria-labelledby=&quot;creating-and-accessing-env-variables&quot;&gt;&lt;span hidden=&quot;&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;You you may want to create your own variables to determine the difference between your &lt;code&gt;production&lt;/code&gt; vs &lt;code&gt;development&lt;/code&gt; environment.&lt;/p&gt;
&lt;p&gt;For this, you&#39;ll start with a modification to your build scripts, such as:&lt;/p&gt;
&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token string-property property&quot;&gt;&quot;start&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;cross-env ELEVENTY_ENV=dev eleventy --serve&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token string-property property&quot;&gt;&quot;build&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;cross-env ELEVENTY_ENV=prod eleventy&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;em&gt;I&#39;m including &lt;code&gt;cross-env&lt;/code&gt; for cross-platform compatibility&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;Then add to a &lt;code&gt;_data&lt;/code&gt; file of your choice, perhaps to &lt;a href=&quot;https://11ty.rocks/tips/site-metadata/&quot;&gt;your site&#39;s &lt;code&gt;meta.js&lt;/code&gt;&lt;/a&gt; or a dedicated file:&lt;/p&gt;
&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;module&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;exports &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token literal-property property&quot;&gt;env&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; process&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;env&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token constant&quot;&gt;ELEVENTY_ENV&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;div class=&quot;heading-wrapper h3&quot;&gt;
&lt;h3 id=&quot;access-env-value-with-templating&quot;&gt;Access &lt;code&gt;.env&lt;/code&gt; Value With Templating&lt;/h3&gt;
&lt;a class=&quot;tdbc-anchor&quot; href=&quot;https://11ty.rocks/tips/env-variables/#access-env-value-with-templating&quot; aria-labelledby=&quot;access-env-value-with-templating&quot;&gt;&lt;span hidden=&quot;&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;Then you can output the value as demonstrated for the other &lt;code&gt;meta&lt;/code&gt; keys, or use within templating such as to control whether or not analytics scripts are included:&lt;/p&gt;
&lt;pre class=&quot;language-twig&quot;&gt;&lt;code class=&quot;language-twig&quot;&gt;&lt;span class=&quot;token twig language-twig&quot;&gt;&lt;span class=&quot;token delimiter punctuation&quot;&gt;{%&lt;/span&gt; &lt;span class=&quot;token tag-name keyword&quot;&gt;if&lt;/span&gt; meta&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;env &lt;span class=&quot;token operator&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&#39;&lt;/span&gt;prod&lt;span class=&quot;token punctuation&quot;&gt;&#39;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token delimiter punctuation&quot;&gt;%}&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;// analytics here&lt;br /&gt;&lt;span class=&quot;token twig language-twig&quot;&gt;&lt;span class=&quot;token delimiter punctuation&quot;&gt;{%&lt;/span&gt; &lt;span class=&quot;token tag-name keyword&quot;&gt;endif&lt;/span&gt; &lt;span class=&quot;token delimiter punctuation&quot;&gt;%}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;div class=&quot;heading-wrapper h3&quot;&gt;
&lt;h3 id=&quot;access-env-values-in-eleventyjs&quot;&gt;Access &lt;code&gt;.env&lt;/code&gt; Values in &lt;code&gt;.eleventy.js&lt;/code&gt;&lt;/h3&gt;
&lt;a class=&quot;tdbc-anchor&quot; href=&quot;https://11ty.rocks/tips/env-variables/#access-env-values-in-eleventyjs&quot; aria-labelledby=&quot;access-env-values-in-eleventyjs&quot;&gt;&lt;span hidden=&quot;&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;If you are trying to access environment values in &lt;code&gt;.eleventy.js&lt;/code&gt;, you will access them directly as &lt;code&gt;process.env.ELEVENTY_ENV&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;If you set &lt;code&gt;.env&lt;/code&gt; variables in an actual &lt;code&gt;.env&lt;/code&gt; file and/or as part of your build pipeline, you will need to include the following in the custom &lt;code&gt;_data&lt;/code&gt; or &lt;code&gt;.eleventy.js&lt;/code&gt; file:&lt;/p&gt;
&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;// First `npm install dotenv`&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token function&quot;&gt;require&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;dotenv&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;config&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token comment&quot;&gt;// Example access&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;token constant&quot;&gt;API_KEY&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; process&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;env&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token constant&quot;&gt;API_KEY&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
</content>
	</entry>
	
	
	<entry>
		<title>.eleventy.js Config Samples</title>
		<link href="/eleventyjs/"/>
		<updated>2020-11-23T00:00:00Z</updated>
		<id>/eleventyjs/</id>
		<content type="html">&lt;p&gt;A collection of filters, shortcodes, and other tips for extending 11ty, such as working with dates and extending built-in filters.&lt;/p&gt;
&lt;a href=&quot;/eleventyjs/&quot;&gt;View All Samples&lt;/a&gt;</content>
	</entry>
	
	
	<entry>
		<title>11ty Slugs and Anchors</title>
		<link href="https://11ty.rocks/eleventyjs/slugs-anchors/"/>
		<updated>2020-11-23T00:00:00Z</updated>
		<id>https://11ty.rocks/eleventyjs/slugs-anchors/</id>
		<content type="html">&lt;div class=&quot;heading-wrapper h2&quot;&gt;
&lt;h2 id=&quot;slug-filter-extension&quot;&gt;&lt;code&gt;slug&lt;/code&gt; Filter Extension&lt;/h2&gt;
&lt;a class=&quot;tdbc-anchor&quot; href=&quot;https://11ty.rocks/eleventyjs/slugs-anchors/#slug-filter-extension&quot; aria-labelledby=&quot;slug-filter-extension&quot;&gt;&lt;span hidden=&quot;&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;The default &lt;code&gt;slug&lt;/code&gt; filter uses &lt;a href=&quot;https://www.npmjs.com/package/slugify&quot;&gt;slugify&lt;/a&gt; under the hood, but sometimes the default behavior isn&#39;t quite enough if you are using special characters, including emoji.&lt;/p&gt;
&lt;p&gt;We can override the filter to enable &lt;code&gt;strict&lt;/code&gt; mode, enforce lowercasing, and &lt;em&gt;optionally&lt;/em&gt; add any other characters you encounter being problematic. In this case, I&#39;m enforcing removing &lt;code&gt;&amp;quot;&lt;/code&gt; because I have experienced issues without explicitly defining it.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Usage&lt;/strong&gt;: &lt;code&gt;{{ title | slug }}&lt;/code&gt;&lt;/p&gt;
&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;// Import prior to `module.exports` within `.eleventy.js`&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; slugify &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;require&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;slugify&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;eleventyConfig&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;addFilter&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;slug&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;str&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;!&lt;/span&gt;str&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;  &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;slugify&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;str&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token literal-property property&quot;&gt;lower&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token boolean&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token literal-property property&quot;&gt;strict&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token boolean&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token literal-property property&quot;&gt;remove&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token regex&quot;&gt;&lt;span class=&quot;token regex-delimiter&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;token regex-source language-regex&quot;&gt;[&quot;]&lt;/span&gt;&lt;span class=&quot;token regex-delimiter&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;token regex-flags&quot;&gt;g&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;div class=&quot;heading-wrapper h2&quot;&gt;
&lt;h2 id=&quot;enable-anchor-links-on-content-headings&quot;&gt;Enable anchor links on content headings&lt;/h2&gt;
&lt;a class=&quot;tdbc-anchor&quot; href=&quot;https://11ty.rocks/eleventyjs/slugs-anchors/#enable-anchor-links-on-content-headings&quot; aria-labelledby=&quot;enable-anchor-links-on-content-headings&quot;&gt;&lt;span hidden=&quot;&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;Eleventy uses &lt;a href=&quot;https://www.npmjs.com/package/markdown-it&quot;&gt;markdown-it&lt;/a&gt; for Markdown parsing, and shows a few options for configuring it in &lt;a href=&quot;https://www.11ty.dev/docs/languages/markdown/&quot;&gt;the 11ty docs&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;There are several plugins you can add to extend markdown-it, but in this example we are adding anchor links to our content headings. We&#39;re also extending the idea from our &lt;code&gt;slug&lt;/code&gt; update to update which characters are removed and replaced to create anchors.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Kudos to &lt;a href=&quot;https://github.com/nhoizey/nicolas-hoizey.com/blob/main/.eleventy.js#L102-L133&quot;&gt;Nicolas Hoizey&lt;/a&gt; for the concise method of modifying the &lt;code&gt;markdown-it-anchor&lt;/code&gt; behavior to add a wrapping div to assist in styling placement of the anchor symbol. And for &lt;a href=&quot;https://github.com/valeriangalliat/markdown-it-anchor/issues/82&quot;&gt;raising the issue&lt;/a&gt; to improve the base behavior of this plugin.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;The &lt;code&gt;markdown-it-anchor&lt;/code&gt; plugin added &lt;a href=&quot;https://github.com/valeriangalliat/markdown-it-anchor/tree/master#permalinks&quot;&gt;three permalink output options&lt;/a&gt; to assist with accessibility. This snippet uses the &lt;code&gt;linkInsideHeader&lt;/code&gt; option with a custom &lt;code&gt;symbol&lt;/code&gt; and &lt;code&gt;permalink&lt;/code&gt; render function, which produces output like the following that also adds a wrapping &lt;code&gt;.heading-wrapper&lt;/code&gt;. I&#39;ve also selected the &lt;code&gt;aria-labelledby&lt;/code&gt; option to prevent the extra text showing up in RSS feeds and search engine results.&lt;/p&gt;
&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;// npm install --save-dev markdown-it-anchor slugify&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token comment&quot;&gt;// Import prior to `module.exports` within `.eleventy.js`&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; markdownIt &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;require&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;markdown-it&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; markdownItAnchor &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;require&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;markdown-it-anchor&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token comment&quot;&gt;// If not already added from previous tip&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; slugify &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;require&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;slugify&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; linkAfterHeader &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; markdownItAnchor&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;permalink&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;linkAfterHeader&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token keyword&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;anchor&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token literal-property property&quot;&gt;symbol&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;&amp;lt;span hidden&gt;#&amp;lt;/span&gt;&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token literal-property property&quot;&gt;style&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;aria-labelledby&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; markdownItAnchorOptions &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token literal-property property&quot;&gt;level&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token function-variable function&quot;&gt;slugify&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;str&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token function&quot;&gt;slugify&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;str&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;token literal-property property&quot;&gt;lower&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token boolean&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;token literal-property property&quot;&gt;strict&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token boolean&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;token literal-property property&quot;&gt;remove&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token regex&quot;&gt;&lt;span class=&quot;token regex-delimiter&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;token regex-source language-regex&quot;&gt;[&quot;]&lt;/span&gt;&lt;span class=&quot;token regex-delimiter&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;token regex-flags&quot;&gt;g&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token literal-property property&quot;&gt;tabIndex&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token boolean&quot;&gt;false&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token function&quot;&gt;permalink&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;slug&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; opts&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; state&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; idx&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;    state&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;tokens&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;splice&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;br /&gt;      idx&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;      Object&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;assign&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;state&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;Token&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;div_open&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;div&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token comment&quot;&gt;// Add class &quot;header-wrapper [h1 or h2 or h3]&quot;&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token literal-property property&quot;&gt;attrs&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;class&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token template-string&quot;&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;heading-wrapper &lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;${&lt;/span&gt;state&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;tokens&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;idx&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;tag&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token literal-property property&quot;&gt;block&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token boolean&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    state&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;tokens&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;splice&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;br /&gt;      idx &lt;span class=&quot;token operator&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;      Object&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;assign&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;state&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;Token&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;div_close&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;div&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token literal-property property&quot;&gt;block&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token boolean&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    &lt;span class=&quot;token function&quot;&gt;linkAfterHeader&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;slug&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; opts&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; state&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; idx &lt;span class=&quot;token operator&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token comment&quot;&gt;/* Markdown Overrides */&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;let&lt;/span&gt; markdownLibrary &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;markdownIt&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token literal-property property&quot;&gt;html&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token boolean&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;use&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;markdownItAnchor&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; markdownItAnchorOptions&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token comment&quot;&gt;// This is the part that tells 11ty to swap to our custom config&lt;/span&gt;&lt;br /&gt;eleventyConfig&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;setLibrary&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;md&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; markdownLibrary&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;Example output&lt;/strong&gt;:&lt;/p&gt;
&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;div&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;heading-wrapper h2&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;h2&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;enable-anchor-links-on-content-headings&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;Enable anchor links on content headings&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;h2&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;a&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;tdbc-anchor&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token attr-name&quot;&gt;href&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;#enable-anchor-links-on-content-headings&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token attr-name&quot;&gt;aria-labelledby&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;enable-anchor-links-on-content-headings&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;span&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;hidden&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;#&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;span&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;a&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;div&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Why use &lt;code&gt;hidden&lt;/code&gt;? Because RSS, search engine results, and &amp;quot;reader mode&amp;quot; will (usually) respect it and prevent those environments from showing the anchor symbol.&lt;/p&gt;
&lt;p&gt;You&#39;ll want the following CSS or similar to handle showing the anchor link symbol on your website:&lt;/p&gt;
&lt;pre class=&quot;language-css&quot;&gt;&lt;code class=&quot;language-css&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;/* Make the &#39;#&#39; anchor visible on your site */&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token selector&quot;&gt;.anchor hidden&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token property&quot;&gt;display&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; block&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
</content>
	</entry>
	
	
	<entry>
		<title>11ty Date Shortcodes and Filters</title>
		<link href="https://11ty.rocks/eleventyjs/dates/"/>
		<updated>2020-11-23T00:00:00Z</updated>
		<id>https://11ty.rocks/eleventyjs/dates/</id>
		<content type="html">&lt;div class=&quot;heading-wrapper h2&quot;&gt;
&lt;h2 id=&quot;year-shortcode&quot;&gt;&lt;code&gt;year&lt;/code&gt; Shortcode&lt;/h2&gt;
&lt;a class=&quot;tdbc-anchor&quot; href=&quot;https://11ty.rocks/eleventyjs/dates/#year-shortcode&quot; aria-labelledby=&quot;year-shortcode&quot;&gt;&lt;span hidden=&quot;&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;Get the current year - super useful for copyright dates.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Usage&lt;/strong&gt;: &lt;code&gt;{% year %}&lt;/code&gt;&lt;/p&gt;
&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;eleventyConfig&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;addShortcode&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;year&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token template-string&quot;&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Date&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;getFullYear&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;div class=&quot;heading-wrapper h2&quot;&gt;
&lt;h2 id=&quot;postdate-filter&quot;&gt;&lt;code&gt;postDate&lt;/code&gt; Filter&lt;/h2&gt;
&lt;a class=&quot;tdbc-anchor&quot; href=&quot;https://11ty.rocks/eleventyjs/dates/#postdate-filter&quot; aria-labelledby=&quot;postdate-filter&quot;&gt;&lt;span hidden=&quot;&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;Eleventy uses &lt;a href=&quot;https://moment.github.io/luxon/&quot;&gt;Luxon&lt;/a&gt; for dates, which is a lighter weight alternative to Moment (but made by Moment).&lt;/p&gt;
&lt;p&gt;By importing &lt;code&gt;DateTime&lt;/code&gt; from &lt;code&gt;luxon&lt;/code&gt; you are provided a deep toolbox of date methods.&lt;/p&gt;
&lt;p&gt;Since this is a filter, and you&#39;ll likely use it to pass &lt;code&gt;{{ page.date | postDate }}&lt;/code&gt;, the format at that point is, ex: &lt;code&gt;(Sun Dec 31 2017 18:00:00 GMT-0600 (Central Standard Time)&lt;/code&gt; which to Luxon is the &lt;code&gt;JSDate&lt;/code&gt; format.&lt;/p&gt;
&lt;p&gt;The output as shown will be &lt;code&gt;Nov 23, 2020&lt;/code&gt;, or you can update it to another option &lt;a href=&quot;https://moment.github.io/luxon/docs/class/src/datetime.js~DateTime.html&quot;&gt;referenced in the Luxon docs on DateTime&lt;/a&gt;.&lt;/p&gt;
&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;// Import prior to `module.exports` within `.eleventy.js`&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; DateTime &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;require&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;luxon&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;eleventyConfig&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;addFilter&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;postDate&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;dateObj&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; DateTime&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;fromJSDate&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;dateObj&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;toLocaleString&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;DateTime&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token constant&quot;&gt;DATE_MED&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
</content>
	</entry>
	
	
	<entry>
		<title>Email Generator</title>
		<link href="https://github.com/5t3ph/11ty-email-generator"/>
		<updated>2020-11-14T00:00:00Z</updated>
		<id>https://github.com/5t3ph/11ty-email-generator</id>
		<content type="html">&lt;p&gt;Generate simple, responsive email templates, with inlined CSS on build.&lt;/p&gt;
&lt;p&gt;Use the Sass theme setup to re-brand the default template, and use the frontmatter keys for flexibilty in the layout. Check out the README for additional tips on creating emails.&lt;/p&gt;
&lt;a href=&quot;https://github.com/5t3ph/11ty-email-generator&quot;&gt;Create Your Emails&lt;/a&gt;</content>
	</entry>
	
	
	<entry>
		<title>Plugin: Social Images</title>
		<link href="https://www.npmjs.com/package/@11tyrocks/eleventy-plugin-social-images"/>
		<updated>2020-11-01T00:00:00Z</updated>
		<id>https://www.npmjs.com/package/@11tyrocks/eleventy-plugin-social-images</id>
		<content type="html">&lt;p&gt;&lt;a href=&quot;https://dev.to/5t3ph/automated-social-sharing-images-with-puppeteer-11ty-and-netlify-22ln&quot;&gt;Based on my tutorial&lt;/a&gt;, this package creates dynamic images sized for social media tags (particularly Twitter and Facebook) based on your available pages. Use one of &lt;a href=&quot;https://github.com/5t3ph/eleventy-plugin-social-images/tree/main/themes&quot;&gt;the predefined color themes&lt;/a&gt;, or define your own style, template, or both to customize the layout (like &lt;a href=&quot;https://11ty.rocks/img/previews/create-your-first-basic-11ty-website.png&quot;&gt;the ones in use on 11ty Rocks&lt;/a&gt;).&lt;/p&gt;
&lt;p&gt;Configure the CLI script to run after your Eleventy build, and by default images will be created in &lt;code&gt;_site/previews/&lt;/code&gt; as png images. Use the CLI options to define a custom &lt;code&gt;outputDir&lt;/code&gt; and/or a custom &lt;code&gt;imageDir&lt;/code&gt;.&lt;/p&gt;
&lt;a href=&quot;https://www.npmjs.com/package/@11tyrocks/eleventy-plugin-social-images&quot;&gt;Docs and Install&lt;/a&gt;</content>
	</entry>
	
	
	<entry>
		<title>Eleventy Plugin Template</title>
		<link href="https://github.com/5t3ph/eleventy-plugin-template"/>
		<updated>2020-10-31T00:00:00Z</updated>
		<id>https://github.com/5t3ph/eleventy-plugin-template</id>
		<content type="html">&lt;p&gt;Kickstart your 11ty plugin project with this template that includes a barebones 11ty build to test your functionality, and docs on how to test your plugin locally.&lt;/p&gt;
&lt;p&gt;Also includes a boilerplate for your plugin README, and demonstrates setting up plugin config defaults.&lt;/p&gt;
&lt;a href=&quot;https://github.com/5t3ph/eleventy-plugin-template&quot;&gt;Build Your Plugin&lt;/a&gt;</content>
	</entry>
	
	
	<entry>
		<title>Create Your First Basic 11ty Website</title>
		<link href="https://11ty.rocks/posts/create-your-first-basic-11ty-website/"/>
		<updated>2020-10-31T00:00:00Z</updated>
		<id>https://11ty.rocks/posts/create-your-first-basic-11ty-website/</id>
		<content type="html">&lt;p&gt;The following tutorial is based on a live stream I did with &lt;a href=&quot;https://www.twitch.tv/edieblu&quot;&gt;Eva on Twitch&lt;/a&gt;. If you prefer, you can watch the recording below, or read on for the step-by-step instructions for creating your first basic 11ty website.&lt;/p&gt;
&lt;div class=&quot;tdbc-video&quot;&gt;&lt;iframe src=&quot;https://www.youtube.com/embed/2By887u7b0A&quot; frameborder=&quot;0&quot; allow=&quot;accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture&quot; allowfullscreen=&quot;&quot;&gt;&lt;/iframe&gt;&lt;/div&gt;
&lt;blockquote&gt;
&lt;p&gt;Check out &lt;a href=&quot;https://github.com/5t3ph/11ty-basics&quot;&gt;the final project on GitHub&lt;/a&gt;, and &lt;a href=&quot;https://11ty-basics.netlify.app/&quot;&gt;the deployed examply on Netlify&lt;/a&gt;.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;div class=&quot;heading-wrapper h2&quot;&gt;
&lt;h2 id=&quot;begin-the-project&quot;&gt;Begin the Project&lt;/h2&gt;
&lt;a class=&quot;tdbc-anchor&quot; href=&quot;https://11ty.rocks/posts/create-your-first-basic-11ty-website/#begin-the-project&quot; aria-labelledby=&quot;begin-the-project&quot;&gt;&lt;span hidden=&quot;&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;Open a new directory in your editor of choice, and then in your terminal do the following command to start a brand new project:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;npm init -y&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;Then, install Eleventy. For a basic site like this, eleventy itself is our &lt;em&gt;only&lt;/em&gt; dependency!&lt;/p&gt;
&lt;p&gt;&lt;code&gt;npm install @11ty/eleventy&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;Once the installs complete, open &lt;code&gt;package.json&lt;/code&gt; and update the default &lt;code&gt;scripts&lt;/code&gt; section to the following. This enables a &lt;code&gt;start&lt;/code&gt; command to run 11ty with hot-reload, which is provided by Browsersync that comes bundled as part of 11ty&#39;s &lt;code&gt;--serve&lt;/code&gt; directive.&lt;/p&gt;
&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;  &lt;span class=&quot;token string-property property&quot;&gt;&quot;scripts&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token string-property property&quot;&gt;&quot;start&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;npx @11ty/eleventy --serve&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token string-property property&quot;&gt;&quot;build&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;npx @11ty/eleventy&quot;&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;div class=&quot;heading-wrapper h2&quot;&gt;
&lt;h2 id=&quot;add-eleventy-config&quot;&gt;Add Eleventy Config&lt;/h2&gt;
&lt;a class=&quot;tdbc-anchor&quot; href=&quot;https://11ty.rocks/posts/create-your-first-basic-11ty-website/#add-eleventy-config&quot; aria-labelledby=&quot;add-eleventy-config&quot;&gt;&lt;span hidden=&quot;&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;Next, we want to begin our Eleventy config. This initial addition is completely optional, but we will be adding more items to this config later.&lt;/p&gt;
&lt;p&gt;Create the file &lt;code&gt;.eleventy.js&lt;/code&gt; at the root of the project.&lt;/p&gt;
&lt;p&gt;Then, add the following as the contents.&lt;/p&gt;
&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;module&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function-variable function&quot;&gt;exports&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;eleventyConfig&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token literal-property property&quot;&gt;dir&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;token literal-property property&quot;&gt;input&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;src&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;token literal-property property&quot;&gt;output&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;public&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The first change here is setting the &lt;code&gt;input&lt;/code&gt; directory to &lt;code&gt;src&lt;/code&gt; - as in, the directory 11ty will watch for changes and use to build for production. Then, we change the &lt;code&gt;output&lt;/code&gt; directory to &lt;code&gt;public&lt;/code&gt; which means that&#39;s where our production-ready files for use by &lt;code&gt;localhost&lt;/code&gt; and a hosting server will be published.&lt;/p&gt;
&lt;div class=&quot;heading-wrapper h3&quot;&gt;
&lt;h3 id=&quot;create-gitignore&quot;&gt;Create &lt;code&gt;.gitignore&lt;/code&gt;&lt;/h3&gt;
&lt;a class=&quot;tdbc-anchor&quot; href=&quot;https://11ty.rocks/posts/create-your-first-basic-11ty-website/#create-gitignore&quot; aria-labelledby=&quot;create-gitignore&quot;&gt;&lt;span hidden=&quot;&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;At this point, you may want to take a minute to setup your &lt;code&gt;.gitignore&lt;/code&gt; if you will be using version control. At minimum, here are the contents for that:&lt;/p&gt;
&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;# dependencies installed by npm&lt;/span&gt;&lt;br /&gt;node_modules&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token comment&quot;&gt;# build artefacts&lt;/span&gt;&lt;br /&gt;public&lt;/code&gt;&lt;/pre&gt;
&lt;div class=&quot;heading-wrapper h2&quot;&gt;
&lt;h2 id=&quot;run-the-develop-server&quot;&gt;Run the Develop Server&lt;/h2&gt;
&lt;a class=&quot;tdbc-anchor&quot; href=&quot;https://11ty.rocks/posts/create-your-first-basic-11ty-website/#run-the-develop-server&quot; aria-labelledby=&quot;run-the-develop-server&quot;&gt;&lt;span hidden=&quot;&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;We have our base in place, so let&#39;s try to run the project using our &lt;code&gt;start&lt;/code&gt; command:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;npm start&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;And... oops! You will get an error message: &amp;quot;Cannot GET /&amp;quot;. That&#39;s because 11ty will literally &lt;em&gt;only&lt;/em&gt; serve up what you give it. So, we first have to create an &lt;code&gt;index&lt;/code&gt; file in our input directory, which we defined in &lt;code&gt;.eleventyconfig&lt;/code&gt; would be called &lt;code&gt;src&lt;/code&gt;.&lt;/p&gt;
&lt;div class=&quot;heading-wrapper h3&quot;&gt;
&lt;h3 id=&quot;create-the-site-index-file&quot;&gt;Create the Site Index File&lt;/h3&gt;
&lt;a class=&quot;tdbc-anchor&quot; href=&quot;https://11ty.rocks/posts/create-your-first-basic-11ty-website/#create-the-site-index-file&quot; aria-labelledby=&quot;create-the-site-index-file&quot;&gt;&lt;span hidden=&quot;&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;So, perform the following steps:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Create &lt;code&gt;src/&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Create &lt;code&gt;src/index.md&lt;/code&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;If you like, add some content into the Markdown file.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Markdown is one of 11 available templating languages you can use to create your 11ty site. &lt;a href=&quot;https://www.11ty.dev/docs/languages/&quot;&gt;Check out the other options &amp;gt;&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Then, refresh the browser page and you will see the content you just added or a blank page if you added no content.&lt;/p&gt;
&lt;p&gt;However, Browsersync is not yet activating which is why you had to manually refresh. To understand why, trigger your browser&#39;s context menu to &amp;quot;View Source&amp;quot;. As you&#39;ll see, there is no markup being rendered besides what&#39;s needed for the conversion of Markdown to HTML.&lt;/p&gt;
&lt;p&gt;For Browsersync to run (and to keep inline with overall standards) we need to provide a way to generate what is often called the HTML5 boilerplate that includes &lt;code&gt;&amp;lt;html&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;head&amp;gt;&lt;/code&gt;, and &lt;code&gt;&amp;lt;body&amp;gt;&lt;/code&gt;. Once the rendered markup includes &lt;code&gt;&amp;lt;head&amp;gt;&lt;/code&gt; then Browsersync will be injected and provide the hot-reload for future edits.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Troubleshooting tip&lt;/strong&gt; - if Browsersync isn&#39;t working, this is a good sign that you&#39;ve forgotten to supply the HTML boilerplate.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;div class=&quot;heading-wrapper h2&quot;&gt;
&lt;h2 id=&quot;create-the-base-layout&quot;&gt;Create the &lt;code&gt;base&lt;/code&gt; Layout&lt;/h2&gt;
&lt;a class=&quot;tdbc-anchor&quot; href=&quot;https://11ty.rocks/posts/create-your-first-basic-11ty-website/#create-the-base-layout&quot; aria-labelledby=&quot;create-the-base-layout&quot;&gt;&lt;span hidden=&quot;&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;To resolve needing to provide the HTML5 boilerplate, we&#39;ll use 11ty&#39;s concept of &lt;em&gt;layouts&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;One of the expected 11ty directories is called &lt;code&gt;_includes&lt;/code&gt; and it&#39;s where you can add layouts.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;You may also be familiar with the concept of templates, or template partials, and you may also place those in &lt;code&gt;_includes&lt;/code&gt;.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;A common 11ty convention is to create this essential HTML structure within &lt;code&gt;_includes/base.njk&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;If you are in a code editor that supports Emmet, you can use the command &lt;code&gt;html:5&lt;/code&gt; to instantly populate it with the HTML5 boilerplate.&lt;/p&gt;
&lt;p&gt;Then, we&#39;ll prepare this &lt;code&gt;base.njk&lt;/code&gt; to start accepting some Frontmatter values that we will add to our content. First, we&#39;ll plan for a &lt;code&gt;title&lt;/code&gt; value.&lt;/p&gt;
&lt;p&gt;Since we&#39;ve created this as a Nunjucks template file (&lt;code&gt;.njk&lt;/code&gt;), we can use the double-curly format to access the &lt;code&gt;title&lt;/code&gt; Frontmatter variable, like so: &lt;code&gt;{{ title }}&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;We&#39;ll add it to the &lt;code&gt;&amp;lt;title&amp;gt;&lt;/code&gt; and create it as an &lt;code&gt;&amp;lt;h1&amp;gt;&lt;/code&gt; within the &lt;code&gt;&amp;lt;body&amp;gt;&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Finally, we need to designate where the body of the markdown file should go. This is available in the Eleventy global page variable of &lt;code&gt;content&lt;/code&gt;. In order to allow rendering of any HTML tags from the page content, we also use the built-in filter called &lt;code&gt;safe&lt;/code&gt; which is added after placing a pipe - &lt;code&gt;|&lt;/code&gt; - character.&lt;/p&gt;
&lt;p&gt;This makes our full &lt;code&gt;base.njk&lt;/code&gt; the following, with a bit of extra HTML semantics:&lt;/p&gt;
&lt;pre class=&quot;language-twig&quot;&gt;&lt;code class=&quot;language-twig&quot;&gt;&lt;span class=&quot;token doctype&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;!&lt;/span&gt;&lt;span class=&quot;token doctype-tag&quot;&gt;DOCTYPE&lt;/span&gt; &lt;span class=&quot;token name&quot;&gt;html&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;html&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;lang&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;en&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;head&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;meta&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;charset&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;UTF-8&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;meta&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;viewport&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;content&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;width=device-width, initial-scale=1.0&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;title&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token twig language-twig&quot;&gt;&lt;span class=&quot;token delimiter punctuation&quot;&gt;{{&lt;/span&gt; title &lt;span class=&quot;token delimiter punctuation&quot;&gt;}}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;title&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;head&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;body&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;header&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;h1&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token twig language-twig&quot;&gt;&lt;span class=&quot;token delimiter punctuation&quot;&gt;{{&lt;/span&gt; title &lt;span class=&quot;token delimiter punctuation&quot;&gt;}}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;h1&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;header&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;main&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token twig language-twig&quot;&gt;&lt;span class=&quot;token delimiter punctuation&quot;&gt;{{&lt;/span&gt; content &lt;span class=&quot;token operator&quot;&gt;|&lt;/span&gt; safe &lt;span class=&quot;token delimiter punctuation&quot;&gt;}}&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;main&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;body&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;html&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Then, we will go back to &lt;code&gt;index.md&lt;/code&gt; and create frontmatter to designate the &lt;code&gt;title&lt;/code&gt; and also to designate the &lt;code&gt;layout&lt;/code&gt; value so that this page uses our &lt;code&gt;base.njk&lt;/code&gt; template:&lt;/p&gt;
&lt;pre class=&quot;language-md&quot;&gt;&lt;code class=&quot;language-md&quot;&gt;&lt;span class=&quot;token front-matter-block&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;---&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token front-matter yaml language-yaml&quot;&gt;title: My first page&lt;br /&gt;layout: base.njk&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;---&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;You will have to manually refresh the page one last time so that it loads the updated markup. Then, additional edits will begin to be picked up by Browsersync. You can test this by modifying the value for the &lt;code&gt;title&lt;/code&gt;.&lt;/p&gt;
&lt;div class=&quot;heading-wrapper h2&quot;&gt;
&lt;h2 id=&quot;create-the-blog&quot;&gt;Create the Blog&lt;/h2&gt;
&lt;a class=&quot;tdbc-anchor&quot; href=&quot;https://11ty.rocks/posts/create-your-first-basic-11ty-website/#create-the-blog&quot; aria-labelledby=&quot;create-the-blog&quot;&gt;&lt;span hidden=&quot;&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;Next, we&#39;ll create a new content type for our blog. To do this, we&#39;ll create a new directory and a markdown file for our first post.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Create &lt;code&gt;src/blog/&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Create &lt;code&gt;src/blog/my-first-post.md&lt;/code&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;div class=&quot;heading-wrapper h3&quot;&gt;
&lt;h3 id=&quot;create-the-post-layout&quot;&gt;Create the &lt;code&gt;post&lt;/code&gt; Layout&lt;/h3&gt;
&lt;a class=&quot;tdbc-anchor&quot; href=&quot;https://11ty.rocks/posts/create-your-first-basic-11ty-website/#create-the-post-layout&quot; aria-labelledby=&quot;create-the-post-layout&quot;&gt;&lt;span hidden=&quot;&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;Next, we&#39;ll create a dedicated layout to display our blog posts.&lt;/p&gt;
&lt;p&gt;Back in the &lt;code&gt;_includes&lt;/code&gt; directory, create &lt;code&gt;post.njk&lt;/code&gt; with the following content:&lt;/p&gt;
&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;article&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;{{ content | safe}}&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;article&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;div class=&quot;heading-wrapper h3&quot;&gt;
&lt;h3 id=&quot;chain-the-post-layout-to-the-blog-layout&quot;&gt;Chain the &lt;code&gt;post&lt;/code&gt; Layout to the &lt;code&gt;blog&lt;/code&gt; Layout&lt;/h3&gt;
&lt;a class=&quot;tdbc-anchor&quot; href=&quot;https://11ty.rocks/posts/create-your-first-basic-11ty-website/#chain-the-post-layout-to-the-blog-layout&quot; aria-labelledby=&quot;chain-the-post-layout-to-the-blog-layout&quot;&gt;&lt;span hidden=&quot;&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;We&#39;ll then use an Eleventy concept called &amp;quot;layout chaining&amp;quot;. This will allow us to designate that the &lt;code&gt;post&lt;/code&gt; layout should also inherit the &lt;code&gt;base&lt;/code&gt; layout.&lt;/p&gt;
&lt;p&gt;To do this, in &lt;code&gt;post.njk&lt;/code&gt; add the following frontmatter:&lt;/p&gt;
&lt;pre class=&quot;language-md&quot;&gt;&lt;code class=&quot;language-md&quot;&gt;&lt;span class=&quot;token front-matter-block&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;---&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token front-matter yaml language-yaml&quot;&gt;layout: base.njk&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;---&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;At this point, you can try to visit the blog page in the browser. By default, 11ty will have created the page using the same structure as you used to organize it in your &lt;code&gt;src&lt;/code&gt; directory. In other words, it will be located at &lt;code&gt;http://localhost:8080/blog/my-first-post/&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;However if you visit that, you should find that it&#39;s blank! Read on to learn why.&lt;/p&gt;
&lt;div class=&quot;heading-wrapper h3&quot;&gt;
&lt;h3 id=&quot;create-blog-directory-data-file&quot;&gt;Create &lt;code&gt;blog&lt;/code&gt; Directory Data File&lt;/h3&gt;
&lt;a class=&quot;tdbc-anchor&quot; href=&quot;https://11ty.rocks/posts/create-your-first-basic-11ty-website/#create-blog-directory-data-file&quot; aria-labelledby=&quot;create-blog-directory-data-file&quot;&gt;&lt;span hidden=&quot;&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;The first reason that link shows a blank page is that we haven&#39;t designated that our new blog post should use the &lt;code&gt;post&lt;/code&gt; layout.&lt;/p&gt;
&lt;p&gt;Now, we could add this as frontmatter to every post as we&#39;ve already learned about. But when you plan on having many files in the same directory inherit certain attributes such as the layout, we can instead create a &lt;em&gt;directory data file&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;The directory data file is expected to have the same name as the directory, and be formatted as JSON. So, create &lt;code&gt;src/blog/blog.json&lt;/code&gt; and add the following:&lt;/p&gt;
&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token string-property property&quot;&gt;&quot;layout&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;post&quot;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;At this point, you may still see a blank page if you have not added any content into the blog post 😉 The other part we haven&#39;t added that our &lt;code&gt;base&lt;/code&gt; template expects is frontmatter for the &lt;code&gt;title&lt;/code&gt;, so go ahead and add that now based on what we&#39;ve learned.&lt;/p&gt;
&lt;p&gt;Once you&#39;ve added both a title and some content, on save you should nearly instantly see Browsersync update the page and see that content rendered.&lt;/p&gt;
&lt;div class=&quot;heading-wrapper h3&quot;&gt;
&lt;h3 id=&quot;optional-modify-the-blog-post-permalinks&quot;&gt;Optional: Modify the Blog Post Permalinks&lt;/h3&gt;
&lt;a class=&quot;tdbc-anchor&quot; href=&quot;https://11ty.rocks/posts/create-your-first-basic-11ty-website/#optional-modify-the-blog-post-permalinks&quot; aria-labelledby=&quot;optional-modify-the-blog-post-permalinks&quot;&gt;&lt;span hidden=&quot;&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;One other way we can use our directory data file is to set an altered permalink structure. &amp;quot;Permalink&amp;quot; is the term for the URL path that follows your domain (maybe you&#39;ve also heard this called a &amp;quot;slug&amp;quot;).&lt;/p&gt;
&lt;p&gt;Just as an example, let&#39;s use the 11ty supplied page variable of &lt;code&gt;fileSlug&lt;/code&gt; and tell 11ty to drop the &lt;code&gt;blog/&lt;/code&gt; from the front of the URL and just use the file name as the permalink value. Here is the update ot our &lt;code&gt;src/blog/blog.json&lt;/code&gt; file:&lt;/p&gt;
&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token string-property property&quot;&gt;&quot;layout&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;post&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token string-property property&quot;&gt;&quot;permalink&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;/{{ page.fileSlug }}/&quot;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;So, our previous blog page is now available at &lt;code&gt;http://localhost:8080/my-first-post/&lt;/code&gt;.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt;: You will continue to be able to visit the old URL because it is currently cached in the &lt;code&gt;public&lt;/code&gt; directory. You can delete the &lt;code&gt;public&lt;/code&gt; directory to remove it, because that directory is completely rebuilt after each save when 11ty is in &lt;code&gt;watch&lt;/code&gt; mode.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;div class=&quot;heading-wrapper h2&quot;&gt;
&lt;h2 id=&quot;create-posts-collection-via-tags&quot;&gt;Create &lt;code&gt;posts&lt;/code&gt; Collection Via &lt;code&gt;tags&lt;/code&gt;&lt;/h2&gt;
&lt;a class=&quot;tdbc-anchor&quot; href=&quot;https://11ty.rocks/posts/create-your-first-basic-11ty-website/#create-posts-collection-via-tags&quot; aria-labelledby=&quot;create-posts-collection-via-tags&quot;&gt;&lt;span hidden=&quot;&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;Next, we&#39;ll explore an 11ty idea called &lt;a href=&quot;https://www.11ty.dev/docs/collections/&quot;&gt;collections&lt;/a&gt;. Collections are groups of related content created by adding &lt;code&gt;tags&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;We&#39;ll again make use of our directory data file and add a new key of &lt;code&gt;tags&lt;/code&gt; with the value &lt;code&gt;posts&lt;/code&gt;:&lt;/p&gt;
&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token string-property property&quot;&gt;&quot;layout&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;post&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token string-property property&quot;&gt;&quot;permalink&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;/{{ page.fileSlug }}/&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token string-property property&quot;&gt;&quot;tags&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;posts&quot;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;And with that, 11ty will now have created a collection called &amp;quot;posts&amp;quot; which we&#39;ll learn how to display next!&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Before you move on, it would be useful to create a second blog post to help see the effects of our next few steps on affecting the &lt;code&gt;posts&lt;/code&gt; collection. You can simply duplicate the first post and change the file name and the &lt;code&gt;title&lt;/code&gt; frontmatter value.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;div class=&quot;heading-wrapper h2&quot;&gt;
&lt;h2 id=&quot;display-posts-collection-on-home-page&quot;&gt;Display &lt;code&gt;posts&lt;/code&gt; Collection on Home Page&lt;/h2&gt;
&lt;a class=&quot;tdbc-anchor&quot; href=&quot;https://11ty.rocks/posts/create-your-first-basic-11ty-website/#display-posts-collection-on-home-page&quot; aria-labelledby=&quot;display-posts-collection-on-home-page&quot;&gt;&lt;span hidden=&quot;&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;Often it is nice to display a list of your posts. Some times that&#39;s on the home page, and sometimes on an archive page. We will be adding it to our home page as a starting point, but you can customize this to display on any page.&lt;/p&gt;
&lt;p&gt;Re-open &lt;code&gt;index.md&lt;/code&gt; and add the following, then we&#39;ll review what&#39;s happening:&lt;/p&gt;
&lt;pre class=&quot;language-twig&quot;&gt;&lt;code class=&quot;language-twig&quot;&gt;## Blog Posts&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token twig language-twig&quot;&gt;&lt;span class=&quot;token delimiter punctuation&quot;&gt;{%&lt;/span&gt; &lt;span class=&quot;token tag-name keyword&quot;&gt;for&lt;/span&gt; post &lt;span class=&quot;token operator&quot;&gt;in&lt;/span&gt; collections&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;posts &lt;span class=&quot;token delimiter punctuation&quot;&gt;%}&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token twig language-twig&quot;&gt;&lt;span class=&quot;token delimiter punctuation&quot;&gt;{{&lt;/span&gt; post&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;data&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;title &lt;span class=&quot;token delimiter punctuation&quot;&gt;}}&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token twig language-twig&quot;&gt;&lt;span class=&quot;token delimiter punctuation&quot;&gt;{%&lt;/span&gt; &lt;span class=&quot;token tag-name keyword&quot;&gt;endfor&lt;/span&gt; &lt;span class=&quot;token delimiter punctuation&quot;&gt;%}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;If you&#39;re wondering what those curly braces and percent signs are about, what we&#39;ve done is created a &lt;em&gt;for loop&lt;/em&gt; using the &lt;a href=&quot;https://shopify.github.io/liquid/&quot;&gt;Liquid templating language&lt;/a&gt; (which happens to share this basic curly brace syntax with &lt;a href=&quot;https://mozilla.github.io/nunjucks/&quot;&gt;Nunjucks templating language&lt;/a&gt;).&lt;/p&gt;
&lt;p&gt;We&#39;ve defined a local variable of &lt;code&gt;post&lt;/code&gt; to be the reference to an individual item in &lt;code&gt;collections.posts&lt;/code&gt;. Thanks to adding our tag of &lt;code&gt;posts&lt;/code&gt;, this collection was created by 11ty and is available throughout all site files.&lt;/p&gt;
&lt;p&gt;Within the loop, we are simply retrieving the post&#39;s title, which is nested within &lt;code&gt;data&lt;/code&gt; due to it being a frontmatter value.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Notice that the loop start and end uses the syntax of a single curly brace and a percent sign, while the portion retrieving the frontmatter variable is flanked by two curly braces. For both Liquid and Nunjucks templating, &lt;code&gt;{% %}&lt;/code&gt; contains functions and &lt;code&gt;{{ }}&lt;/code&gt; displays variables.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;div class=&quot;heading-wrapper h3&quot;&gt;
&lt;h3 id=&quot;create-linked-list-of-posts&quot;&gt;Create Linked List of Posts&lt;/h3&gt;
&lt;a class=&quot;tdbc-anchor&quot; href=&quot;https://11ty.rocks/posts/create-your-first-basic-11ty-website/#create-linked-list-of-posts&quot; aria-labelledby=&quot;create-linked-list-of-posts&quot;&gt;&lt;span hidden=&quot;&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;We can modify our &lt;code&gt;for&lt;/code&gt; loop to use semantic HTML and create a list of links to each post.&lt;/p&gt;
&lt;p&gt;We&#39;ve added one new variable, which is &lt;code&gt;url&lt;/code&gt;. This is a page variable provided by 11ty for any paged piece of content, and so is available directly off of our local loop variable of &lt;code&gt;post&lt;/code&gt;:&lt;/p&gt;
&lt;pre class=&quot;language-twig&quot;&gt;&lt;code class=&quot;language-twig&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;ul&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token twig language-twig&quot;&gt;&lt;span class=&quot;token delimiter punctuation&quot;&gt;{%&lt;/span&gt; &lt;span class=&quot;token tag-name keyword&quot;&gt;for&lt;/span&gt; post &lt;span class=&quot;token operator&quot;&gt;in&lt;/span&gt; collections&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;posts &lt;span class=&quot;token delimiter punctuation&quot;&gt;%}&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;li&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;a&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;href&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;token twig language-twig&quot;&gt;&lt;span class=&quot;token delimiter punctuation&quot;&gt;{{&lt;/span&gt; post&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;url &lt;span class=&quot;token delimiter punctuation&quot;&gt;}}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token twig language-twig&quot;&gt;&lt;span class=&quot;token delimiter punctuation&quot;&gt;{{&lt;/span&gt; post&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;data&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;title &lt;span class=&quot;token delimiter punctuation&quot;&gt;}}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;a&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;li&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token twig language-twig&quot;&gt;&lt;span class=&quot;token delimiter punctuation&quot;&gt;{%&lt;/span&gt; &lt;span class=&quot;token tag-name keyword&quot;&gt;endfor&lt;/span&gt; &lt;span class=&quot;token delimiter punctuation&quot;&gt;%}&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;ul&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;blockquote&gt;
&lt;p&gt;Have you realized we&#39;re doing all of this is a markdown file so far? That&#39;s right - we&#39;ve mixed markdown, HTML, and Liquid and still had success rendering our outcome! This is part of the ✨ magic of 11ty!&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;&lt;small&gt;If the previous example broke, it may be because you added spaces or tabs to indent and format the HTML - that&#39;s a pitfall of trying to mix templating languages which we&#39;ll sort out next!&lt;/small&gt;&lt;/p&gt;
&lt;div class=&quot;heading-wrapper h2&quot;&gt;
&lt;h2 id=&quot;create-template-include-from-blog-post-links&quot;&gt;Create Template Include from Blog Post Links&lt;/h2&gt;
&lt;a class=&quot;tdbc-anchor&quot; href=&quot;https://11ty.rocks/posts/create-your-first-basic-11ty-website/#create-template-include-from-blog-post-links&quot; aria-labelledby=&quot;create-template-include-from-blog-post-links&quot;&gt;&lt;span hidden=&quot;&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;Ok, while we &lt;em&gt;can&lt;/em&gt; do all of this in markdown, it&#39;s not sustainable for all types of content - or, as noted, breaks when trying to add formatting to the HTML (read why &lt;a href=&quot;https://www.11ty.dev/docs/languages/markdown/#there-are-extra-and-in-my-output&quot;&gt;on the 11ty docs&lt;/a&gt;).&lt;/p&gt;
&lt;p&gt;Let&#39;s improve our solution, first by creating a &lt;em&gt;template include&lt;/em&gt; (or &amp;quot;partial&amp;quot;) to hold our post list. Includes will live in our - you guessed it! - &lt;code&gt;_includes&lt;/code&gt; directory.&lt;/p&gt;
&lt;p&gt;Create &lt;code&gt;_includes/postlist.njk&lt;/code&gt;, and move the HTML with the &lt;code&gt;for&lt;/code&gt; loop into it, removing it from the index.&lt;/p&gt;
&lt;p&gt;In it&#39;s place in &lt;code&gt;index.md&lt;/code&gt;, add &lt;code&gt;{% include &amp;quot;postlist.njk&amp;quot; %}&lt;/code&gt; and save.&lt;/p&gt;
&lt;p&gt;Oops! We&#39;ve hit an error which should be visible in your Terminal. Let&#39;s find out why...&lt;/p&gt;
&lt;div class=&quot;heading-wrapper h2&quot;&gt;
&lt;h2 id=&quot;instruct-11ty-how-to-handle-template-processing&quot;&gt;Instruct 11ty How to Handle Template Processing&lt;/h2&gt;
&lt;a class=&quot;tdbc-anchor&quot; href=&quot;https://11ty.rocks/posts/create-your-first-basic-11ty-website/#instruct-11ty-how-to-handle-template-processing&quot; aria-labelledby=&quot;instruct-11ty-how-to-handle-template-processing&quot;&gt;&lt;span hidden=&quot;&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;While we can do some template mixing, sometimes 11ty needs a little hint on our expectations of how to process the mix.&lt;/p&gt;
&lt;p&gt;In the case of mixing templating with markdown, 11ty &lt;em&gt;only&lt;/em&gt; allows either Liquid or Nunjucks.&lt;/p&gt;
&lt;p&gt;What happened to cause our error had to do with order of operations, and in this case we need to add an 11ty-supplied frontmatter key to tell 11ty which order to process the templating vs. the markdown.&lt;/p&gt;
&lt;p&gt;Add &lt;code&gt;templateEngineOverride: njk,md&lt;/code&gt; to &lt;code&gt;index.md&lt;/code&gt; frontmatter, which says to process the Nunjucks include &lt;em&gt;first&lt;/em&gt; and then continue processing the markdown to render.&lt;/p&gt;
&lt;p&gt;Hooray! The error is resolved, and we can again see our postlist being rendered on the home page.&lt;/p&gt;
&lt;div class=&quot;heading-wrapper h2&quot;&gt;
&lt;h2 id=&quot;create-a-css-file&quot;&gt;Create a CSS File&lt;/h2&gt;
&lt;a class=&quot;tdbc-anchor&quot; href=&quot;https://11ty.rocks/posts/create-your-first-basic-11ty-website/#create-a-css-file&quot; aria-labelledby=&quot;create-a-css-file&quot;&gt;&lt;span hidden=&quot;&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;One big thing missing from our site is some style 😎&lt;/p&gt;
&lt;p&gt;CSS is not yet a file type recognized for auto-inclusion in the build directory, so we need to do a few extra steps.&lt;/p&gt;
&lt;p&gt;First, let&#39;s create a very basic starting point for our CSS.&lt;/p&gt;
&lt;p&gt;Create &lt;code&gt;src/css/style.css&lt;/code&gt;, and add:&lt;/p&gt;
&lt;pre class=&quot;language-css&quot;&gt;&lt;code class=&quot;language-css&quot;&gt;&lt;span class=&quot;token selector&quot;&gt;body&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token property&quot;&gt;font-family&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; sans-serif&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;div class=&quot;heading-wrapper h3&quot;&gt;
&lt;h3 id=&quot;passthrough-css&quot;&gt;Passthrough CSS&lt;/h3&gt;
&lt;a class=&quot;tdbc-anchor&quot; href=&quot;https://11ty.rocks/posts/create-your-first-basic-11ty-website/#passthrough-css&quot; aria-labelledby=&quot;passthrough-css&quot;&gt;&lt;span hidden=&quot;&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;In order for 11ty to recognize our CSS file and include it in the build directory, we need to modify &lt;code&gt;.eleventy.js&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;As the first line inside of the &lt;code&gt;module.exports&lt;/code&gt; function (before the &lt;code&gt;return&lt;/code&gt; we had previously added), add:&lt;/p&gt;
&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;eleventyConfig&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;addPassthroughCopy&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;./src/css&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This tells 11ty to &amp;quot;pass through&amp;quot; the CSS directory.&lt;/p&gt;
&lt;div class=&quot;heading-wrapper h3&quot;&gt;
&lt;h3 id=&quot;watch-css-for-changes&quot;&gt;Watch CSS for Changes&lt;/h3&gt;
&lt;a class=&quot;tdbc-anchor&quot; href=&quot;https://11ty.rocks/posts/create-your-first-basic-11ty-website/#watch-css-for-changes&quot; aria-labelledby=&quot;watch-css-for-changes&quot;&gt;&lt;span hidden=&quot;&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;In addition to the pass through, we also need to ask 11ty to watch the CSS directory for changes so that when we modify our CSS file it triggers a rebuild and refresh from Browsersync.&lt;/p&gt;
&lt;p&gt;Still in &lt;code&gt;.eleventy.js&lt;/code&gt;, add the following after our pass through line:&lt;/p&gt;
&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;eleventyConfig&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;addWatchTarget&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;./src/css/&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;blockquote&gt;
&lt;p&gt;When changes are made to &lt;code&gt;.eleventy.js&lt;/code&gt;, it typically requires stopping the watch process and restarting. On both Mac and PC, use &lt;code&gt;Ctrl + C&lt;/code&gt; in Terminal to stop the watch command, and then re-run &lt;code&gt;npm start&lt;/code&gt; to start it again. When complete, the CSS directory should be present in &lt;code&gt;public&lt;/code&gt; and if you test modifying &lt;code&gt;style.css&lt;/code&gt; the changes should cause a rebuild and be updated in &lt;code&gt;public/css/style.css&lt;/code&gt;.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;div class=&quot;heading-wrapper h2&quot;&gt;
&lt;h2 id=&quot;link-to-stylesheet-in-base-layout&quot;&gt;Link to Stylesheet in &lt;code&gt;base&lt;/code&gt; Layout&lt;/h2&gt;
&lt;a class=&quot;tdbc-anchor&quot; href=&quot;https://11ty.rocks/posts/create-your-first-basic-11ty-website/#link-to-stylesheet-in-base-layout&quot; aria-labelledby=&quot;link-to-stylesheet-in-base-layout&quot;&gt;&lt;span hidden=&quot;&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;Now, our CSS hasn&#39;t updated our site to a &lt;code&gt;sans-serif&lt;/code&gt; font yet. Any guesses why?&lt;/p&gt;
&lt;p&gt;Yup - we need to add the stylesheet link to our layout!&lt;/p&gt;
&lt;p&gt;Within &lt;code&gt;_includes/base.njk&lt;/code&gt;, add the following within the &lt;code&gt;&amp;lt;head&amp;gt;&lt;/code&gt; section after the &lt;code&gt;&amp;lt;title&amp;gt;&lt;/code&gt;:&lt;/p&gt;
&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;link&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;rel&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;stylesheet&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;href&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;/css/style.css&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;/&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;And on save, once Browsersync refreshes, the page content should be using a &lt;code&gt;sans-serif&lt;/code&gt; font.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;🏁 &lt;strong&gt;Checkpoint&lt;/strong&gt;: You have now created a successful 11ty starting point! Using what you&#39;ve learned so far, you can continue making different content types and organizing them into collections. You know how to modify their permalinks, and chain layouts. And you know how to use Liquid and Nunjucks to display variables and leverage &lt;code&gt;for&lt;/code&gt; loops. You can also mix templating languages and overcome templating pitfalls. And you can add and watch a CSS file. The last few sections show a bit more advanced features of 11ty that will help you take your project further!&lt;/p&gt;
&lt;/blockquote&gt;
&lt;div class=&quot;heading-wrapper h2&quot;&gt;
&lt;h2 id=&quot;custom-data&quot;&gt;Custom Data&lt;/h2&gt;
&lt;a class=&quot;tdbc-anchor&quot; href=&quot;https://11ty.rocks/posts/create-your-first-basic-11ty-website/#custom-data&quot; aria-labelledby=&quot;custom-data&quot;&gt;&lt;span hidden=&quot;&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;One of my favorite features of 11ty is custom data. One of the expected directories in the 11ty file system is &lt;code&gt;_data&lt;/code&gt;, and any files you create here that are &lt;code&gt;module.exports&lt;/code&gt; or basic JSON data is made availably &lt;em&gt;globally&lt;/em&gt; to your pages and layouts.&lt;/p&gt;
&lt;p&gt;So, let&#39;s create a simple (and silly) data file: &lt;code&gt;src/_data/facts.json&lt;/code&gt;&lt;/p&gt;
&lt;pre class=&quot;language-json&quot;&gt;&lt;code class=&quot;language-json&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token string&quot;&gt;&quot;Did you know horses can swim?&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token string&quot;&gt;&quot;Did you know that the average human can hold their breath for 2 minutes?&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token string&quot;&gt;&quot;Did you know that we live on Earth?&quot;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;small&gt;&lt;em&gt;These are definitely true facts...maybe...&lt;/em&gt;&lt;/small&gt;&lt;/p&gt;
&lt;div class=&quot;heading-wrapper h3&quot;&gt;
&lt;h3 id=&quot;add-facts-loop-to-post-layout&quot;&gt;Add &lt;code&gt;facts&lt;/code&gt; Loop to &lt;code&gt;post&lt;/code&gt; Layout&lt;/h3&gt;
&lt;a class=&quot;tdbc-anchor&quot; href=&quot;https://11ty.rocks/posts/create-your-first-basic-11ty-website/#add-facts-loop-to-post-layout&quot; aria-labelledby=&quot;add-facts-loop-to-post-layout&quot;&gt;&lt;span hidden=&quot;&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;For fun, let&#39;s add our facts after our blog post content.&lt;/p&gt;
&lt;p&gt;Add the following after &lt;code&gt;article&lt;/code&gt; in &lt;code&gt;_includes/post.njk&lt;/code&gt;:&lt;/p&gt;
&lt;pre class=&quot;language-twig&quot;&gt;&lt;code class=&quot;language-twig&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;aside&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token twig language-twig&quot;&gt;&lt;span class=&quot;token delimiter punctuation&quot;&gt;{%&lt;/span&gt; &lt;span class=&quot;token tag-name keyword&quot;&gt;for&lt;/span&gt; fact &lt;span class=&quot;token operator&quot;&gt;in&lt;/span&gt; facts &lt;span class=&quot;token delimiter punctuation&quot;&gt;%}&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;p&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token twig language-twig&quot;&gt;&lt;span class=&quot;token delimiter punctuation&quot;&gt;{{&lt;/span&gt; fact &lt;span class=&quot;token delimiter punctuation&quot;&gt;}}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;p&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token twig language-twig&quot;&gt;&lt;span class=&quot;token delimiter punctuation&quot;&gt;{%&lt;/span&gt; &lt;span class=&quot;token tag-name keyword&quot;&gt;endfor&lt;/span&gt; &lt;span class=&quot;token delimiter punctuation&quot;&gt;%}&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;aside&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This for loop should look pretty familiar, but instead of retrieving data from a &lt;em&gt;collection&lt;/em&gt; we are requesting it from our &lt;em&gt;facts&lt;/em&gt;. Recall that I mentioned that the output of files in &lt;code&gt;_data&lt;/code&gt; is made globally available? This means that we can access the output of that data by referencing the &lt;em&gt;filename&lt;/em&gt;, which is where &lt;code&gt;facts&lt;/code&gt; comes from.&lt;/p&gt;
&lt;p&gt;If you visit one of your blog posts, you should see each fact is output within a paragraph tag.&lt;/p&gt;
&lt;div class=&quot;heading-wrapper h2&quot;&gt;
&lt;h2 id=&quot;create-randomitem-filter&quot;&gt;Create &lt;code&gt;randomItem&lt;/code&gt; Filter&lt;/h2&gt;
&lt;a class=&quot;tdbc-anchor&quot; href=&quot;https://11ty.rocks/posts/create-your-first-basic-11ty-website/#create-randomitem-filter&quot; aria-labelledby=&quot;create-randomitem-filter&quot;&gt;&lt;span hidden=&quot;&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;Now, it&#39;s not very interesting to output all of our facts at once.&lt;/p&gt;
&lt;p&gt;Let&#39;s add our first custom filter to help randomly pick one of the facts to display.&lt;/p&gt;
&lt;p&gt;Open &lt;code&gt;.eleventy.js&lt;/code&gt;, and add the following between the work related to our CSS, and the &lt;code&gt;return&lt;/code&gt;:&lt;/p&gt;
&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;eleventyConfig&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;addFilter&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;randomItem&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;arr&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;  arr&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;sort&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;0.5&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt; Math&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;random&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; arr&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;slice&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;code&gt;addFilter&lt;/code&gt; globally makes the &amp;quot;randomItem&amp;quot; filter available to any templating language. In this case, we expect that the data that will come into the filter will be an array, since we&#39;ll be using it on our &lt;code&gt;facts&lt;/code&gt; array. The body of the filter is a very basic randomizing function written in JavaScript.&lt;/p&gt;
&lt;div class=&quot;heading-wrapper h3&quot;&gt;
&lt;h3 id=&quot;add-the-filter-to-facts-loop&quot;&gt;Add the Filter to &lt;code&gt;facts&lt;/code&gt; Loop&lt;/h3&gt;
&lt;a class=&quot;tdbc-anchor&quot; href=&quot;https://11ty.rocks/posts/create-your-first-basic-11ty-website/#add-the-filter-to-facts-loop&quot; aria-labelledby=&quot;add-the-filter-to-facts-loop&quot;&gt;&lt;span hidden=&quot;&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;Back in our &lt;code&gt;post&lt;/code&gt; layout, we&#39;ll update our &lt;code&gt;for&lt;/code&gt; loop to include our filter. If you recall from applying the &lt;code&gt;safe&lt;/code&gt; filter, a filter goes &lt;em&gt;after&lt;/em&gt; the variable or collection it is being applied to, with a pipe &lt;code&gt;|&lt;/code&gt; character inbetween. The &lt;code&gt;facts&lt;/code&gt; array is passed into the filter for processing.&lt;/p&gt;
&lt;pre class=&quot;language-twig&quot;&gt;&lt;code class=&quot;language-twig&quot;&gt;&lt;span class=&quot;token twig language-twig&quot;&gt;&lt;span class=&quot;token delimiter punctuation&quot;&gt;{%&lt;/span&gt; &lt;span class=&quot;token tag-name keyword&quot;&gt;for&lt;/span&gt; fact &lt;span class=&quot;token operator&quot;&gt;in&lt;/span&gt; facts &lt;span class=&quot;token operator&quot;&gt;|&lt;/span&gt; randomItem &lt;span class=&quot;token delimiter punctuation&quot;&gt;%}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;On save, there should only be one randomly selected fact displayed on each blog post. Of course, there&#39;s a chance that the fact will be the same since it&#39;s a small pool to choose from ☺️&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Important note&lt;/strong&gt;: Since 11ty is a truly &lt;em&gt;static&lt;/em&gt; site builder, the quote will be selected during &lt;em&gt;build time&lt;/em&gt; and not on &lt;em&gt;page load&lt;/em&gt;. This is an important difference from dynamic build tools like Gatsby. You can include JavaScript on your own to make this selection happen on page load, but using the filter method makes it part of the build process. If you have content that you want to update somewhere between statically and page load, you can use tools like IFTTT to trigger periodic builds if your site host supports webhooks.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;div class=&quot;heading-wrapper h2&quot;&gt;
&lt;h2 id=&quot;create-data-from-api&quot;&gt;Create Data from API&lt;/h2&gt;
&lt;a class=&quot;tdbc-anchor&quot; href=&quot;https://11ty.rocks/posts/create-your-first-basic-11ty-website/#create-data-from-api&quot; aria-labelledby=&quot;create-data-from-api&quot;&gt;&lt;span hidden=&quot;&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;11ty can use the output of Node modules as data, which also means we can use Node packages to help us retrieve data. And it means we can get external data at build time.&lt;/p&gt;
&lt;p&gt;Let&#39;s explore this by retrieving a cat picture from an API using axios for fetching.&lt;/p&gt;
&lt;p&gt;Create &lt;code&gt;_data/catpic.js&lt;/code&gt;, and add the following:&lt;/p&gt;
&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; axios &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;require&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;axios&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;module&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function-variable function&quot;&gt;exports&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;async&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; result &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;await&lt;/span&gt; axios&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;get&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;https://aws.random.cat/meow&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;  &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; result&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;data&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;file&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;small&gt;&lt;em&gt;Note: You may need to add &lt;code&gt;axios&lt;/code&gt; to your package for a local build to work: &lt;code&gt;npm install axios&lt;/code&gt;&lt;/em&gt;&lt;/small&gt;&lt;/p&gt;
&lt;p&gt;It&#39;s ok if you&#39;re not very familiar with Node! What we&#39;re doing here is &lt;em&gt;fetching&lt;/em&gt; the result from the cat pic API. Then we are returning the &lt;code&gt;file&lt;/code&gt; key that is present in that particular data set.&lt;/p&gt;
&lt;div class=&quot;heading-wrapper h3&quot;&gt;
&lt;h3 id=&quot;add-catpic-to-home-page&quot;&gt;Add &lt;code&gt;catpic&lt;/code&gt; to Home Page&lt;/h3&gt;
&lt;a class=&quot;tdbc-anchor&quot; href=&quot;https://11ty.rocks/posts/create-your-first-basic-11ty-website/#add-catpic-to-home-page&quot; aria-labelledby=&quot;add-catpic-to-home-page&quot;&gt;&lt;span hidden=&quot;&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;Now we&#39;d like to display the retrieved cat pic on our home page. Add the following to &lt;code&gt;index.md&lt;/code&gt;:&lt;/p&gt;
&lt;pre class=&quot;language-twig&quot;&gt;&lt;code class=&quot;language-twig&quot;&gt;## Cat of the Day&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;img&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;src&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;token twig language-twig&quot;&gt;&lt;span class=&quot;token delimiter punctuation&quot;&gt;{{&lt;/span&gt; catpic &lt;span class=&quot;token delimiter punctuation&quot;&gt;}}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;/&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Since the API includes an image URL within the &lt;code&gt;file&lt;/code&gt; key, and we are directly returning that value out of our function within &lt;code&gt;_data/catpic.js&lt;/code&gt;, and 11ty has made that output available globally via the filename - this makes including it in our image tag very simple!&lt;/p&gt;
&lt;p&gt;Once again, remember that this fetch only happens at build time. Meaning, once your site is built on your hosting server, whatever cat pic is retrieved will be what is displayed until the next site build. However, for the duration that you are doing local development with &lt;code&gt;npm start&lt;/code&gt;, a &lt;em&gt;new&lt;/em&gt; build is generated each time you save a file, which will make it appear as though the &lt;code&gt;catpic&lt;/code&gt; is changing more frequently.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;🏁 &lt;strong&gt;Checkpoint&lt;/strong&gt;: Congrats! You now know how to add local and external data to your 11ty site! With these fundamental concepts, you can really stretch 11ty to many use cases. To wrap up, read on to learn how to deploy to Netlify, or feel free to use the host of your choice.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;div class=&quot;heading-wrapper h2&quot;&gt;
&lt;h2 id=&quot;bonus-deploy-to-netlify&quot;&gt;Bonus: Deploy to Netlify&lt;/h2&gt;
&lt;a class=&quot;tdbc-anchor&quot; href=&quot;https://11ty.rocks/posts/create-your-first-basic-11ty-website/#bonus-deploy-to-netlify&quot; aria-labelledby=&quot;bonus-deploy-to-netlify&quot;&gt;&lt;span hidden=&quot;&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;Netlify is an excellent host for static sites - especially because you can start and stay free for basic needs.&lt;/p&gt;
&lt;div class=&quot;heading-wrapper h3&quot;&gt;
&lt;h3 id=&quot;create-a-netlify-config&quot;&gt;Create a Netlify Config&lt;/h3&gt;
&lt;a class=&quot;tdbc-anchor&quot; href=&quot;https://11ty.rocks/posts/create-your-first-basic-11ty-website/#create-a-netlify-config&quot; aria-labelledby=&quot;create-a-netlify-config&quot;&gt;&lt;span hidden=&quot;&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;If you choose to continue with hosting on Netlify, we can create a file to speed up your first deploy.&lt;/p&gt;
&lt;p&gt;At the root of your project (outside of &lt;code&gt;src&lt;/code&gt;), create &lt;code&gt;netlify.toml&lt;/code&gt; with the following content:&lt;/p&gt;
&lt;pre class=&quot;language-yaml&quot;&gt;&lt;code class=&quot;language-yaml&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;build&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token comment&quot;&gt;# Directory (relative to root of your repo) that contains the deploy-ready&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token comment&quot;&gt;# HTML files and assets generated by the build. If a base directory has&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token comment&quot;&gt;# been specified, include it in the publish directory path.&lt;/span&gt;&lt;br /&gt;  publish = &quot;public&quot;&lt;br /&gt;&lt;br /&gt;  &lt;span class=&quot;token comment&quot;&gt;# Default build command.&lt;/span&gt;&lt;br /&gt;  command = &quot;npm run build&quot;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This is telling Netlify that our production-ready files post-11ty build will be located in &lt;code&gt;public/&lt;/code&gt; and that the command to produce that build is &lt;code&gt;npm run build&lt;/code&gt;.&lt;/p&gt;
&lt;div class=&quot;heading-wrapper h3&quot;&gt;
&lt;h3 id=&quot;push-to-github&quot;&gt;Push to Github&lt;/h3&gt;
&lt;a class=&quot;tdbc-anchor&quot; href=&quot;https://11ty.rocks/posts/create-your-first-basic-11ty-website/#push-to-github&quot; aria-labelledby=&quot;push-to-github&quot;&gt;&lt;span hidden=&quot;&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;Netlify runs off of a continuous integration model, which allows any pushes to your main branch on Github to trigger a build.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Alternatively, you can &lt;a href=&quot;https://app.netlify.com/drop&quot;&gt;drag and drop your site folder&lt;/a&gt; to deploy!&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;For the GitHub route, create a repo and push your project to Github (&lt;em&gt;instructions outside the scope of these steps&lt;/em&gt;).&lt;/p&gt;
&lt;div class=&quot;heading-wrapper h3&quot;&gt;
&lt;h3 id=&quot;connect-to-netlify-and-deploy&quot;&gt;Connect to Netlify and Deploy&lt;/h3&gt;
&lt;a class=&quot;tdbc-anchor&quot; href=&quot;https://11ty.rocks/posts/create-your-first-basic-11ty-website/#connect-to-netlify-and-deploy&quot; aria-labelledby=&quot;connect-to-netlify-and-deploy&quot;&gt;&lt;span hidden=&quot;&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;After pushing to GitHub, follow these steps, after which your new site will be live immediately at a temporary URL provided by Netlify!&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Create a &lt;a href=&quot;https://netlify.com/&quot;&gt;Netlify&lt;/a&gt; account, using GitHub login for fastest deploy&lt;/li&gt;
&lt;li&gt;Select &amp;quot;Create from Git&amp;quot;&lt;/li&gt;
&lt;li&gt;Link to Github and select your repo&lt;/li&gt;
&lt;li&gt;Netlify will recognize the values in &lt;code&gt;netlify.toml&lt;/code&gt; and you can deploy! 🎉&lt;/li&gt;
&lt;/ol&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Next Steps&lt;/strong&gt;: For a video walkthrough and slightly different way to get started with 11ty, including adding Sass for styling, check out my 20 minute egghead course: &lt;a href=&quot;https://5t3ph.dev/learn-11ty&quot;&gt;Build an Eleventy Site From Scratch&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;
</content>
	</entry>
	
	
	<entry>
		<title>Plugin: Emoji Read Time</title>
		<link href="https://www.npmjs.com/package/@11tyrocks/eleventy-plugin-emoji-readtime"/>
		<updated>2020-10-20T00:00:00Z</updated>
		<id>https://www.npmjs.com/package/@11tyrocks/eleventy-plugin-emoji-readtime</id>
		<content type="html">&lt;p&gt;This plugin provides a filter that displays an estimated read time for Eleventy content, optionally with an emoji visual indicator.&lt;/p&gt;
&lt;p&gt;The plugin offers config options to change or remove the emoji, update the word-per-minute, and alter the label. A simple string is returned, so the text formatting is up to you.&lt;/p&gt;
&lt;p&gt;The default appearance displays one 🍿 per rounded 5 minutes of estimated reading time, ex: &lt;code&gt;🍿 7 min. read&lt;/code&gt;&lt;/p&gt;
&lt;a href=&quot;https://www.npmjs.com/package/@11tyrocks/eleventy-plugin-emoji-readtime&quot;&gt;Docs for Emoji Read Time&lt;/a&gt;</content>
	</entry>
	
	
	<entry>
		<title>Build a Community Site With Eleventy</title>
		<link href="https://css-tricks.com/a-community-driven-site-with-eleventy-building-the-site/"/>
		<updated>2020-10-20T00:00:00Z</updated>
		<id>https://css-tricks.com/a-community-driven-site-with-eleventy-building-the-site/</id>
		<content type="html">&lt;p&gt;Based on my experience building &lt;a href=&quot;https://stylestage.dev/&quot;&gt;StyleStage.dev&lt;/a&gt;, this tutorial will cover how to create a full-featured 11ty site including:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;How to initialize Eleventy and create useful develop and build scripts&lt;/li&gt;
&lt;li&gt;Recommended setup customizations&lt;/li&gt;
&lt;li&gt;How to define custom data and combine multiple data sources&lt;/li&gt;
&lt;li&gt;Creating layouts with Nunjucks and Eleventy layout chaining&lt;/li&gt;
&lt;li&gt;Deploying to Netlify&lt;/li&gt;
&lt;/ul&gt;
&lt;a href=&quot;https://css-tricks.com/a-community-driven-site-with-eleventy-building-the-site/&quot;&gt;Build Your Community&lt;/a&gt;</content>
	</entry>
	
	
	<entry>
		<title>11ty Web Component Generator</title>
		<link href="https://11ty-web-component-generator.netlify.app/"/>
		<updated>2020-10-20T00:00:00Z</updated>
		<id>https://11ty-web-component-generator.netlify.app/</id>
		<content type="html">&lt;p&gt;Eleventy makes it possible to mix templating languages. More importantly to this generator is that we can customize the output file type and composite a file from includes.&lt;/p&gt;
&lt;p&gt;This generator works with the inherent features of 11ty. Web components are generated within a Nunjucks (&lt;code&gt;.njk&lt;/code&gt;) template that outputs the final &lt;code&gt;.js&lt;/code&gt; file.&lt;/p&gt;
&lt;a href=&quot;https://11ty-web-component-generator.netlify.app/&quot;&gt;Demo the Generator&lt;/a&gt;</content>
	</entry>
	
	
	<entry>
		<title>11ty Sass Skeleton Starter</title>
		<link href="https://github.com/5t3ph/11ty-sass-skeleton"/>
		<updated>2020-10-20T00:00:00Z</updated>
		<id>https://github.com/5t3ph/11ty-sass-skeleton</id>
		<content type="html">&lt;p&gt;Featuring absolutely nothing beyond a base HTML5 template and the essential setup to watch and compile your Sass alongside 11ty.&lt;/p&gt;
&lt;p&gt;Includes minifiying and autoprefixing of styles postbuild.&lt;/p&gt;
&lt;a href=&quot;https://github.com/5t3ph/11ty-sass-skeleton&quot;&gt;Get the Starter&lt;/a&gt;</content>
	</entry>
	
	
	<entry>
		<title>11ty Netlify Jumpstart</title>
		<link href="https://11ty-netlify-jumpstart.netlify.app/"/>
		<updated>2020-10-20T00:00:00Z</updated>
		<id>https://11ty-netlify-jumpstart.netlify.app/</id>
		<content type="html">&lt;p&gt;Quickly launch an 11ty-generated static site. Includes a minimal Sass framework, and generated sitemap, RSS feed, and social share preview images.&lt;/p&gt;
&lt;a href=&quot;https://11ty-netlify-jumpstart.netlify.app/&quot;&gt;Test Drive the Jumpstart&lt;/a&gt;</content>
	</entry>
	
	
	<entry>
		<title>Build an Eleventy Site from Scratch</title>
		<link href="https://5t3ph.dev/learn-11ty"/>
		<updated>2020-10-20T00:00:00Z</updated>
		<id>https://5t3ph.dev/learn-11ty</id>
		<content type="html">&lt;p&gt;&lt;strong&gt;Build a site in 20 mins!&lt;/strong&gt; Start from a blank project and build up to an 11ty site that includes Sass, a blog collection, and is prepared to source content from a headless CMS.&lt;/p&gt;
&lt;a href=&quot;https://5t3ph.dev/learn-11ty&quot;&gt;Watch the Collection&lt;/a&gt;</content>
	</entry>
	
	
	<entry>
		<title>Plugin: Open in CodePen</title>
		<link href="https://www.npmjs.com/package/@11tyrocks/eleventy-plugin-open-in-codepen"/>
		<updated>2020-04-02T00:00:00Z</updated>
		<id>https://www.npmjs.com/package/@11tyrocks/eleventy-plugin-open-in-codepen</id>
		<content type="html">&lt;p&gt;This plugin provides an Eleventy shortcode to add &amp;quot;Open in CodePen&amp;quot; functionality for code demos.&lt;/p&gt;
&lt;p&gt;The functionality pairs well with the result of this tutorial on &lt;a href=&quot;https://11ty.rocks/posts/eleventy-templating-static-code-demos/&quot;&gt;creating live static code demos&lt;/a&gt;.&lt;/p&gt;
&lt;a href=&quot;https://www.npmjs.com/package/@11tyrocks/eleventy-plugin-open-in-codepen&quot;&gt;Docs for Open in CodePen&lt;/a&gt;</content>
	</entry>
</feed>