<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Michael Rose on Medium]]></title>
        <description><![CDATA[Stories by Michael Rose on Medium]]></description>
        <link>https://medium.com/@mmistakes?source=rss-28f2062ce9ef------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*o9tF_emnuilC4kLLjYGmUw.jpeg</url>
            <title>Stories by Michael Rose on Medium</title>
            <link>https://medium.com/@mmistakes?source=rss-28f2062ce9ef------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 03 Dec 2026 20:49:11 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@mmistakes/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[How I’m Using Jekyll in 2017]]></title>
            <link>https://medium.com/@mmistakes/how-im-using-jekyll-in-2017-5eb2aaeee3b1?source=rss-28f2062ce9ef------2</link>
            <guid isPermaLink="false">https://medium.com/p/5eb2aaeee3b1</guid>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[gulp]]></category>
            <category><![CDATA[travis-ci]]></category>
            <category><![CDATA[jekyll]]></category>
            <category><![CDATA[static-site]]></category>
            <dc:creator><![CDATA[Michael Rose]]></dc:creator>
            <pubDate>Wed, 30 Aug 2017 00:00:00 GMT</pubDate>
            <atom:updated>2017-08-31T16:35:54.777Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UsNuRRL81setgct5SONSvg.jpeg" /></figure><p>Not going to lie — I ❤️ <a href="https://mademistakes.com/tag/jekyll/">Jekyll</a>, but huge static sites like mine take forever to build. What used to take seconds now go on for over 30 minutes, as thousands of files are generated and optimized.</p><p>Inspired by Anne Tomasevich’s post, <a href="http://savaslabs.com/2016/10/19/optimizing-jekyll-with-gulp.html"><strong>Optimizing Jekyll Performance with Gulp</strong></a> — I begun digging into my build process to identify performance bottlenecks.</p><p>At the time of writing this post, my site contained roughly:</p><ul><li>1,028 images generated at different sizes (5,140 in total).</li><li>1,052 total documents (<a href="https://github.com/mmistakes/made-mistakes-jekyll/tree/master/src/_posts">991 posts</a> / <a href="https://github.com/mmistakes/made-mistakes-jekyll/tree/master/src/_pages">14 pages</a> / 3 sets of collections).</li><li><a href="https://github.com/mmistakes/made-mistakes-jekyll/tree/master/src/_data/comments">535 comments</a> stored as YAML data files.</li></ul><p>And was built with the following Jekyll plugins: <a href="https://github.com/robwierzbowski/jekyll-picture-tag">jekyll-picture-tag</a>, <a href="https://github.com/mmistakes/made-mistakes-jekyll/blob/master/src/_plugins/sort_name.rb">sort_name</a>, <a href="https://github.com/jekyll/jekyll-archives">jekyll-archives</a>, <a href="https://github.com/jekyll/jekyll-assets">jekyll-assets</a>, <a href="https://github.com/pattex/jekyll-tagging">jekyll/tagging</a>, <a href="https://github.com/toshimaru/jekyll-tagging-related_posts">jekyll-tagging-related_posts</a>, <a href="https://github.com/jekyll/jekyll-sitemap">jekyll-sitemap</a>, <a href="https://github.com/jekyll/jemoji">jemoji</a>, <a href="http://ajclarkson.co.uk/blog/jekyll-category-post-navigation/">jekyll-category-post-navigation</a>, and <a href="https://github.com/myles/jekyll-typogrify">jekyll-typogrify</a>.</p><p>Using Jekyll’s profiler flag --profile, I measured how long the following tasks took to complete. Before each build I ran jekyll clean to wipe _site, .asset-cache and any other temporary files to keep results more consistent.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/828/1*Me7A41V80hzs8ShNVap_PA.png" /></figure><h4>Is Jekyll faster on macOS or Windows?</h4><p>For giggles I also tested my Windows and Mac development environments against each other. While not exactly an apples to apples comparison I thought it would be interesting to note any variations.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/779/1*K0WwH4dDcFddEbAmeHzv_w.png" /></figure><h3>Optimization</h3><p>The numbers above don’t lie. Relying on Jekyll and friends to do jobs more suited for a task runner like <a href="http://gulpjs.com/"><strong>Gulp</strong></a> was slowing the build. Armed with this knowledge I started stripping down Jekyll to one of its core purposes — <em>converting Markdown files into HTML</em>.</p><p>Doing this also allowed me to make my site’s content more portable and not as reliant on a specific static-site generator. In the off-chance I wanted to swap Jekyll for another SSG like <a href="https://gohugo.io/"><strong>Hugo</strong></a> or <a href="https://github.com/gatsbyjs/gatsby"><strong>Gatsby</strong></a>, I could.</p><h3>CSS and JavaScript Assets</h3><p><a href="https://github.com/jekyll/jekyll-assets"><strong>Jekyll Assets</strong></a> is a great plugin that served me well for a long time by: preprocessing, vendor prefixing, concatenating, minifying, and fingerprinting assets. But with a site of my size it was painfully slow to iterate with during front-end development.</p><p>Making a change to a Sass partial would trigger a full site rebuild, which meant waiting a few minutes before it could be previewed in a browser. Jekyll’s incremental build feature might have helped here, but I never had much luck getting it to work reliably.</p><p>During development CSS or JavaScript changes would ideally be pushed instantly to the browser with something like <a href="https://www.browsersync.io/">Browsersync</a>. By replacing <a href="https://github.com/jekyll/jekyll-assets">Jekyll Assets</a> with the following Gulp alternatives I was able to do this, and improve build times by 93%:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/828/1*yLxJk9QXX4g_VmB7s7U1xA.png" /></figure><p>Here’s a small taste of the <a href="https://github.com/mmistakes/made-mistakes-jekyll/blob/master/gulp/tasks/assets.js">Gulp file</a> I’m using for the site’s styles if you’re curious:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/864405b1182fe9684010694669bcdc8b/href">https://medium.com/media/864405b1182fe9684010694669bcdc8b/href</a></iframe><p>Without going too deep into how these Gulp tasks work, the gist is:</p><ol><li>A glob of files have “stuff” done to them using various plugins.</li><li>These files are placed in a temporary folder excluded from Jekyll so they don’t trigger a full site rebuild during development.</li><li>Production builds move these temporary files and deploys them alongside the HTML files generated by Jekyll.</li></ol><h3>Image Assets</h3><p>Resizing a thousand or so images to serve them responsively is no joke — taking over 20 minutes to complete in my site’s case. Up until now I was using the <a href="https://github.com/robwierzbowski/jekyll-picture-tag">Jekyll Picture Tag</a> plugin to do this work for me… which wasn’t ideal.</p><p>To try and see if <a href="https://nodejs.org/en/">Node</a> and <a href="http://gulpjs.com/">Gulp</a> could do this faster I came up with a set of Gulp tasks to:</p><ol><li>Generate thousands of “feature” images<a href="https://mademistakes.com/articles/using-jekyll-2017/#fn:feature-image">2</a>at 4 different sizes with <a href="https://github.com/mahnunchik/gulp-responsive"><strong>gulp-responsive</strong></a>.</li><li>Optimize all images using <a href="https://github.com/sindresorhus/gulp-imagemin"><strong>gulp-imagemin</strong></a>.</li><li>Save the optimized images directly to the destination folder — bypassing Jekyll and a full-site rebuild.</li></ol><p>This helped some, but it wasn’t until I <a href="https://github.com/mmistakes/made-mistakes-jekyll/commit/56bbd9bf5429a269047a41e045cc2ef0bf34e62b">dropped GraphicsMagick</a> for <a href="https://github.com/lovell/sharp">Sharp</a> did I see a noticeable improvement…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/782/1*8ZLV6Z2-CHfrjRPUaHYVGw.png" /></figure><p>The other missing piece was generating the necessary markup for responsive images. Because I was no longer using the {% picture %} tag to output a fully formed <a href="https://cloudfour.com/thinks/dont-use-picture-most-of-the-time/">&lt;picture&gt; element</a>, I had to roll my own responsive image markup.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e90fcaddaf0265460b1e543270378ddd/href">https://medium.com/media/e90fcaddaf0265460b1e543270378ddd/href</a></iframe><p>This bit of Liquid takes the filename as defined by page.image.feature, splits it at the extension, appends suffixes that match those used in the gulp-responsive task, and adds them to the srcset attribute.</p><p>This Gulp + Liquid hybrid isn’t as nice as a plugin since there is no logic to actually verify if -lq, -320, -768, or -1024 versions of the images exist. I’m willing to look passed that since it did shave 16 minutes off my build time.</p><h3>Simplify Layouts</h3><p>With the bulk of the time savings coming from faster image resizing tasks, I went after some low-hanging fruit next by <a href="https://github.com/mmistakes/made-mistakes-jekyll/issues/81">decluttering my layouts</a>. Anything that detracted from the main content or added visual noise to the page was fair game for removal.</p><p>Including buttons at the bottom (or top of post) didn’t really boost shares of my content on Twitter or Facebook — so I dropped them. If someone really wants to share it on social media they’ll use the built-in methods of iOS/Android or do it the old fashioned way of copy-pasting a URL.</p><h4>Replace layout: compress</h4><p>Occasionally things on the site would break if inline JavaScript with // styled comments were used. This happened because of a complex set of Liquid filters used in my <a href="http://jch.penibelst.de/">compress layout</a> to reduce whitespace in the generated HTML.</p><p>The fix was easy, just surround inline JavaScript comments with /* */ instead. Or do what I did, stop using layout: compress and minify with these Gulp plugins instead: <a href="https://github.com/jonschlinkert/gulp-htmlmin"><strong>gulp-htmlmin</strong></a> and <a href="https://github.com/jstuckey/gulp-gzip"><strong>gulp-gzip</strong></a>.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/268627c236a35ac0f89d4b42e23a5809/href">https://medium.com/media/268627c236a35ac0f89d4b42e23a5809/href</a></iframe><h4>Minifying HTML with Gulp</h4><p>In my tests, replacing <a href="http://jch.penibelst.de/">_layouts/compress.html</a> with Gulp tasks to minify and gzip every HTML file ended up being slightly slower.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/781/1*zgmwabkfmqWJUJ-LY3GASw.png" /><figcaption>I’m willing to live with the extra 8 seconds of build time as it helps avoid potential site breakages due to badly minified scripts…</figcaption></figure><h4>Reduce and Replace JavaScript</h4><p>I’m close to ditching jQuery and going vanilla, but I’m not quite there yet. Where possible I’ve ditched jQuery plugins and <a href="https://github.com/mmistakes/made-mistakes-jekyll/issues/84">replaced with “lighter” alternatives</a>. Here’s a few highlights:</p><ul><li>Replaced <a href="https://github.com/dimsemenov/Magnific-Popup"><strong>Magnific Popup</strong></a> with <a href="http://sorgalla.com/lity/"><strong>Lity</strong></a>.</li><li>Replaced <a href="https://github.com/verlok/lazyload"><strong>Lazyload</strong></a> with <a href="https://github.com/aFarkas/lazysizes"><strong>Lazysizes</strong></a> + <a href="https://github.com/aFarkas/lazysizes/tree/gh-pages/plugins/respimg">Lazysizes responsive images polyfill extension</a>.</li><li>Added <a href="https://github.com/jonathantneal/svg4everybody"><strong>SVG 4 Everybody</strong></a> for external SVG spritemap support.</li><li>Replaced <a href="http://fitvidsjs.com/"><strong>FitVids.JS</strong></a> with responsive embed CSS and a custom Jekyll <a href="https://github.com/mmistakes/made-mistakes-jekyll/blob/master/src/_plugins/video_embed.rb">video embed tag</a>.</li></ul><h3>Results</h3><p>Decoupling the asset pipeline from Jekyll and Gulp-ifying it made the biggest splash in terms of build time. Along with <a href="https://www.browsersync.io/">Browsersync</a>, any asset (CSS, JavaScript, images and icons) updates could be previewed almost instantly. Greatly speeding up the time it takes to develop and iterate the site’s front-end.</p><h4>Made Mistakes Gulp files</h4><p>This set of Gulp tasks were heavily inspired by those in Sondre Nilsen’s <a href="https://github.com/sondr3/generator-jekyllized"><strong>Jekyllized Yeoman generator</strong></a>. The main <a href="https://github.com/mmistakes/made-mistakes-jekyll/blob/master/gulpfile.js">gulpfile.js</a> is broken down into <a href="https://github.com/mmistakes/made-mistakes-jekyll/tree/master/gulp/tasks">smaller bits</a>: assets, build, clean, copy, html, images, and uploading.</p><p>With <a href="https://github.com/mmistakes/made-mistakes-jekyll/blob/master/gulp/paths.js">paths.js</a> assigning all of the various paths used throughout the files to DRYthings up.</p><h3>Automation/Continuous Integration</h3><p>After ditching Disqus last year to <a href="https://mademistakes.com/articles/jekyll-static-comments/">roll my own static-based solution</a> powered by <a href="https://staticman.net/"><strong>Staticman</strong></a>, I needed to find a better way of deploying the site. Merging in new comments, pulling those commits down, manually building the site locally, and then deploying to my web server wasn’t ideal.</p><p>With some research I determined a continuous integration platform like <strong>Travis CI </strong>that integrates with GitHub was what I needed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*nCaR9M6oXUh-xzPV.png" /></figure><p>Setting things up with Travis CI wasn’t too painful, but there was some trial and error getting dependencies squared away. I’d suggest reading through <a href="https://docs.travis-ci.com/">their documentation</a>, but the basic idea is:</p><ol><li><a href="https://travis-ci.org/auth">Sign in to Travis CI</a> with your GitHub account and grant it access.</li><li>Configure the build and deployment scripts with a <a href="https://github.com/mmistakes/made-mistakes-jekyll/blob/master/.travis.yml">.travis.yml</a> file.</li><li>Set the type of triggers<a href="https://mademistakes.com/articles/using-jekyll-2017/#fn:triggers">7</a>that initiate a build.</li></ol><h3>Travis CI Config</h3><p>Let’s take a closer look my .travis.yml config file and how I’ve set it up.</p><pre>language: ruby <br>rvm: <br>  - 2.2</pre><p>Since Jekyll is built on Ruby I set the language to ruby. Depending on what version of Jekyll you’re using you can change rvm to meet your needs. I went with 2.2 since that’s the latest <a href="https://docs.travis-ci.com/user/languages/ruby/#Supported-Ruby-Versions-and-RVM">Travis CI provides</a>.</p><pre>sudo: false</pre><p>This enables quicker build start times using the new <a href="https://docs.travis-ci.com/user/migrating-from-legacy/">container-based infrastructure</a>.</p><pre>branches:<br>  only:<br>    - master</pre><p>Fairly obvious, build only from the master branch.</p><pre>cache:<br>  bundler: true<br>  yarn: true<br>  directories:<br>    - node_modules # NPM packages</pre><p>Travis CI pulls down and installs gem and Node.js modules before every build. Depending on what you have in your Gemfile and package.json files this can take a bit of time.</p><p>The above lines enable caching of these dependencies eliminating this installation step.</p><pre>addons:<br>  apt:<br>    sources:<br>      - ubuntu-toolchain-r-test<br>    packages:<br>      - g++-4.8<br><br>env:<br>  CXX=g++-4.8</pre><p>Enables the <a href="https://gcc.gnu.org/">GCC, GNU Compiler Collection</a> using <a href="https://docs.travis-ci.com/user/installing-dependencies/#Installing-Packages-with-the-APT-Addon">APT Addon</a> and a newer version of gcc/g++ to properly install <a href="https://github.com/lovell/sharp">Sharp</a>.</p><h3>Travis CI Build Lifecycle</h3><p>My <a href="https://docs.travis-ci.com/user/customizing-the-build/#The-Build-Lifecycle">build lifecycle</a> breaks down like this:</p><ol><li>Clone repo and any submodules.</li><li>Install apt addons.</li><li>Install Ruby gems.</li><li>Upgrade Node.js and install <a href="https://yarnpkg.com/en/">Yarn</a> + Node modules.</li><li>Run Gulp production build task gulp build --prod.</li><li><a href="https://oncletom.io/2016/travis-ssh-deploy/">Decrypt private SSH keys</a> needed to rsync files to my server.</li><li>Run Gulp deploy task:</li></ol><pre>deploy:<br>  provider: script<br>  skip_cleanup: true<br>  script: gulp deploy<br>  on:<br>    branch: master</pre><p>With everything configured I no longer need to build locally and deploy. I can merge in comments or make small edits to Markdown files directly on GitHub, and automatically trigger a site build/deploy.</p><p>If there’s a problem Travis CI will notify me, otherwise in ~15 minutes (or however long the build takes) any changes committed will be live on the site.</p><h4>ProTip: Use Travis CI with Sites Hosted on GitHub Pages</h4><p>Travis CI comes in handy if you want to use Jekyll plugins or a more advanced Gulp workflow like I am. There are <a href="https://docs.travis-ci.com/user/deployment/pages/">deployment scripts</a> specifically for this purpose.</p><p><a href="https://www.netlify.com/">Netlify</a>, <a href="https://pages.gitlab.io/">GitLab</a>, and friends also do similar things if you’re feeling constrained by what’s currently allowed by GitHub Pages.</p><h3>Other Jekyll Related Bits</h3><h4>Pagination Upgrades</h4><p>Looking to wring a little more #WebPerf juice out of my site, I went after category and tag archive pages next. Depending on the tag, these index.html pages could be quite hefty due to the amount of HTML needed to display hundreds of post teasers.</p><p>To trim them down in size I needed a way of paginating these pages into small chunks. Jekyll has an <a href="http://jekyllrb.com/docs/pagination/">official pagination plugin</a>, but unfortunately it’s limited (and deprecated) in what it can actually paginate. <a href="https://github.com/sverrirs/jekyll-paginate-v2"><strong>Jekyll Paginate v2</strong></a> on the other hand is fully featured, backwards compatible, and actively being worked on.</p><p>In addition to paginating posts it can handle: <a href="https://github.com/sverrirs/jekyll-paginate-v2/blob/master/README-GENERATOR.md#paginating-collections">collections</a>, <a href="https://github.com/sverrirs/jekyll-paginate-v2/blob/master/README-GENERATOR.md#filtering-categories">categories</a>, <a href="https://github.com/sverrirs/jekyll-paginate-v2/blob/master/README-GENERATOR.md#filtering-tags">tags</a>, and <a href="https://github.com/sverrirs/jekyll-paginate-v2/blob/master/README-GENERATOR.md#filtering-locales">locales</a> (useful if you have a multi-language site).</p><p>It doesn’t stop there though! It has a built-in generator called <a href="https://github.com/sverrirs/jekyll-paginate-v2/blob/master/README-AUTOPAGES.md"><strong>Auto-Pages</strong></a> to create tag, category, and collection archives. Which unlike <a href="https://github.com/jekyll/jekyll-archives"><strong>Jekyll Archives</strong></a>, can all be paginated.</p><p>With a few changes to my _config.yml file and adapting my Jekyll Archive <a href="https://github.com/mmistakes/made-mistakes-jekyll/blob/master/src/_layouts/autopage_tags.html">layout</a> to work with <a href="https://github.com/sverrirs/jekyll-paginate-v2">Jekyll Paginate v2</a>, I was ready to roll.</p><pre># Plugin: Pagination (jekyll-paginate-v2)<br>pagination:<br>  enabled      : true<br>  debug        : false<br>  per_page     : 15<br>  permalink    : &quot;/page/:num/&quot;<br>  title        : &quot;:title - Page :num of :max&quot;<br>  limit        : 0<br>  sort_field   : &quot;date&quot;<br>  sort_reverse : true<br><br># Plugin: Auto Pages (jekyll-paginate-v2)<br>autopages:<br>  enabled      : true<br>  categories:<br>    enabled    : false<br>  collections:<br>    enabled    : false<br>  tags:<br>    enabled    : true<br>    layouts:<br>      - &quot;autopage_tags.html&quot;<br>    title      : &quot;:tag&quot; # :tag is replaced by the tag name<br>    permalink  : &quot;/tag/:tag&quot;</pre><p>For category archives I created my own bespoke pages since there are only a handful of them. Mostly because it was easier to customize them than generating with <a href="https://github.com/sverrirs/jekyll-paginate-v2/blob/master/README-AUTOPAGES.md">Auto-Pages</a>.</p><p><strong>Step 1:</strong> Create an archive page… let’s use my <a href="https://mademistakes.com/article/">Articles archive</a> as an example. I like to keep all of my source pages grouped together, so I created articles.md and placed it in a <a href="https://mademistakes.com/articles/using-jekyll-2016/#pages-for-everything-else%7D">folder named </a><a href="https://mademistakes.com/articles/using-jekyll-2016/#pages-for-everything-else%7D">_pages</a>.</p><p><strong>Step 2:</strong> Enable pagination and define what categories it should filter, in this case articles by adding the following YAML Front Matter to articles.md.</p><pre>pagination: <br>  enabled: true<br>  category: articles</pre><h4>ProTip: <a href="https://github.com/sverrirs/jekyll-paginate-v2/blob/master/README-GENERATOR.md#filtering-categories">Filter Multiple Categories</a></h4><p>Want to combine several categories into one paginator object? Jekyll Paginate v2 has you covered. Just add additional categories as a comma separated list e.g. category: foo, bar.</p><p><strong>Step 3:</strong> Output the posts by looping through the paginator.posts array. A simple example would look something like this:</p><pre>&lt;ul&gt;<br>  {% for post in paginator.posts %}<br>    &lt;!-- what you want to output. title, url, image, etc. --&gt;<br>    &lt;li&gt;&lt;a href=&quot;{{ post.url }}&quot;&gt;{{ post.title }}&lt;/a&gt;&lt;/li&gt;<br>  {% endfor %}<br>&lt;/ul&gt;</pre><p>And for “next/previous” navigation links you can do something like this:</p><pre>{% if paginator.total_pages &gt; 1 %}<br>  {% if paginator.previous_page %}<br>    &lt;a href=&quot;{{ paginator.previous_page_path }}&quot;&gt;Newer Posts&lt;/a&gt;<br>  {% endif %}<br>  {% if paginator.next_page %}<br>    &lt;a href=&quot;{{ paginator.next_page_path }}&quot;&gt;Older Posts&lt;/a&gt;<br>  {% endif %}<br>{% endif %}</pre><h3>Lazyload Tag</h3><p>Another #WebPerf improvement was adding the ability to defer loading of images and video embeds.</p><p>To do this I created a custom Jekyll plugin using <a href="https://github.com/aFarkas/lazysizes"><strong>lazysizes</strong></a> to do some JavaScript magic.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/820/1*iOiaHWHoem7tnu0ttuUMsw.png" /></figure><p><strong>Example:</strong></p><pre>{% lazyload data-src=&quot;/assets/images/my-image.jpg&quot; src=&quot;/assets/images/my-image-low-quality.jpg&quot; alt=&quot;my lazyloaded image&quot; %}</pre><p>A Liquid version of this method is used in the <a href="https://github.com/mmistakes/made-mistakes-jekyll/blob/master/src/_includes/page__hero.html">hero image include</a> to apply a nice blur effect as those large images are loaded by the browser.</p><h3>Responsive Video Embed Tag</h3><p>Custom Jekyll plugin to embed a video from YouTube or Vimeo that responsively sizes to fit the width of its parent using <a href="https://mademistakes.com/articles/using-jekyll-2017/src/_plugins.video_embed.rb">/_plugins/video_embed.rb</a>.</p><p>Embeds are also <a href="https://mademistakes.com/articles/using-jekyll-2017/#lazyload-tag">lazyloaded</a> to improve page performance.</p><h4>YouTube Embed</h4><p>To embed the following YouTube video at url https://www.youtube.com/watch?v=fFX1CUO472U (long version) or https://youtu.be/fFX1CUO472U (short version) into a post or page’s main content you’d use:</p><pre>{% youtube fFX1CUO472U %}</pre><h4>Vimeo Embed</h4><p>To embed the following Vimeo video at url https://vimeo.com/97649261 into a post or page’s main content you’d use:</p><pre>{% vimeo 34948855 %}</pre><h3>Simplified Breadcrumbs</h3><p>Previously I was using some Liquid voodoo to <a href="https://github.com/mmistakes/made-mistakes-jekyll/blob/10.3.0/src/_includes/breadcrumbs.html">build a trail of breadcrumbs</a>. This sort of worked because my site structure isn’t too complex. On the other hand it wasn’t flexible and didn’t allow for overriding crumbs with more descriptive labels.</p><p>Since my content hierarchy is shallow I decided to manually assign breadcrumbs to each post with YAML Front Matter.</p><pre>breadcrumbs:<br>  - label: &quot;Blog Articles&quot;<br>    url: /articles/</pre><p>Then using this Liquid and HTML it’s outputted in my layout:</p><pre>{% if page.breadcrumbs %}<br>  {% assign crumb = page.breadcrumbs[0] %}<br>  &lt;a href=&quot;{{ crumb.url }}&quot;&gt;&lt;strong&gt;{{ crumb.label }}&lt;/strong&gt;&lt;/a&gt;<br>{% endif %}</pre><p>For multiple levels of breadcrumbs the following YAML and sample for loop should get the job started.</p><pre>breadcrumbs:<br>  - label: &quot;Level 1&quot;<br>    url: /level-1/<br>  - label: &quot;Level 2&quot;<br>    url: /level-2/</pre><pre>{% if page.breadcrumbs %}<br>  &lt;ul class=&quot;breadcrumbs&quot;&gt;<br>    {% for crumb in page.breadcrumbs %}<br>      &lt;li&gt;&lt;a href=&quot;{{ crumb.url }}&quot;&gt;{{ crumb.label }}&lt;/a&gt;&lt;/li&gt;<br>    {% endfor %}<br>  &lt;/ul&gt;<br>{% endif %}</pre><h4>ProTip: Add Breadcrumbs Using <a href="http://jekyllrb.com/docs/configuration/#front-matter-defaults">Front Matter Defaults</a></h4><p>Take a DRY approach and <a href="https://github.com/mmistakes/made-mistakes-jekyll/blob/11.0.0/_config.yml#L126-L128">add breadcrumbs</a> at the category level instead of on every post/page. defaults: in _config.yml is your friend.</p><h3>Popular Tags</h3><p>Looking over my site’s analytics I came to the conclusion no one was clicking on the “this post was tagged” links, so I removed them. To make category pages more sticky and useful including tags seemed more useful. So with the following Liquid I was able to build a list of the most popular tags filtered on the current category.</p><pre>{% assign filterCategory = page.pagination.category | default: page.category %}<br><br>&lt;ul&gt;<br>  {% assign tagLimiter = 0 %}<br>  {% for tag in site.tags %}<br>    {% comment %}create an empty array{% endcomment %}<br>    {% assign postsInCategory = &quot;&quot; | split: &quot;/&quot; %}<br><br>    {% comment %}loop over site.tags{% endcomment %}<br>    {% for post in tag[1] %}<br>      {% if post.categories contains filterCategory %}<br>        {% comment %}if a post is in the filter category add it to postsInCategory array{% endcomment %}<br>        {% assign postsInCategory = postsInCategory | push: post %}<br>      {% endif %}<br>    {% endfor %}<br><br>    {% comment %}poor man&#39;s tag limit on those that are frequently used{% endcomment %}<br>    {% if postsInCategory.size &gt;= 5 and tagLimiter &lt;= 5 %}<br>      {% assign tagLimiter = tagLimiter | plus: 1 %}<br>      &lt;li&gt;&lt;a href=&quot;/tag/{{ tag[0] | replace:&#39; &#39;,&#39;-&#39; | downcase }}/&quot; &gt;{{ tag[0] }}&lt;/a&gt;&lt;/li&gt;<br>    {% endif %}<br>  {% endfor %}<br>&lt;/ul&gt;</pre><p>On my <strong>Mastering Paper</strong> category page about the iPad app <a href="http://www.fiftythree.com/">Paper by FiftyThree</a>, you’ll see related links to tags like <em>Paper by 53</em>, <em>iPad</em>, <em>drawing</em>, etc.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/862/0*LrN7euPFuDzPFGgN.png" /></figure><p>Well there you have it, the complete tale of how I took something inherently simple and overly complicated it to suit my needs 😜.</p><p><em>Originally published at </em><a href="https://mademistakes.com/articles/using-jekyll-2017/"><em>mademistakes.com</em></a><em> on August 30, 2017.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5eb2aaeee3b1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How I’m Using Jekyll in 2016]]></title>
            <link>https://medium.com/@mmistakes/how-i-m-using-jekyll-in-2016-750e1e4a8cf9?source=rss-28f2062ce9ef------2</link>
            <guid isPermaLink="false">https://medium.com/p/750e1e4a8cf9</guid>
            <category><![CDATA[jekyll]]></category>
            <category><![CDATA[github]]></category>
            <category><![CDATA[web-development]]></category>
            <dc:creator><![CDATA[Michael Rose]]></dc:creator>
            <pubDate>Fri, 04 Mar 2016 15:05:22 GMT</pubDate>
            <atom:updated>2016-03-04T15:05:22.541Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KrnBoACoZmg5JVzPyOJOuw.jpeg" /></figure><p>I first started using <a href="http://jekyllrb.com/"><strong>Jekyll</strong></a> — a static site generator, back in 2012. In the four years since, it has indirectly introduced me to a host of new tools and ways of building websites. Hell, I wasn’t even using version control when developing this site — so you know a lot has changed.</p><p>What follows is a brain dump documenting my approach to using Jekyll, how that’s evolved over the years, and any other learnings I’ve picked up along the way. This is mostly an excuse for me to capture and reflect on things, but maybe you’ll find some useful nuggets in the mess that’s sure to follow.</p><h3>Converting and Restructuring Content</h3><p>To learn how Jekyll works I set off on a journey to turn a <a href="https://wordpress.org/"><strong>Wordpress</strong></a> powered site into the static version you see now. I read several tutorials, learned Kramdown<a href="https://mademistakes.com/articles/using-jekyll-2016/#fn:kramdown">1</a>and <a href="https://docs.shopify.com/themes/liquid-documentation/basics">Liquid</a>, <a href="https://mademistakes.com/articles/going-static/">blogged about the process</a>, and eventually ended up with something I was happy with — all without a database or CMS.</p><h3>Posts for All the Things</h3><p>As Jekyll has matured and added features, the complexity at which I use it has too. In those early days, content could only be considered a <strong>post</strong> or <strong>page</strong>. Posts became more valuable to me than pages since they could reap the benefits of site.tags and site.categories for creating archives and as a way to surface “related content”.</p><p>Posts made a lot of sense then because the only type of content I had on the site were blog posts. As I started incorporating things like portfolio pieces into the site I used categories as a way to structure content by “post type.” For example, <a href="https://mademistakes.com/articles/"><strong>Blog Articles</strong></a> would get categories: articles added to their YAML Front Matter and <strong>permalink: /:categories/:title/</strong> in _config.yml to produce pretty URLs like <strong>/articles/jekyll-is-the-best/</strong>.</p><p>A drawback I hit with this method was reliable pagination between posts. Jekyll provides the variables page.previous and page.next to help create previous/next style links between posts. But because I was trying to section off posts by category, these links didn’t always behave as expected.</p><p>For example, when reading a post in the articles category, I’d expect the <strong>NEXT →</strong> link to show the next article post. Instead, something from the portfolio category came up because it was the next item in the site.posts array. With plugins or a messy bit of Liquid you could probably filter on the current category and get around this, but I never took it that far.</p><p>Details like this drive me bonkers, so instead I opted for a <strong>You May Also Enjoy</strong> module that displays three related posts (with the help of a plugin) at the bottom of the page. In my eyes, this provided a better reading experience even if my site took longer to generate at build…</p><pre>         Jekyll version     Build time    Posts<br>Then     0.12.1             &lt; 1s          25<br>Now      3.1.1              121.62s       980</pre><p>It’s no coincidence that my build times went from under a second to a few minutes as I hit almost 1,000 posts. Moving to solid-state drives and reducing the amount of Liquid for loops in my layouts and includes has helped — but I still have ways to go if I want to speed things up further.</p><p>The new <strong>— incremental regeneration</strong> feature will eventually play a big role in speeding things up. On a default jekyll new site it works really well, but unfortunately I haven’t had much luck getting it to play nicely with the plugins I use. Work currently being done on this feature seems like its <a href="https://github.com/jekyll/jekyll/pull/4269">going in the right direction</a>, so I’m sure in time things will sort out.</p><p>For now the best I can do is use the new <strong>Liquid Profiler </strong>to identify problematic bits and simplify where I can. I add new content so infrequently that it really isn’t a bother waiting 2 minutes for a build to finish, but damn it would be nice to hit &lt; 1s again!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/851/0*0jAnoCLNoQ0XO6Yl.png" /></figure><h3>Collections</h3><p>When <a href="http://jekyllrb.com/docs/collections/">collections</a> were introduced back in v2.0, I decided to build out a <a href="https://mademistakes.com/faqs/"><strong>Frequently Asked Questions</strong></a> section on my site to familiarize myself with the feature.</p><p>Creating a collection of FAQ items turned out to be easier than expected. Make a _faqs directory populated with Markdown-formatted text files (like any other post or page), configure the collection in _config.yml, build an <a href="https://github.com/mmistakes/made-mistakes-jekyll/blob/master/_pages/faqs/index.md">index page</a> to display all of the collection’s documents, and done!</p><pre># _config.yml<br>collections:<br>  faqs:<br>    output: true<br>    permalink: /:collection/:path/<br>    title: FAQs</pre><p>As collections have elevated in status they’re increasingly becoming my preferred way of working with static content. In addition to the FAQs collection I’ve also created one to build a “<a href="https://mademistakes.com/articles/jekyll-style-guide/">living style guide</a>” of sorts — documenting the look and feel of the site with visual representations and code samples.</p><p>Eventually I plan to convert more posts into their own collections. Posts currently categorized as work seem like the obvious choice since its always felt funny shoe-horning them into _posts. As far as others? Not sure yet.</p><p>What I’d like to investigate deeper is adding taxonomies to collections and how they mingle with the tags and categories already in site.posts. I’m not exactly sure if they coexist with site.tags or how <a href="https://mademistakes.com/tag/">tag archives</a> generated by <a href="https://github.com/jekyll/jekyll-archives"><strong>Jekyll Archives</strong></a> might see them. A job best saved for a rainy day I suppose…</p><h3>Pages for Everything Else</h3><p>Content that doesn’t need to be ordered chronologically or grouped in any way becomes a <strong>page</strong>. To keep things nice and tidy I place all of the source .md or .html files into a_pages directory and assign permalink overrides in the YAML Front Matter of each.</p><p>An architecture like this helps centralize the content so you’re not poking around trying to locate files. Meaningfully naming files should be the goal. Avoid patterns like/about/index.md as it makes distinguishing between multiple index.md files harder.</p><pre>project-name/<br>├── _assets/<br>├── _data/<br>├── _drafts/<br>├── _includes/<br>├── _layouts/<br>├── _pages/<br>|   ├── 404.md               # custom 404 page<br>|   ├── about.md             # about page<br>|   ├── contact.md           # contact page<br>|   └── home.md              # home page (eg. &lt;root&gt;/index.html)<br>├── _posts/<br>├── .gitignore<br>├── _config.yml<br>└── Gemfile</pre><p>And then in each Markdown file I set a permalink that fits in with the format used on the rest of the site.</p><p>Examples: about.md ~&gt; <strong>permalink: /about/</strong>, home.md ~&gt; <strong>permalink: /</strong>, contact.md ~&gt; <strong>permalink: /contact/</strong>, etc.</p><h4>ProTip: Include Your Pages Directory</h4><p>To be sure Jekyll “sees” and processes the files inside of _pages, be sure to include it. Add include: [“_pages”] to _config.yml and you should be good to go.</p><h3>An Evolution</h3><p>From a workflow perspective, things have mostly stayed the same. I still “write in Markdown”, build this site locally, and push the contents of the _site directory to a web server. On the development side, however, complexities have been introduced in an effort to optimize and improve website performance.</p><p>Tinkering and experimenting with the visual design of Made Mistakes whenever I want is important to me. Since I work on both Mac OS X and Windows based devices I need tooling that plays nicely with each. Below are the tools, configurations, and Jekyll plugins that help do that.</p><h3>Bundler</h3><p>Installing Ruby, Bundler, and Ruby Gems were all new to me four years ago. Running jekyll build on different operating systems felt like a crap shoot. A setup that worked one day would most certainly break the next after updating Jekyll on a Windows machine.</p><p>I eventually learned to embrace <a href="http://bundler.io/">Bundler</a> from the advice of numerous Stack Overflow threads and GitHub issues. Since Bundler is the official way to install Jekyll it wasn’t that big of a leap for me to start using a Gemfile to manage all dependencies. To do that:</p><ol><li>Run bundle init to create an empty Gemfile</li><li>Add gem ‘jekyll’ and any other gems to the Gemfile.</li></ol><pre># Made Mistakes example Gemfile<br><br>source &#39;https://rubygems.org&#39;<br><br>gem &#39;breakpoint&#39;<br>gem &#39;wdm&#39;, &#39;~&gt; 0.1.0&#39; if Gem.win_platform?<br>gem &#39;mini_magick&#39;<br>gem &#39;autoprefixer-rails&#39;<br>gem &#39;uglifier&#39;<br><br># Jekyll and Plugins<br>gem &#39;jekyll&#39;<br>gem &#39;jekyll-archives&#39;<br>gem &#39;jekyll-tagging-related_posts&#39;<br>group :jekyll_plugins do<br>  gem &#39;jekyll-assets&#39;, github: &#39;jekyll/jekyll-assets&#39;<br>  gem &#39;jekyll-sitemap&#39;, github: &#39;jekyll/jekyll-sitemap&#39;<br>end</pre><p>Now when running bundle install each of the gems specified above are installed and a Gemfile.lock is created listing all of the dependencies. Prepending all Jekyll commands with bundle exec ensures only the versions in Gemfile.lock are executed helping to mitigate conflicts.</p><p>Committing both of these Gemfiles to a git repository also makes it easy to revert back if a gem update goes bad. Sure it’s a few more characters to type, but the headaches it solves are more than worth it. You can even write shortcut tasks with Rakefiles to eliminate the extra keystrokes — if automation is your thing (more on that below).</p><h3>Environments and Configurations</h3><p>With the introduction of asset related plugins and various other build steps, I eventually settled on two Jekyll configuration files. A default _config.yml with production settings and _config.dev.yml for development specific ones.</p><p>The cool thing is you can chain together these configuration files, overriding settings from the previous. For example, when building locally I’d like {{ site.url }} and {{ site.disqus-shortname }} to default to their development equivalents for testing purposes. Adding the following values to _config.dev.yml overrides the ones in _config.yml:</p><pre>url: <a href="http://localhost:4000/">http://localhost:4000</a><br>disqus-shortname: mmistakes-dev</pre><p>A development server can then be fired up with the relevant settings using…</p><pre>$ bundle exec jekyll serve — config _config.yml,_config.dev.yml</pre><p>Going one step further a Jekyll environment can be specified as well. By default Jekyll runs in development with a value of JEKYLL_ENV=development. The <a href="https://github.com/mmistakes/made-mistakes-jekyll/blob/master/_layouts/compress.html">compress.html</a> layout and <a href="https://github.com/jekyll/jekyll-assets"><strong>Jekyll-Assets</strong></a> plugin both make use of this triggering HTML, CSS, and JavaScript compression with the following command:</p><pre>$ JEKYLL_ENV=production bundle exec jekyll build</pre><h4>Windows Environment Gotcha</h4><p>On Windows I had issues minifying when JEKYLL_ENV=production bundle exec jekyll build silently failed. Instead, I found that the <a href="http://ss64.com/nt/set.html">SET</a> command had to be used to assign environment variables.</p><pre>&gt; set JEKYLL_ENV=production</pre><h4>Other Configurations</h4><p>As mentioned earlier I have a moderately sized Jekyll site at 982 posts. Combine that fact with an /images/ directory that is close to 2 GB, a liberal use of Liquid for loops, and generator plugins like <a href="https://github.com/jekyll/jekyll-archives"><strong>Jekyll Archives</strong></a> — you get site builds that are far from instant. And in the rare cases when I run jekyll clean to flush caches and everything in /_site/, builds can take over 15 minutes as the <a href="https://github.com/robwierzbowski/jekyll-picture-tag"><strong>Jekyll Picture Tag</strong></a> plugin regenerates appropriately sized hero images for every posts. Yikes!</p><p>So as you might have guessed, I sure as hell never start up a server with <em>auto-regeneration</em> enabled. Instead, I start with bundle exec jekyll serve — no-watch and then run a rake task to manually build every time I want to check changes locally.</p><p>When working on the site’s design it can be cumbersome to sit through a 2 minute build just to check a CSS change. But until — incremental works reliably its something I have to suffer through (or use plugins to isolate posts at build). Its a good thing I do a lot of my ‘designing’ in-browser with <a href="https://developer.chrome.com/devtools">Chrome’s DevTools</a> before editing the actual source as this hasn’t been too annoying.</p><p>To save time (and my sanity) when working on the site locally, I employee a few tools to perform common development related tasks.</p><h4>Grunt</h4><p><a href="http://gruntjs.com/"><strong>Grunt</strong></a> describes itself as “the JavaScript task runner.” Grunt has a fairly large set of plugins that can handle pretty much any mundane task you through at it.</p><p>Prior to Jekyll natively supporting Sass I used Grunt plugins to pre-process .less files, concatenate a set of JavaScript files, and optimize image assets. Now that I’m running Jekyll 3.1 and the Jekyll-Assets plugin I no longer need Grunt to mess with my scripts and stylesheets.</p><p>These days I use Grunt solely for optimizing images and SVGs with the following plugins:</p><pre>// Grunt plugins in package.json<br>&quot;devDependencies&quot;: {<br>  &quot;grunt&quot;: &quot;~0.4.2&quot;,<br>  &quot;grunt-newer&quot;: &quot;^0.7.0&quot;,<br>  &quot;grunt-imgcompress&quot;: &quot;~0.1.1&quot;,<br>  &quot;grunt-svgmin&quot;: &quot;~0.3.1&quot;,<br>  &quot;grunt-svgstore&quot;: &quot;^0.5.0&quot;<br>}</pre><p>When I add new JPEG or PNG assets to /images/ I use the following command to optimize them — reducing their file size and speeding up page loads.</p><pre>$ grunt images</pre><p>On the SVG side of things any files added to /_svg/ are optimized and merged into a <a href="https://css-tricks.com/svg-sprites-use-better-icon-fonts/">single sprite map</a> with the following command:</p><pre>$ grunt svg</pre><p>In combination with both of these tasks I use the <a href="https://www.npmjs.com/package/grunt-newer"><strong>grunt-newer</strong></a> plugin. This dramatically speeds up things as only new and modified files are processed.</p><h4>Rake</h4><p>On the build and deployment side of things I have a few shortcut tasks defined in Rakefile.rb. As mentioned earlier typing out bundle exec before Jekyll commands can get old fast. Instead, I use the following:</p><p><strong>Start up a Jekyll server</strong></p><pre>$ rake serve</pre><p><strong>Production Build, Development Build, and Build with Drafts</strong></p><pre>$ rake build $ rake build:dev $ rake build:drafts</pre><p><strong>Deployment</strong></p><p>Since I self-host my site I need a way of pushing the contents of the /_site/ directory after a production build. Years ago I’d use <a href="https://cyberduck.io/"><strong>Cyberduck</strong></a> or <a href="https://filezilla-project.org/"><strong>FileZilla</strong></a> to transfer everything over slowly to <a href="http://bit.ly/1Ugg7nN">Media Temple</a> via FTP.</p><p>These days I use <strong>rsync</strong> to speed that transfer way the hell up, sending only new and modified files. It’s also a task that I can automate by adding the following to my <a href="https://github.com/mmistakes/made-mistakes-jekyll/blob/master/Rakefile.rb">Rakefile.rb</a> file.</p><pre># Usage: rake rsync<br>desc &quot;rsync the contents of ./_site to the server&quot;<br>task :rsync do<br>  puts &quot;* rsyncing the contents of ./_site to the server&quot;<br>  system &quot;rsync --perms --recursive --verbose --compress --delete --chmod=Du=rwx,Dgo=rx,Fu=rw,Fgo=r _site/ SSHuser@mydomain.com&quot;<br>end</pre><p>As part of my deployment process I also run tasks that notify <a href="http://pingomatic.com/">Ping-O-Matic</a>, Google, and Bing that the site has been updated and to index the <a href="https://mademistakes.com/sitemap.xml">sitemap.xml</a> and <a href="https://mademistakes.com/atom.xml">atom.xml</a> feeds. These tasks look something like this:</p><pre># Usage: rake notify<br>task :notify =&gt; [&quot;notify:pingomatic&quot;, &quot;notify:google&quot;, &quot;notify:bing&quot;]<br>desc &quot;Notify various services that the site has been updated&quot;<br>namespace :notify do<br><br>  desc &quot;Notify Ping-O-Matic&quot;<br>  task :pingomatic do<br>    begin<br>      require &#39;xmlrpc/client&#39;<br>      puts &quot;* Notifying Ping-O-Matic that the site has updated&quot;<br>      XMLRPC::Client.new(&#39;rpc.pingomatic.com&#39;, &#39;/&#39;).call(&#39;weblogUpdates.extendedPing&#39;, &#39;mydomain.com&#39; , &#39;//mydomain.com&#39;, &#39;//mydomain.com/atom.xml&#39;)<br>    rescue LoadError<br>      puts &quot;! Could not ping ping-o-matic, because XMLRPC::Client could not be found.&quot;<br>    end<br>  end<br><br>  desc &quot;Notify Google of updated sitemap&quot;<br>  task :google do<br>    begin<br>      require &#39;net/http&#39;<br>      require &#39;uri&#39;<br>      puts &quot;* Notifying Google that the site has updated&quot;<br>      Net::HTTP.get(&#39;www.google.com&#39;, &#39;/webmasters/tools/ping?sitemap=&#39; + URI.escape(&#39;//mydomain.com/sitemap.xml&#39;))<br>    rescue LoadError<br>      puts &quot;! Could not ping Google about our sitemap, because Net::HTTP or URI could not be found.&quot;<br>    end<br>  end<br><br>  desc &quot;Notify Bing of updated sitemap&quot;<br>  task :bing do<br>    begin<br>      require &#39;net/http&#39;<br>      require &#39;uri&#39;<br>      puts &#39;* Notifying Bing that the site has updated&#39;<br>      Net::HTTP.get(&#39;www.bing.com&#39;, &#39;/webmaster/ping.aspx?siteMap=&#39; + URI.escape(&#39;//mydomain.com/sitemap.xml&#39;))<br>    rescue LoadError<br>      puts &quot;! Could not ping Bing about our sitemap, because Net::HTTP or URI could not be found.&quot;<br>    end<br>  end<br>end</pre><p>And with a simple rake deploy I can build a production-ready version of the site, rsync everything over to my web host, and notify search engines there’s new content to crawl.</p><h3>Asset Pipeline</h3><p>Originally I wrote my stylesheets in <a href="http://lesscss.org/">Less</a> and squished them down with a Grunt task. Then one day Jekyll grew up and started supporting Sass files natively so I converted everything over and was able to remove a dependency. Hooray!</p><p>Not content with that workflow I eventually leveled-up by incorporating the <a href="https://github.com/jekyll/jekyll-assets"><strong>Jekyll-Assets</strong></a> plugin into the mix. It’s a powerful gem with an assortment of tags that make cache busting and inlining assets (something I’ll get to in a minute) so much easier.</p><p>It also supports the wonderful <a href="http://postcss.org/">PostCSS</a> plugin <a href="https://github.com/postcss/autoprefixer">Autoprefixer</a>, for automatically adding vendor prefixes to CSS rules. CSS declarations like this:</p><pre>.post__content {<br>  display: flex;<br>  flex-direction: column;<br>  flex-wrap: nowrap;<br>  margin-top: 1em;<br>}</pre><p>Get properly prefixed without any additional effort…</p><pre>.post__content {<br>  display: -webkit-box;<br>  display: -webkit-flex;<br>  display: -ms-flexbox;<br>  display: flex;<br>  -webkit-box-orient: vertical;<br>  -webkit-box-direction: normal;<br>  -webkit-flex-direction: column;<br>  -ms-flex-direction: column;<br>  flex-direction: column;<br>  -webkit-flex-wrap: nowrap;<br>  -ms-flex-wrap: nowrap;<br>  flex-wrap: nowrap;<br>  margin-top: 1em;<br>}</pre><p>Even better, when browsers don’t need this extra prefixed nonsense — Autoprefixer will leave it out based on the browsers: set in my Jekyll config.</p><p>For this site I target the <em>last 2 versions</em> of each major browser, browsers that have a <em>global usage of over 5%</em>, or are <em>Internet Explorer 9+</em>.</p><pre># _config.yml assets: autoprefixer: browsers: [&quot;last2versions&quot;, &quot;&gt;5%&quot;, &quot;IE9&quot;]</pre><h3>Page Speed Optimizations</h3><h3>Critical Path CSS</h3><p>To speed up page loads I’ve gone to the trouble of <a href="https://www.smashingmagazine.com/2015/08/understanding-critical-css/">inlining the critical CSS</a> needed to render a page. I didn’t use any fancy tools to determine what was critical but instead structured my SCSS partials in a way that the important visual stuff comes first.</p><p>With a focus on modular CSS, I can build critical and non-critical flavors by @import-ing the bits needed for each fairly easily. Using the Jekyll-Assets asset_source tag<a href="https://mademistakes.com/articles/using-jekyll-2016/#fn:assets-tag-example">5</a>to output the contents of <a href="https://github.com/mmistakes/made-mistakes-jekyll/blob/master/_assets/stylesheets/critical.css.scss">critical.scss</a> into the &lt;head&gt; of ever page and a bit of JavaScript to <a href="https://github.com/filamentgroup/loadCSS">asynchronously load the non-critical stuff</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*kTLR-w3OZOZrIvTu.jpg" /></figure><pre>&lt;head&gt;<br>  &lt;style type=&quot;text/css&quot;&gt;<br>    {% capture criticalcss %}<br>      {% include critical.scss %}<br>    {% endcapture %}<br>    {{ criticalcss | scssify }}<br>  &lt;/style&gt;<br>&lt;/head&gt;</pre><h4>Responsive Images Revisited</h4><p>Inlining the above the fold CSS and lazy loading the rest wasn’t the only site performance improvement I’ve made. The biggest hurdle I’ve come across working with Jekyll is image management. Since Jekyll isn’t a CMS and I have thousands of image assets, finding a solution to <a href="http://alistapart.com/article/responsive-images-in-practice">serve them responsively</a> has been challenging.</p><p>Since day one I’ve been trying to get closer to this <a href="https://github.com/jekyll/jekyll-assets/issues/172">dream scenario</a>:</p><ol><li>Link images in a post/page with just Markdown (e.g. ![image](image-name.jpg)).</li><li>Automatically generate smaller sizes (perhaps specified in _config.yml).</li><li>&lt;img&gt; elements are spit out with the correct srcset and sizes markup.</li></ol><p>To my knowledge there are no Jekyll plugin that do this, though some get close — <a href="https://github.com/robwierzbowski/jekyll-picture-tag">Jekyll-Picture-Tag</a>, <a href="https://github.com/wildlyinaccurate/jekyll-responsive-image">Jekyll-Responsive-Image</a>, <a href="https://github.com/netlify/jekyll-srcset">Jekyll-Srcset</a>. <strong>Jekyll-Picture-Tag</strong> does most of what I want (automatically size images from presets) with tags like {% picture image.jpg %}, which means I have to forgo linking to images with plain Markdown for now.</p><p>When setting up the plugin I focused in on the large hero images and decided to worry about the others later. Replacing Markdown images with {%picture%} tags for 1,000 posts just isn’t feasible yet. Since the hero images are Liquid driven they proved much easier to implement.</p><p>All it took was changing &lt;img src=”{{ page.image.feature }}” alt=““””&gt; to {% picturehero {{ page.image.feature }}alt=”” %} and settling on this configuration:</p><pre>picture:<br>  source: &quot;images/_originals&quot;<br>  output: &quot;images&quot;<br>  markup: &quot;picture&quot;<br>  presets:<br>    hero:<br>      attr:<br>        class: &quot;page__hero-image&quot;<br>        itemprop: &quot;image&quot;<br>      ppi: [1]<br>      source_1600:<br>        media: &quot;(min-width: 1600px)&quot;<br>        width: &quot;1600&quot;<br>      source_1024:<br>        media: &quot;(min-width: 1024px)&quot;<br>        width: &quot;1024&quot;<br>      source_768:<br>        media: &quot;(min-width: 768px)&quot;<br>        width: &quot;768&quot;<br>      source_600:<br>        media: &quot;(min-width: 600px)&quot;<br>        width: &quot;600&quot;<br>      source_default:<br>        width: &quot;320&quot;</pre><p>Now when a high resolution image is placed in /images/_originals/ and feature: image.jpg added to the YAML Front Matter of a page, this markup spits out automatically:</p><pre>&lt;picture&gt;<br>  &lt;source srcset=&quot;image-1600.jpg&quot; media=&quot;(min-width: 1600px)&quot;&gt;<br>  &lt;source srcset=&quot;image-1024.jpg&quot; media=&quot;(min-width: 1024px)&quot;&gt;<br>  &lt;source srcset=&quot;image-768.jpg&quot; media=&quot;(min-width: 768px)&quot;&gt;<br>  &lt;source srcset=&quot;image-600.jpg&quot; media=&quot;(min-width: 600px)&quot;&gt;<br>  &lt;source srcset=&quot;image-320.jpg&quot;&gt;<br>  &lt;img src=&quot;image-320.jpg&quot; class=&quot;page__hero-image&quot; itemprop=&quot;image&quot; alt=&quot;&quot;&gt;<br>&lt;/picture&gt;</pre><p>By default, the plugin hashes the filenames, but <a href="https://github.com/mmistakes/made-mistakes-jekyll/commit/39fcf74b99d5fd6988eaff332ce90208c57ed840">I disabled that</a> since it was getting hard to manage between Mac OS X and Windows environments (each created their own hashed version of the file even when visually the same).</p><p>Currently, this plugin only supports the &lt;picture&gt; element which is great for art directed responsive images, but a bit overkill in this case. Having the option to use srcset instead would be preferred, but since I’m not a Rubyist making that change to the plugin is out of my hands until <a href="https://github.com/robwierzbowski/jekyll-picture-tag/issues/68">someone else tackles it</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*fOFj8aGDF7CGcwst.jpg" /></figure><p>The one big drawback I’ve experienced using this plugin has been an increase in build times. If I don’t instruct Jekyll to keep_files: [“images”], every time I run Jekyll over 1,000 images will go through the process of being resized into smaller files. This takes forever and even longer when uploading them all to my web server (another reason I disabled MD5 hashed filenames). Baby steps right?</p><h3>A Focus on Content</h3><p>Showcasing a post or page’s content is still the primary goal of the layouts I designed years ago. It’s been a balancing act as I’ve tried to incorporate navigation systems (<em>main menu</em>, <em>table of contents</em>, <em>page breadcrumbs</em>, <em>tag archives</em>), reader submitted comments, related posts, and social sharing links in complimenting and responsive ways.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/0*T4pKgS-u4tk_7QSK.jpg" /><figcaption>Post layout then</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/0*5kj1eCe3sKrUH_d5.jpg" /><figcaption>Post layout now</figcaption></figure><p>The core elements have remained unchanged since I originally launched the site:</p><ol><li>A neutral design to avoid competing with page content (text and image).</li><li>Well defined structure, way points for navigating the site, and related content to encourage deeper browsing.</li><li>Readable typography to help showcase long-form articles and tutorials.</li></ol><p>Building everything from scratch has really given me the chance to focus on all of these points. It’s also helped me avoid the trap of adding useless widgets and <em>other cruft</em> because they’re trivial to install — something I was guilty of when using plug and play software like <a href="https://wordpress.org/"><strong>Wordpress</strong></a>.</p><p>The challenge has been finding ways to surface related content and displaying them in an attractive manner. I wanted to take a simple text list of posts and turn them into something more visual. With the thought that no one was going to sift through a bunch of boring text unless there were images to break up things.</p><h4>Listing Posts</h4><p>Archive page layouts I’ve designed over the years have gone through several incarnations. I went from plain text lists, to thumbnail images, to listings with a short excerpt, to something that combined them all.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/463/0*w4wSO45QT8bkamhb.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/463/0*uwOyNCdSvhG8aQ1Q.png" /></figure><p>What I’m currently using are tiles for related and featured post modules and a more traditional plain list for archive pages.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/804/0*3h4bE9AJwGOrM4Rn.jpg" /></figure><p>Related posts are dynamically pulled from site.related_posts and augmented with a <a href="https://github.com/toshimaru/jekyll-tagging-related_posts">Jekyll plugin</a> to make matches based on post.tags. The following tile logic resides in an include file and is ready to be used in layouts or within post/page content.</p><pre>&lt;!-- /_includes/related.html --&gt;<br>&lt;h3 class=&quot;tile__header&quot;&gt;You May Also Enjoy&lt;/h3&gt;<br>&lt;div class=&quot;tiles&quot;&gt;<br>  {% for post in site.related_posts limit:3 %}<br>    &lt;article class=&quot;tile__item&quot; itemscope itemtype=&quot;http://schema.org/CreativeWork&quot;&gt;<br>      &lt;meta itemprop=&quot;text&quot; content=&quot;{{ post.excerpt | strip_html }}&quot;&gt;<br>      &lt;a href=&quot;{{ post.url }}&quot;&gt;<br>        &lt;img src=&quot;{% if post.image.teaser %}{{ post.image.teaser }}{% else %}{{ site.teaser }}{% endif %}&quot; itemprop=&quot;image&quot; alt=&quot;{{ post.title }}&quot;&gt;<br>        &lt;h3 class=&quot;tile__title&quot; itemprop=&quot;headline&quot;&gt;{{ post.title | markdownify | remove: &#39;&lt;p&gt;&#39; | remove: &#39;&lt;/p&gt;&#39; }}&lt;/h3&gt;<br>      &lt;/a&gt;<br>      {% if post.categories %}<br>        {% assign category_slug = post.categories | first %}<br>        {% assign category = site.data.slugs[category_slug] %}<br>        &lt;a href=&quot;/{{ post.categories | first }}/&quot; class=&quot;tile__category&quot;&gt;{{ category.name }}&lt;/a&gt;<br>      {% endif %}<br>    &lt;/article&gt;<br>  {% endfor %}<br>&lt;/div&gt;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/900/0*-zoYERHPEyJcaoth.jpg" /></figure><p>Similar in design to the <strong>related posts</strong> module, I also utilize a set of tiles for featuring posts. Visually they look the same but instead of being dynamically determined by post.tags they’re manually set and grouped by category.</p><p>Adding Featured Posts</p><p>The first step is to flag a post as featured. To do this, I add featured: true to its YAML Front Matter.</p><p>Next I use a variation of the <a href="https://github.com/mmistakes/made-mistakes-jekyll/blob/master/_includes/related.html">related posts include</a> with additional Liquid conditionals to control headlines and other variable data.</p><pre>&lt;!-- /_includes/featured.html --&gt;<br>&lt;h3 class=&quot;tile__header&quot;&gt;{% if page.feature.headline %}{{ page.feature.headline }}{% else %}Featured Posts{% endif %}&lt;/h3&gt;<br>  &lt;div class=&quot;tiles&quot;&gt;<br>    {% assign features = site.categories[page.feature.category] | where:&quot;featured&quot;, true %}<br>    {% for post in features limit:3 %}<br>      &lt;article class=&quot;tile__item&quot; itemscope itemtype=&quot;http://schema.org/CreativeWork&quot;&gt;<br>        &lt;meta itemprop=&quot;text&quot; content=&quot;{{ post.excerpt | strip_html }}&quot;&gt;<br>        &lt;a href=&quot;{{ post.url }}&quot;&gt;<br>          &lt;img src=&quot;{% if post.image.teaser %}{{ post.image.teaser }}{% else %}{{ site.teaser }}{% endif %}&quot; itemprop=&quot;image&quot; alt=&quot;{{ post.title }}&quot;&gt;<br>          &lt;h3 class=&quot;tile__title&quot; itemprop=&quot;headline&quot;&gt;{{ post.title | markdownify | remove: &#39;&lt;p&gt;&#39; | remove: &#39;&lt;/p&gt;&#39; }}&lt;/h3&gt;<br>          {% assign readtime = post.content | strip_html | number_of_words | divided_by:site.words_per_minute %}<br>          &lt;span class=&quot;tile__item-time&quot;&gt;{% if readtime &lt;= 1 %}1{% else %}{{ readtime }}{% endif %} min read&lt;/span&gt;<br>        &lt;/a&gt;<br>        {% if post.work %}<br>          &lt;span class=&quot;tile__category&quot;&gt;{{ post.work }}&lt;/span&gt;<br>        {% endif %}<br>      &lt;/article&gt;<br>    {% endfor %}<br>  &lt;/div&gt;</pre><p>To display on a page, the following YAML Front Matter is added — customizing the headline and assigning a site.categories category to pull from.</p><pre>feature:<br>  visible: true<br>  headline: &quot;Featured Tutorials&quot;<br>  category: mastering-paper</pre><p>Everything is pulled together by adding this to relevant layouts:</p><pre>{% if page.feature.visible == true %}<br>  {% include featured.html %}<br>{% endif %}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/900/0*9agqetU727PhiFzM.jpg" /></figure><h3>Introducing Flexibility</h3><p>My configuration files used to be a dumping ground for all kinds of site, navigation, and author data. This always felt messy to me and when support for data files was added I took advantage of it in my Jekyll themes first.</p><h3>Data Files</h3><p>So what exactly are <a href="http://jekyllrb.com/docs/datafiles/">data files</a>? I like to think of them as custom variables that Liquid can play with in all the ways you’d expect — for loops, captures, filters, you name it. Data files can be YAML, JSON, or CSV, are placed in /_data/, and are accessible with site.data.&lt;filename&gt;.</p><p>Before discovering data files I was hard-coding nav links directly into my layouts and junking up _config.yml with them. It was with my first set of Jekyll themes that I began to see the benefit of pulling this data out into their own little world.</p><p>In an effort to build a DRY navigation menu for this site I created <a href="https://github.com/mmistakes/made-mistakes-jekyll/blob/master/_data/navigation.yml">/_data/navigation.yml</a> and added the following four links:</p><pre># Masthead navigation links<br><br>masthead:<br>  - title: &quot;About&quot;<br>    url: /about/<br>  - title: &quot;Work&quot;<br>    url: /work/<br>  - title: &quot;Blog&quot;<br>    url: /articles/<br>  - title: &quot;Mastering Paper&quot;<br>    url: /mastering-paper/</pre><p>As you can guess, title corresponds to the page title and url… well the URL. With these values, I can loop over the home-primary key and auto-generate list elements with the appropriate titles and links from a single file.</p><pre>&lt;!-- excerpt from /_includes/masthead.html --&gt;<br>&lt;header class=&quot;masthead&quot;&gt;<br>  &lt;div class=&quot;container&quot;&gt;<br>    &lt;a class=&quot;masthead__title&quot; href=&quot;https://mademistakes.com/&quot;&gt;Made Mistakes&lt;/a&gt;<br>    &lt;nav id=&quot;nav-primary&quot; class=&quot;masthead__menu-wrapper&quot;&gt;<br>      &lt;ul class=&quot;masthead__menu&quot;&gt;<br>        &lt;li&gt;&lt;a href=&quot;https://mademistakes.com&quot; class=&quot;masthead__menu-item&quot;&gt;← Home&lt;/a&gt;&lt;/li&gt;<br>        {% for link in site.data.navigation.masthead %}<br>          &lt;li&gt;&lt;a href=&quot;{{ site.url }}{{ link.url }}&quot; class=&quot;masthead__menu-item&quot;&gt;{{ link.title }}&lt;/a&gt;&lt;/li&gt;<br>        {% endfor %}<br>        &lt;li&gt;&lt;a href=&quot;#0&quot; class=&quot;overlay__menu-trigger masthead__menu-item&quot; aria-label=&quot;Navigation Menu&quot; title=&quot;Navigation Menu&quot;&gt;•&amp;nbsp;•&amp;nbsp;•&lt;/a&gt;&lt;/li&gt;<br>      &lt;/ul&gt;<br>    &lt;/nav&gt;<br>  &lt;/div&gt;<br>&lt;/header&gt;</pre><p>What’s going on here is I’m looping through site.data.navigation.masthead to pull out a title and url variable for each. If I ever need to update the masthead navigation I just edit navigation.yml and the rest is handled automatically at build.</p><p>To improve the navigation’s UI, .active classes are added using the following Liquid:</p><pre>{% for link in site.data.navigation.masthead %}<br>&lt;ul class=&quot;masthead__menu&quot;&gt;<br>  {% assign class = nil %}<br>  {% if page.url contains link.url %}<br>    {% assign class = &#39;is--active&#39; %}<br>  {% endif %}<br>  &lt;li&gt;&lt;a href=&quot;{{ site.url }}{{ link.url }}&quot; class=&quot;masthead__menu-item {{ class }}&quot;&gt;{{ link.title }}&lt;/a&gt;&lt;/li&gt;<br>&lt;/ul&gt;<br>{% endfor %}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/900/0*HWwr4h7pwhJ2sqVp.jpg" /></figure><p>I’ve also used a similar technique to build drop-down navigations with nested lists. An example of one of those is as follows.</p><pre># example /_data/navigation.yml<br><br>- title: &quot;About&quot;<br>  href: &quot;/about/&quot;<br>  children:<br>    - childtitle: &quot;Biography&quot;<br>      childhref: &quot;/about/bio/&quot;<br>    - childtitle: &quot;Resume&quot;<br>      childhref: &quot;/about/resume/&quot;<br><br>- title: &quot;Portfolio&quot;<br>  href: &quot;/portfolio/&quot;<br>  children:<br>    - childtitle: &quot;Design&quot;<br>      childhref: &quot;/portfolio/design/&quot;<br>    - childtitle: &quot;Illustration&quot;<br>      childhref: &quot;/portfolio/illustration/&quot;<br>    - childtitle: &quot;Development&quot;<br>      childhref: &quot;/portfolio/development/&quot;</pre><p><strong>Drop-Down Navigation HTML and Liquid</strong></p><pre>&lt;ul&gt;<br>  {% for nav in site.data.navigation %}<br>    {% if nav.children != null %}<br>      &lt;li&gt;&lt;a href=&quot;{{ nav.href }}&quot;&gt;{{ nav.title }}&lt;/a&gt;<br>        &lt;ul class=&quot;child&quot;&gt;<br>        {% for child in nav.children %}<br>          &lt;li&gt;&lt;a href=&quot;{{ child.childhref }}&quot;&gt;{{ child.childtitle }}&lt;/a&gt;&lt;/li&gt;<br>        {% endfor %}<br>        &lt;/ul&gt;<br>        {% else %}<br>      &lt;li&gt;&lt;a href=&quot;{{ nav.href }}&quot;&gt;{{ nav.title }}&lt;/a&gt;{% endif %}&lt;/li&gt;<br>  {% endfor %}<br>&lt;/ul&gt;</pre><p><strong>Which will produce the following HTML:</strong></p><pre>&lt;ul&gt;<br>  &lt;li&gt;&lt;a href=&quot;/about/&quot;&gt;About&lt;/a&gt;<br>    &lt;ul class=&quot;child&quot;&gt;<br>      &lt;li&gt;&lt;a href=&quot;/about/bio/&quot;&gt;Biography&lt;/a&gt;&lt;/li&gt;<br>      &lt;li&gt;&lt;a href=&quot;/about/resume/&quot;&gt;Resume&lt;/a&gt;&lt;/li&gt;<br>    &lt;/ul&gt;<br>  &lt;/li&gt;<br>  &lt;li&gt;&lt;a href=&quot;/portfolio/&quot;&gt;Portfolio&lt;/a&gt;<br>    &lt;ul class=&quot;child&quot;&gt;<br>      &lt;li&gt;&lt;a href=&quot;/portfolio/design/&quot;&gt;Design&lt;/a&gt;&lt;/li&gt;<br>      &lt;li&gt;&lt;a href=&quot;/portfolio/illustration/&quot;&gt;Illustration&lt;/a&gt;&lt;/li&gt;<br>      &lt;li&gt;&lt;a href=&quot;/portfolio/development/&quot;&gt;Development&lt;/a&gt;&lt;/li&gt;<br>    &lt;/ul&gt;<br>  &lt;/li&gt;<br>&lt;/ul&gt;</pre><p><a href="https://mademistakes.com/"><strong>Made Mistakes</strong></a> has always had a singular voice, so supporting multiple authors wasn’t really on my radar. But for some of <a href="https://mademistakes.com/work/jekyll-themes/">my Jekyll themes</a> the need arose and I added support for assigning authors with a data file.</p><p>To achieve this. a YAML file in created in the _data directory with all of the authors.</p><pre># /_data/authors.yml<br><br>billy_rick:<br>  name: Billy Rick<br>  web: http://<br>  email: billy@rick.com<br>  bio: &quot;I am a very extravagant man.&quot;<br>  avatar: billy-rick-photo.jpg<br><br>cornelius_fiddlebone:<br>  name: Cornelius Fiddlebone<br>  email: cornelius@fiddlebone.com<br>  bio: &quot;Jewel miner.&quot;<br>  avatar: cornelius-fiddlebone-photo.jpg</pre><p>Then, to override the author on any given post or page, author: is added to its YAML Front Matter with a key that matches one in authors.yml. For example to assign <strong>Billy Rick</strong> as the author of a post I’d add author: billy_rick.</p><p>With a small layout addition, Liquid is used to assign Billy Rick’s info, replacing the default values. In cases where an author isn’t set {{ site.owner }} values in _config.yml are used instead.</p><pre>{% if page.author %}<br>  {% assign author = site.data.authors[page.author] %}{% else %}{% assign author = site.owner %}<br>{% endif %}<br>{% if author.avatar contains &#39;http&#39; %}<br>  &lt;img src=&quot;{{ author.avatar }}&quot; class=&quot;bio-photo&quot; alt=&quot;{{ author.name }} bio photo&quot;&gt;&lt;/a&gt;<br>{% elsif author.avatar %}<br>  &lt;img src=&quot;{{ site.url }}/images/{{ author.avatar }}&quot; alt=&quot;{{ author.name }} bio photo&quot;&gt;&lt;/a&gt;<br>{% endif %}<br>&lt;h3 class=&quot;author-name&quot;&gt;{{ author.name }}&lt;/h3&gt;<br>{% if author.bio %}&lt;p class=&quot;author-bio&quot;&gt;{{ author.bio }}&lt;/p&gt;{% endif %}</pre><h4>Slug Names</h4><p>This next one is probably overkill and inefficient in most scenarios, but for me, it has a use. The hacky way I’m going about creating breadcrumb navigations imposes some limitations on the crumb titles.</p><p>With Liquid I’m taking a page.url and then grabbing the first bit of text before /. Since I’m fairly consistent in how I organize posts (using categories as part of my permalink format) this works reliably. The problem I run into is some of these “slug” names aren’t all that descriptive or properly title cased.</p><p>By using a slugs.yml data file as a definition list I can replace these “simple slugs” with whatever I want.</p><p>Let’s use the “<a href="https://mademistakes.com/faqs/website-tools/">What tools do you use to build your website?</a>” FAQ page from my site as an example. If I were to output breadcrumbs for this page, I’d filter the page.url of <a href="https://mademistakes.com/faqs/website-tools/">https://mademistakes.com/faqs/website-tools/</a> down to faqs and end up with the following breadcrumbs: <strong>Home &gt; faqs</strong></p><p>Which isn’t the worst thing in the world, but ideally <strong>faqs</strong> would be properly capitalized (eg. FAQs) or spelled out as “<strong>Frequently Asked Questions</strong>.”</p><p>To fix this, I add a faqs slug to slugs.yml and assign it a nice descriptive name to use as the title — like “Frequently Asked Questions.”</p><pre>faqs:<br>  name: &quot;Frequently Asked Questions&quot;</pre><p>The <a href="https://github.com/mmistakes/made-mistakes-jekyll/blob/master/_includes/breadcrumbs.html">breadcrumbs.html</a> include is then modified to output a slug.name instead.</p><pre>{% assign page_slug = page.url | remove_first: &#39;/&#39; | split: &#39;/&#39; %}<br>{% assign slug_first = page_slug[0] %}<br>{% assign slug = site.data.slugs[slug_first] %}<br><br>&lt;nav class=&quot;breadcrumbs&quot;&gt;<br>  &lt;span itemscope itemtype=&quot;http://data-vocabulary.org/Breadcrumb&quot;&gt;<br>    &lt;a href=&quot;{{ site.url }}&quot; class=&quot;breadcrumb__item&quot; itemprop=&quot;url&quot;&gt;<br>      &lt;span itemprop=&quot;title&quot;&gt;Home&lt;/span&gt;<br>    &lt;/a&gt; &lt;span class=&quot;breadcrumb__sep&quot;&gt;×&lt;/span&gt;<br>  &lt;/span&gt;<br>  &lt;span itemscope itemtype=&quot;http://data-vocabulary.org/Breadcrumb&quot;&gt;<br>    &lt;a href=&quot;/{{ page_slug[0] }}/&quot; class=&quot;breadcrumb__item&quot; itemprop=&quot;url&quot;&gt;<br>      &lt;span itemprop=&quot;title&quot;&gt;{{ slug.name }}&lt;/span&gt;<br>    &lt;/a&gt;<br>  &lt;/span&gt;<br>&lt;/nav&gt;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/900/0*pgcxiOSa1yLZJULK.jpg" /></figure><h4>Translation Keys</h4><p>Localizing my themes is an idea I’ve only started to flirt with. The thought of using <a href="https://tuananh.org/2014/08/13/localization-with-jekyll/">data files as translation keys</a> for localizing text was brought to my attention through a <a href="https://github.com/mmistakes/skinny-bones-jekyll/commit/b08024fcd4815e61eb3c9a0c60c0bc793f195db2">pull request</a> by <a href="https://github.com/yonojoy">@yonojoy</a>. This is by no means a full-on i18n solution, but it does help theme developers looking to support multiple languages.</p><p>There’s three pieces to pulling this off.</p><p><strong>1. Languages data file</strong></p><p>In the case of my <a href="https://mmistakes.github.io/skinny-bones-jekyll/"><strong>Skinny Bones</strong></a> starter theme, German and <a href="https://github.com/mmistakes/skinny-bones-jekyll/commit/bd4c02bbf29ffbc0194fa6d871f9fefcb8979ed5">French</a> translations have been added via hashes in a YAML file (eg. /_data/languages.yml).</p><pre>locales:<br>  # English ---------------------------------------------<br>  en: &amp;DEFAULT_EN<br>    overview: &quot;Overview&quot;<br>    toc: &quot;Table of Contents&quot;<br>    written_by: &quot;Written by&quot;<br>    updated: &quot;Updated&quot;<br>    share: &quot;Share on&quot;<br>  en_US:<br>    &lt;&lt;: *DEFAULT_EN     # use en for en_US<br>  en_UK:<br>    &lt;&lt;: *DEFAULT_EN     # use en for en_UK<br><br>  # German translations ---------------------------------<br>  de: &amp;DEFAULT_DE<br>    &lt;&lt;: *DEFAULT_EN     # load English values as default<br>    overview: &quot;&amp;Uuml;bersicht&quot;<br>    toc: &quot;Inhalt&quot;<br>    written_by: &quot;Verfasst von&quot;<br>    updated: &quot;Zuletzt aktualisiert:&quot;<br>    share: &quot;&quot;<br>  de_DE:<br>    &lt;&lt;: *DEFAULT_DE     # use de translation for de_DE<br><br>  # French translations ---------------------------------<br>  fr: &amp;DEFAULT_FR<br>    &lt;&lt;: *DEFAULT_EN     # load English values as default<br>    overview: &quot;Aperçu&quot;<br>    toc: &quot;Table des matières&quot;<br>    written_by: &quot;Écrit par&quot;<br>    updated: &quot;Mis à jour&quot;<br>    share: &quot;Partager sur&quot;<br>  fr_FR:<br>    &lt;&lt;: *DEFAULT_FR     # use fr translation for fr_FR</pre><p><strong>2. Set locale in Jekyll config</strong></p><p>To change the default language, a locale variable is set in _config.yml. For example to switch from English to French you’d add locale: fr_FR or locale: fr.</p><p><strong>3. Call in the correct language hashes</strong></p><p>The last step is using long variables like {{site.data.languages.locales[site.locale].updated}} into the appropriate places — replacing any text you want to localize. If done correctly, this variable should output with the French updated string, Mis à jour.</p><p>If you want to learn more about this technique be sure to check out Tuan Anh’s <a href="https://tuananh.org/2014/08/13/localization-with-jekyll/">blog post</a>. Or if you’re looking for a plugin to do the heavy lifting, <a href="https://github.com/screeninteraction/jekyll-multiple-languages-plugin">Jekyll-Multiple-Languages</a> might be a good place to start.</p><h3>Fin</h3><p>Maybe not 100% complete, but this is certainly the majority of techniques I’ve picked up using Jekyll over the years. What keeps me coming back is its flexibility — there’s no shortage of ways to approach a problem and always new things to learn. Browse the threads on <a href="https://talk.jekyllrb.com/">Jekyll Talk</a> on any given day and you’ll see what I mean .</p><h4><em>Originally published at </em><a href="https://mademistakes.com/articles/using-jekyll-2016/"><em>mademistakes.com</em></a><em>.</em></h4><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=750e1e4a8cf9" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>