forked from omsf/omsf.github.io
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.xml
1 lines (1 loc) · 107 KB
/
index.xml
1
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>OMSF</title><link>https://omsf.io/</link><description>Recent content on OMSF</description><generator>Hugo -- gohugo.io</generator><language>en-us</language><lastBuildDate>Thu, 17 Nov 2022 13:17:20 +0200</lastBuildDate><atom:link href="https://omsf.io/index.xml" rel="self" type="application/rss+xml"/><item><title>Feature Image</title><link>https://omsf.io/post/feature-image/</link><pubDate>Wed, 01 Jan 2020 00:00:00 +0000</pubDate><guid>https://omsf.io/post/feature-image/</guid><description><p>The Hugo Kiera theme now supports featured images. To use the feature, set the <code>images</code> parameter in a page&rsquo;s frontmatter.</p><p>(Note that this is required to be an array, even though only the first image is used. This is to provide compatability with the built-in <a href="https://gohugo.io/templates/internal/#twitter-cards">Twitter Card</a> shortcode.)</p></description></item><item><title>Markdown Syntax Guide</title><link>https://omsf.io/post/markdown-syntax/</link><pubDate>Mon, 11 Mar 2019 00:00:00 +0000</pubDate><guid>https://omsf.io/post/markdown-syntax/</guid><description><p>This article offers a sample of basic Markdown syntax that can be used in Hugo content files, also it shows whether basic HTML elements are decorated with CSS in a Hugo theme.</p><h2 id="headings">Headings</h2><p>The following HTML <code>&lt;h1&gt;</code>—<code>&lt;h6&gt;</code> elements represent six levels of section headings. <code>&lt;h1&gt;</code> is the highest section level while <code>&lt;h6&gt;</code> is the lowest.</p><h1 id="h1">H1</h1><h2 id="h2">H2</h2><h3 id="h3">H3</h3><h4 id="h4">H4</h4><h5 id="h5">H5</h5><h6 id="h6">H6</h6><h2 id="paragraph">Paragraph</h2><p>Xerum, quo qui aut unt expliquam qui dolut labo. Aque venitatiusda cum, voluptionse latur sitiae dolessi aut parist aut dollo enim qui voluptate ma dolestendit peritin re plis aut quas inctum laceat est volestemque commosa as cus endigna tectur, offic to cor sequas etum rerum idem sintibus eiur? Quianimin porecus evelectur, cum que nis nust voloribus ratem aut omnimi, sitatur? Quiatem. Nam, omnis sum am facea corem alique molestrunt et eos evelece arcillit ut aut eos eos nus, sin conecerem erum fuga. Ri oditatquam, ad quibus unda veliamenimin cusam et facea ipsamus es exerum sitate dolores editium rerore eost, temped molorro ratiae volorro te reribus dolorer sperchicium faceata tiustia prat.</p><p>Itatur? Quiatae cullecum rem ent aut odis in re eossequodi nonsequ idebis ne sapicia is sinveli squiatum, core et que aut hariosam ex eat.</p><h2 id="blockquotes">Blockquotes</h2><p>The blockquote element represents content that is quoted from another source, optionally with a citation which must be within a <code>footer</code> or <code>cite</code> element, and optionally with in-line changes such as annotations and abbreviations.</p><h4 id="blockquote-without-attribution">Blockquote without attribution</h4><blockquote><p>Tiam, ad mint andaepu dandae nostion secatur sequo quae.<strong>Note</strong> that you can use <em>Markdown syntax</em> within a blockquote.</p></blockquote><h4 id="blockquote-with-attribution">Blockquote with attribution</h4><blockquote><p>Don&rsquo;t communicate by sharing memory, share memory by communicating.<!-- raw HTML omitted -->— <!-- raw HTML omitted -->Rob Pike<sup id="fnref:1"><a href="#fn:1" class="footnote-ref" role="doc-noteref">1</a></sup><!-- raw HTML omitted --></p></blockquote><h2 id="tables">Tables</h2><p>Tables aren&rsquo;t part of the core Markdown spec, but Hugo supports supports them out-of-the-box.</p><table><thead><tr><th>Name</th><th>Age</th></tr></thead><tbody><tr><td>Bob</td><td>27</td></tr><tr><td>Alice</td><td>23</td></tr></tbody></table><h4 id="inline-markdown-within-tables">Inline Markdown within tables</h4><table><thead><tr><th>Inline </th><th>Markdown </th><th>In </th><th>Table</th></tr></thead><tbody><tr><td><em>italics</em></td><td><strong>bold</strong></td><td><del>strikethrough</del> </td><td><code>code</code></td></tr></tbody></table><h2 id="code-blocks">Code Blocks</h2><h4 id="code-block-with-backticks">Code block with backticks</h4><pre><code>html&lt;!DOCTYPE html&gt;&lt;html lang=&quot;en&quot;&gt;&lt;head&gt; &lt;meta charset=&quot;UTF-8&quot;&gt; &lt;title&gt;Example HTML5 Document&lt;/title&gt;&lt;/head&gt;&lt;body&gt; &lt;p&gt;Test&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</code></pre><h4 id="code-block-indented-with-four-spaces">Code block indented with four spaces</h4><pre><code>&lt;!DOCTYPE html&gt;&lt;html lang=&quot;en&quot;&gt;&lt;head&gt; &lt;meta charset=&quot;UTF-8&quot;&gt; &lt;title&gt;Example HTML5 Document&lt;/title&gt;&lt;/head&gt;&lt;body&gt; &lt;p&gt;Test&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</code></pre><h4 id="code-block-with-hugos-internal-highlight-shortcode">Code block with Hugo&rsquo;s internal highlight shortcode</h4><div class="highlight"><pre style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-html" data-lang="html"><span style="color:#75715e">&lt;!DOCTYPE html&gt;</span>&lt;<span style="color:#f92672">html</span> <span style="color:#a6e22e">lang</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;en&#34;</span>&gt;&lt;<span style="color:#f92672">head</span>&gt; &lt;<span style="color:#f92672">meta</span> <span style="color:#a6e22e">charset</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;UTF-8&#34;</span>&gt; &lt;<span style="color:#f92672">title</span>&gt;Example HTML5 Document&lt;/<span style="color:#f92672">title</span>&gt;&lt;/<span style="color:#f92672">head</span>&gt;&lt;<span style="color:#f92672">body</span>&gt; &lt;<span style="color:#f92672">p</span>&gt;Test&lt;/<span style="color:#f92672">p</span>&gt;&lt;/<span style="color:#f92672">body</span>&gt;&lt;/<span style="color:#f92672">html</span>&gt;</code></pre></div><h2 id="list-types">List Types</h2><h4 id="ordered-list">Ordered List</h4><ol><li>First item</li><li>Second item</li><li>Third item</li></ol><h4 id="unordered-list">Unordered List</h4><ul><li>List item</li><li>Another item</li><li>And another item</li></ul><h4 id="nested-list">Nested list</h4><ul><li>Item</li></ul><ol><li>First Sub-item</li><li>Second Sub-item</li></ol><h2 id="other-elements--abbr-sub-sup-kbd-mark">Other Elements — abbr, sub, sup, kbd, mark</h2><p><!-- raw HTML omitted -->GIF<!-- raw HTML omitted --> is a bitmap image format.</p><p>H<!-- raw HTML omitted -->2<!-- raw HTML omitted -->O</p><p>X<!-- raw HTML omitted -->n<!-- raw HTML omitted --> + Y<!-- raw HTML omitted -->n<!-- raw HTML omitted --> = Z<!-- raw HTML omitted -->n<!-- raw HTML omitted --></p><p>Press <!-- raw HTML omitted --><!-- raw HTML omitted -->CTRL<!-- raw HTML omitted -->+<!-- raw HTML omitted -->ALT<!-- raw HTML omitted -->+<!-- raw HTML omitted -->Delete<!-- raw HTML omitted --><!-- raw HTML omitted --> to end the session.</p><p>Most <!-- raw HTML omitted -->salamanders<!-- raw HTML omitted --> are nocturnal, and hunt for insects, worms, and other small creatures.</p><section class="footnotes" role="doc-endnotes"><hr><ol><li id="fn:1" role="doc-endnote"><p>The above quote is excerpted from Rob Pike&rsquo;s <a href="https://www.youtube.com/watch?v=PAAkCSZUG1c">talk</a> during Gopherfest, November 18, 2015.&#160;<a href="#fnref:1" class="footnote-backref" role="doc-backlink">&#x21a9;&#xfe0e;</a></p></li></ol></section></description></item><item><title>Style Guide</title><link>https://omsf.io/post/style-guide/</link><pubDate>Tue, 14 Nov 2017 10:57:55 -0500</pubDate><guid>https://omsf.io/post/style-guide/</guid><description><h1 id="headings">Headings</h1><h1 id="heading-1">Heading 1</h1><h2 id="heading-2">Heading 2</h2><h3 id="heading-3">Heading 3</h3><h4 id="heading-4">Heading 4</h4><h5 id="heading-5">Heading 5</h5><h6 id="heading-6">Heading 6</h6><hr><h1 id="headings-with-text">Headings with Text</h1><h1 id="heading-1-1">Heading 1</h1><p>Lorem ipsum dolor sit amet, adipiscing elit. Nullam dignissim convallis est. Quisque aliquam. Donec faucibus. Nunc iaculis suscipit dui. Nam sit amet sem. Aliquam libero nisi, imperdiet at, tincidunt nec, gravida vehicula, nisl.</p><h2 id="heading-2-1">Heading 2</h2><p>Lorem ipsum dolor sit amet, adipiscing elit. Nullam dignissim convallis est. Quisque aliquam. Donec faucibus. Nunc iaculis suscipit dui. Nam sit amet sem. Aliquam libero nisi, imperdiet at, tincidunt nec, gravida vehicula, nisl.</p><h3 id="heading-3-1">Heading 3</h3><p>Lorem ipsum dolor sit amet, adipiscing elit. Nullam dignissim convallis est. Quisque aliquam. Donec faucibus. Nunc iaculis suscipit dui. Nam sit amet sem. Aliquam libero nisi, imperdiet at, tincidunt nec, gravida vehicula, nisl.</p><h4 id="heading-4-1">Heading 4</h4><p>Lorem ipsum dolor sit amet, adipiscing elit. Nullam dignissim convallis est. Quisque aliquam. Donec faucibus. Nunc iaculis suscipit dui. Nam sit amet sem. Aliquam libero nisi, imperdiet at, tincidunt nec, gravida vehicula, nisl.</p><h5 id="heading-5-1">Heading 5</h5><p>Lorem ipsum dolor sit amet, adipiscing elit. Nullam dignissim convallis est. Quisque aliquam. Donec faucibus. Nunc iaculis suscipit dui. Nam sit amet sem. Aliquam libero nisi, imperdiet at, tincidunt nec, gravida vehicula, nisl.</p><h6 id="heading-6-1">Heading 6</h6><p>Lorem ipsum dolor sit amet, adipiscing elit. Nullam dignissim convallis est. Quisque aliquam. Donec faucibus. Nunc iaculis suscipit dui. Nam sit amet sem. Aliquam libero nisi, imperdiet at, tincidunt nec, gravida vehicula, nisl.</p><hr><h1 id="block-elements">Block Elements</h1><h2 id="paragraphs-and-images">Paragraphs and Images</h2><p>Moinsen! Der kess 🦄 Lichtspieltheater. Kittchen und Schwedenfilm krakelen blümerant Narr. Das flügge Personenvereinzelungsanlage dengeln. Kleintierzuchtverein und Naschkatze meucheln adrett Himmelfahrtskommando. Der gebeutelt Personenvereinzelungsanlage. Der butterweich Scharlatan. Der gemach Kokolores. Haderlump und Waldschrat abkupfern hanebüchen Lump. Der hochgestochen Stümper. Das Trinkhalle abkupfern der bierernst Eisbein. Die Lametta stibitzen der töricht Prahlhans. Die altbacken Himmelfahrtskommando. Kerbholz und Schürzenjäger erquicken garstig Schlachtschüssel. Jungfer und Herrengedeck auftakeln pompös Schnitzel. Ach du liebes Lottchen!</p><p>Aliquam libero nisi, imperdiet at, tincidunt nec, gravida vehicula, nisl. Praesent mattis, massa quis luctus fermentum, turpis mi volutpat justo, eu volutpat enim diam eget metus. Maecenas ornare tortor.</p><p><img src="https://placehold.it/350x150" alt="Placeholder Image and Some Alt Text" title="A title element for this placeholder image."></p><p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Nullam dignissim convallis est. Quisque aliquam. Donec faucibus. Nunc iaculis suscipit dui. Nam sit amet sem.</p><h2 id="blockquote">Blockquote</h2><p>This is a standard paragraph. Lorem ipsum dolor sit amet, consectetuer adipiscing elit.</p><blockquote><p>&ldquo;<strong>This is a blockquote</strong>. Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Nullam dignissim convallis est. Quisque aliquam. Donec faucibus. Nunc iaculis suscipit dui. Nam sit amet sem. Aliquam libero nisi, imperdiet at, tincidunt nec, gravida vehicula, nisl.&rdquo;</p></blockquote><p>This is a standard paragraph. Lorem ipsum dolor sit amet, consectetuer adipiscing elit.</p><p><em>Note: the <a href="http://html5doctor.com/the-figure-figcaption-elements/">Figure-Figcaption</a> and <a href="http://html5doctor.com/the-details-and-summary-elements/">Details-Summary</a> elements are not currently supported in markdown.</em></p><hr><h1 id="text-elements">Text Elements</h1><p>The <a href="#">a element</a> and <a href="https://example.com">external a element</a> examples</p><p>The <!-- raw HTML omitted -->abbr element<!-- raw HTML omitted --> and an <!-- raw HTML omitted -->abbr<!-- raw HTML omitted --> element with title examples</p><p>The <!-- raw HTML omitted -->ACRONYM<!-- raw HTML omitted --> element example</p><p>The <strong>b element</strong> example</p><p>The <!-- raw HTML omitted -->cite element<!-- raw HTML omitted --> example</p><p>The <code>code element</code> example</p><p>The <!-- raw HTML omitted -->data element<!-- raw HTML omitted --> example</p><p>The <del>del element</del> example</p><p>The <!-- raw HTML omitted -->dfn element<!-- raw HTML omitted --> and <!-- raw HTML omitted -->dfn element with title<!-- raw HTML omitted --> examples</p><p>The <em>em element</em> example</p><p>The <em>i element</em> example</p><p>The <!-- raw HTML omitted -->ins element<!-- raw HTML omitted --> example</p><p>The <!-- raw HTML omitted -->kbd element<!-- raw HTML omitted --> example</p><p>The <!-- raw HTML omitted -->mark element<!-- raw HTML omitted --> example</p><p>The <!-- raw HTML omitted -->q element<!-- raw HTML omitted --> example</p><p>The <!-- raw HTML omitted -->q element <!-- raw HTML omitted -->inside<!-- raw HTML omitted --> a q element<!-- raw HTML omitted --> example</p><p>The <!-- raw HTML omitted -->s element<!-- raw HTML omitted --> example</p><p>The <!-- raw HTML omitted -->samp element<!-- raw HTML omitted --> example</p><p>The <!-- raw HTML omitted -->small element<!-- raw HTML omitted --> example</p><p>The <!-- raw HTML omitted -->span element<!-- raw HTML omitted --> example</p><p>The <strong>strong element</strong> example</p><p>The <!-- raw HTML omitted -->sub element<!-- raw HTML omitted --> example</p><p>The <!-- raw HTML omitted -->sup element<!-- raw HTML omitted --> example</p><p>The <!-- raw HTML omitted -->time element<!-- raw HTML omitted --> example</p><p>The <!-- raw HTML omitted -->u element<!-- raw HTML omitted --> example</p><p>The <!-- raw HTML omitted -->var element<!-- raw HTML omitted --> example</p><hr><h1 id="monospace--preformatted">Monospace / Preformatted</h1><p>Code block wrapped in &ldquo;pre&rdquo; and &ldquo;code&rdquo; tags:</p><div class="highlight"><pre style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-javascript" data-lang="javascript"><span style="color:#75715e">// Loop through Divs using Javascript.</span><span style="color:#75715e"></span><span style="color:#66d9ef">var</span> <span style="color:#a6e22e">divs</span> <span style="color:#f92672">=</span> document.<span style="color:#a6e22e">querySelectorAll</span>(<span style="color:#e6db74">&#39;div&#39;</span>), <span style="color:#a6e22e">i</span>;<span style="color:#66d9ef">for</span> (<span style="color:#a6e22e">i</span> <span style="color:#f92672">=</span> <span style="color:#ae81ff">0</span>; <span style="color:#a6e22e">i</span> <span style="color:#f92672">&lt;</span> <span style="color:#a6e22e">divs</span>.<span style="color:#a6e22e">length</span>; <span style="color:#f92672">++</span><span style="color:#a6e22e">i</span>) { <span style="color:#a6e22e">divs</span>[<span style="color:#a6e22e">i</span>].<span style="color:#a6e22e">style</span>.<span style="color:#a6e22e">color</span> <span style="color:#f92672">=</span> <span style="color:#e6db74">&#34;green&#34;</span>;}</code></pre></div><p>Monospace Text wrapped in &ldquo;pre&rdquo; tags:</p><!-- raw HTML omitted --><hr><h1 id="list-types">List Types</h1><h2 id="ordered-list">Ordered List</h2><ol><li>List Item 1</li><li>List Item 2</li><li>List Item 3<ol><li>List Item 3.1</li><li>List Item 3.2<ol><li>List Item 3.2.1</li><li>List Item 3.2 2</li></ol></li><li>List Item 3.3</li></ol></li><li>List Item 4</li></ol><h2 id="unordered-list">Unordered List</h2><ul><li>List Item 1</li><li>List Item 2</li><li>List Item 3<ul><li>List Item 3.1<ul><li>List Item 3.2<ul><li>List Item 3.2.1</li><li>List Item 3.2 2</li></ul></li><li>List Item 3.3</li></ul></li></ul></li><li>List Item 4</li></ul><h2 id="definition-list">Definition List</h2><dl><dt>Definition Term 1</dt><dd>Definition Description 1</dd><dt>Definition Term 2</dt><dd>Definition Description 2</dd></dl><hr><h1 id="tables">Tables</h1><table><thead><tr><th>Table Header 1</th><th>Table Header 2</th><th>Table Header 3</th></tr></thead><tbody><tr><td>Division 1</td><td>Division 2</td><td>Division 3</td></tr><tr><td>Division 1</td><td>Division 2</td><td>Division 3</td></tr><tr><td>Division 1</td><td>Division 2</td><td>Division 3</td></tr></tbody></table><hr><h1 id="media-and-form-elements">Media and Form Elements</h1><p>The remaining sections contain elements that cannot be represented in markdown. Please consult <a href="https://github.com/bryanbraun/poor-mans-styleguide/blob/gh-pages/index.html">the HTML version</a>, to see these elements.</p></description></item><item><title>Image Style Guide</title><link>https://omsf.io/post/image-content/</link><pubDate>Tue, 14 Nov 2017 08:08:17 -0500</pubDate><guid>https://omsf.io/post/image-content/</guid><description><p>Veniam est eu adipisicing reprehenderit do sit sint elit sint. Tempor laborum ut dolore aliqua. Commodo eu qui sint magna veniam laborum. Ad cupidatat do proident ex veniam amet Lorem. Officia laboris aute fugiat id consequat culpa ullamco labore ea amet ad. Occaecat quis dolor commodo pariatur cillum et id id cupidatat officia.</p><p>Magna incididunt proident cupidatat cupidatat enim consectetur sunt. Ipsum velit aliqua ex ipsum qui labore magna. Ea nisi anim ad culpa Lorem occaecat ex cupidatat duis labore officia dolor.</p><figure class="full"><img src="http://via.placeholder.com/600x200" alt="Magna sunt ut ea quis aliqua cupidatat ut quis sit aliqua tempor duis."/><figcaption> <p>Magna sunt ut ea quis aliqua cupidatat ut quis sit aliqua tempor duis.</p> </figcaption></figure><p>Aliqua minim esse velit est non. Ea do irure labore aliquip culpa ex ut sunt anim duis irure. Ex adipisicing deserunt do occaecat. Incididunt esse ea tempor fugiat magna.</p><p>Voluptate elit exercitation aliqua ut elit reprehenderit aliquip anim elit laborum laborum. Elit aute sint nisi labore irure in labore culpa. Fugiat velit fugiat ea reprehenderit. Sint minim amet occaecat eu labore reprehenderit pariatur nulla.</p><figure class="mid"><img src="http://via.placeholder.com/600x300" alt="Eu cupidatat ex qui do."/><figcaption> <p>Eu cupidatat ex qui do.</p> </figcaption></figure><p>In deserunt exercitation Lorem est nulla ullamco enim duis consequat tempor minim. Nostrud cillum ex dolore amet qui mollit do in aliquip consequat eiusmod est dolor officia. Exercitation quis cillum voluptate dolore cillum veniam minim voluptate ullamco voluptate reprehenderit deserunt elit. Et cillum sunt labore ad duis officia aute Lorem incididunt commodo ea.</p><p>Deserunt Lorem aliquip dolor et ut adipisicing nisi esse est dolore irure laborum. Excepteur dolor pariatur excepteur deserunt eiusmod laborum. Ad officia ea magna id ex. Laborum enim proident incididunt quis.</p><p><img src="http://via.placeholder.com/300x400#float-right" alt="floaty mcboaty"></p><p>Elit culpa ad ex aute ullamco dolor anim do labore. Non ex do eiusmod elit occaecat. Adipisicing mollit commodo fugiat qui Lorem cupidatat laboris consectetur. Anim nostrud ullamco excepteur Lorem aliqua ullamco nisi.</p><p>Dolor adipisicing magna cupidatat consequat commodo est deserunt enim amet nulla pariatur mollit. Cupidatat officia veniam adipisicing laboris et ullamco consequat est nisi cupidatat. Quis id cillum excepteur consectetur aute excepteur ipsum magna. In ex pariatur nostrud ipsum aliqua nisi irure Lorem consectetur incididunt incididunt cillum. Fugiat ea Lorem velit voluptate cillum. Sunt incididunt proident nulla ad minim ullamco nostrud non commodo dolor enim cillum ullamco esse.</p><p><img src="http://via.placeholder.com/300x400#float-left" alt="floaty mcboaty"></p><p>Do pariatur culpa labore dolore nostrud velit nostrud labore adipisicing enim laborum eu eu. Laborum nulla occaecat amet commodo ut velit. Incididunt et officia ex voluptate qui velit amet. Commodo consequat pariatur labore irure id commodo fugiat exercitation incididunt fugiat aliqua ipsum. Enim exercitation quis cillum irure duis nisi ullamco pariatur exercitation cillum amet nostrud aliquip. Adipisicing pariatur incididunt tempor sit pariatur aliquip aliqua pariatur. Eu occaecat fugiat aliqua consectetur velit incididunt nostrud enim.</p><p>Consectetur non dolore duis anim nostrud pariatur. Nisi ad pariatur est fugiat non occaecat excepteur ea amet esse. Id ullamco nisi anim ut eu reprehenderit irure ullamco. Do voluptate dolor est nostrud sit.</p><figure class="float-right"><img src="http://via.placeholder.com/300x400" alt="Eu cupidatat ex qui do."/><figcaption> <p>Eu cupidatat ex qui do.</p> </figcaption></figure><p>Irure anim officia nostrud ad veniam reprehenderit incididunt id elit eu id sint ea laboris. Irure esse sit dolore enim nulla consequat esse id esse. Anim consequat reprehenderit incididunt sit. Incididunt incididunt eu ullamco excepteur sit qui id reprehenderit cillum eiusmod velit elit adipisicing. Pariatur et cupidatat quis sint ipsum est non. Anim sit labore ut minim id sint eu incididunt exercitation laborum laborum anim.</p><p>Sit id et irure consectetur veniam do eiusmod. Exercitation veniam labore proident laborum commodo esse culpa laboris ex laboris fugiat. Sunt ut amet tempor eiusmod exercitation laboris in qui tempor mollit culpa mollit. Eu sint consequat consectetur laboris amet dolore do labore ipsum dolor ipsum fugiat. Qui deserunt cillum nostrud dolore tempor reprehenderit reprehenderit reprehenderit.</p><figure class="float"><img src="http://via.placeholder.com/300x400" alt="Eu cupidatat ex qui do."/><figcaption> <p>Eu cupidatat ex qui do.</p> </figcaption></figure><p>Enim anim veniam ea officia. Duis fugiat fugiat exercitation voluptate labore est est aliqua dolor incididunt eiusmod veniam. Reprehenderit sunt aute veniam anim qui sunt irure officia duis non aute labore. Aliqua reprehenderit pariatur reprehenderit voluptate excepteur ut amet sit ut duis. Ea exercitation ex ad ut dolor minim.</p><p>Lorem nostrud aute cillum ut veniam deserunt. Est commodo et id ea. Proident incididunt consequat deserunt sit do est duis. Do sint ullamco sunt cillum duis.</p><p>Officia aliqua occaecat ipsum dolore nostrud aliqua laborum do consequat nostrud. Dolor amet non ad excepteur duis Lorem aliqua aute. Lorem reprehenderit do sit minim magna nostrud Lorem officia duis.</p><p>Ad amet laboris eu qui ipsum eu ut cillum ipsum consectetur mollit nulla aliqua esse. Adipisicing et ad anim ipsum aliqua duis eiusmod. Quis ad in ea eu amet cupidatat sint eiusmod ullamco. Ullamco aliquip Lorem aliqua labore ipsum. Consectetur magna nostrud mollit nulla nostrud duis ipsum. Officia ad nulla culpa exercitation exercitation exercitation duis ipsum laboris.</p></description></item><item><title>Creating a New Theme</title><link>https://omsf.io/post/creating-a-new-theme/</link><pubDate>Sun, 28 Sep 2014 00:00:00 +0000</pubDate><guid>https://omsf.io/post/creating-a-new-theme/</guid><description><h2 id="introduction">Introduction</h2><p>This tutorial will show you how to create a simple theme in Hugo. I assume that you are familiar with HTML, the bash command line, and that you are comfortable using Markdown to format content. I&rsquo;ll explain how Hugo uses templates and how you can organize your templates to create a theme. I won&rsquo;t cover using CSS to style your theme.</p><p>We&rsquo;ll start with creating a new site with a very basic template. Then we&rsquo;ll add in a few pages and posts. With small variations on that, you will be able to create many different types of web sites.</p><p>In this tutorial, commands that you enter will start with the &ldquo;$&rdquo; prompt. The output will follow. Lines that start with &ldquo;#&rdquo; are comments that I&rsquo;ve added to explain a point. When I show updates to a file, the &ldquo;:wq&rdquo; on the last line means to save the file.</p><p>Here&rsquo;s an example:</p><pre><code>## this is a comment$ echo this is a commandthis is a command## edit the file$vi foo.md+++date = &quot;2014-09-28&quot;title = &quot;creating a new theme&quot;+++bah and humbug:wq## show it$ cat foo.md+++date = &quot;2014-09-28&quot;title = &quot;creating a new theme&quot;+++bah and humbug$</code></pre><h2 id="some-definitions">Some Definitions</h2><p>There are a few concepts that you need to understand before creating a theme.</p><h3 id="skins">Skins</h3><p>Skins are the files responsible for the look and feel of your site. It’s the CSS that controls colors and fonts, it’s the Javascript that determines actions and reactions. It’s also the rules that Hugo uses to transform your content into the HTML that the site will serve to visitors.</p><p>You have two ways to create a skin. The simplest way is to create it in the <code>layouts/</code> directory. If you do, then you don’t have to worry about configuring Hugo to recognize it. The first place that Hugo will look for rules and files is in the <code>layouts/</code> directory so it will always find the skin.</p><p>Your second choice is to create it in a sub-directory of the <code>themes/</code> directory. If you do, then you must always tell Hugo where to search for the skin. It’s extra work, though, so why bother with it?</p><p>The difference between creating a skin in <code>layouts/</code> and creating it in <code>themes/</code> is very subtle. A skin in <code>layouts/</code> can’t be customized without updating the templates and static files that it is built from. A skin created in <code>themes/</code>, on the other hand, can be and that makes it easier for other people to use it.</p><p>The rest of this tutorial will call a skin created in the <code>themes/</code> directory a theme.</p><p>Note that you can use this tutorial to create a skin in the <code>layouts/</code> directory if you wish to. The main difference will be that you won’t need to update the site’s configuration file to use a theme.</p><h3 id="the-home-page">The Home Page</h3><p>The home page, or landing page, is the first page that many visitors to a site see. It is the index.html file in the root directory of the web site. Since Hugo writes files to the public/ directory, our home page is public/index.html.</p><h3 id="site-configuration-file">Site Configuration File</h3><p>When Hugo runs, it looks for a configuration file that contains settings that override default values for the entire site. The file can use TOML, YAML, or JSON. I prefer to use TOML for my configuration files. If you prefer to use JSON or YAML, you’ll need to translate my examples. You’ll also need to change the name of the file since Hugo uses the extension to determine how to process it.</p><p>Hugo translates Markdown files into HTML. By default, Hugo expects to find Markdown files in your <code>content/</code> directory and template files in your <code>themes/</code> directory. It will create HTML files in your <code>public/</code> directory. You can change this by specifying alternate locations in the configuration file.</p><h3 id="content">Content</h3><p>Content is stored in text files that contain two sections. The first section is the “front matter,” which is the meta-information on the content. The second section contains Markdown that will be converted to HTML.</p><h4 id="front-matter">Front Matter</h4><p>The front matter is information about the content. Like the configuration file, it can be written in TOML, YAML, or JSON. Unlike the configuration file, Hugo doesn’t use the file’s extension to know the format. It looks for markers to signal the type. TOML is surrounded by “<code>+++</code>”, YAML by “<code>---</code>”, and JSON is enclosed in curly braces. I prefer to use TOML, so you’ll need to translate my examples if you prefer YAML or JSON.</p><p>The information in the front matter is passed into the template before the content is rendered into HTML.</p><h4 id="markdown">Markdown</h4><p>Content is written in Markdown which makes it easier to create the content. Hugo runs the content through a Markdown engine to create the HTML which will be written to the output file.</p><h3 id="template-files">Template Files</h3><p>Hugo uses template files to render content into HTML. Template files are a bridge between the content and presentation. Rules in the template define what content is published, where it&rsquo;s published to, and how it will rendered to the HTML file. The template guides the presentation by specifying the style to use.</p><p>There are three types of templates: single, list, and partial. Each type takes a bit of content as input and transforms it based on the commands in the template.</p><p>Hugo uses its knowledge of the content to find the template file used to render the content. If it can’t find a template that is an exact match for the content, it will shift up a level and search from there. It will continue to do so until it finds a matching template or runs out of templates to try. If it can’t find a template, it will use the default template for the site.</p><p>Please note that you can use the front matter to influence Hugo’s choice of templates.</p><h4 id="single-template">Single Template</h4><p>A single template is used to render a single piece of content. For example, an article or post would be a single piece of content and use a single template.</p><h4 id="list-template">List Template</h4><p>A list template renders a group of related content. That could be a summary of recent postings or all articles in a category. List templates can contain multiple groups.</p><p>The homepage template is a special type of list template. Hugo assumes that the home page of your site will act as the portal for the rest of the content in the site.</p><h4 id="partial-template">Partial Template</h4><p>A partial template is a template that can be included in other templates. Partial templates must be called using the “partial” template command. They are very handy for rolling up common behavior. For example, your site may have a banner that all pages use. Instead of copying the text of the banner into every single and list template, you could create a partial with the banner in it. That way if you decide to change the banner, you only have to change the partial template.</p><h2 id="create-a-new-site">Create a New Site</h2><p>Let&rsquo;s use Hugo to create a new web site. I&rsquo;m a Mac user, so I&rsquo;ll create mine in my home directory, in the Sites folder. If you&rsquo;re using Linux, you might have to create the folder first.</p><p>The &ldquo;new site&rdquo; command will create a skeleton of a site. It will give you the basic directory structure and a useable configuration file.</p><pre><code>$ hugo new site ~/Sites/zafta$ cd ~/Sites/zafta$ ls -ltotal 8drwxr-xr-x 7 quoha staff 238 Sep 29 16:49 .drwxr-xr-x 3 quoha staff 102 Sep 29 16:49 ..drwxr-xr-x 2 quoha staff 68 Sep 29 16:49 archetypes-rw-r--r-- 1 quoha staff 82 Sep 29 16:49 config.tomldrwxr-xr-x 2 quoha staff 68 Sep 29 16:49 contentdrwxr-xr-x 2 quoha staff 68 Sep 29 16:49 layoutsdrwxr-xr-x 2 quoha staff 68 Sep 29 16:49 static$</code></pre><p>Take a look in the content/ directory to confirm that it is empty.</p><p>The other directories (archetypes/, layouts/, and static/) are used when customizing a theme. That&rsquo;s a topic for a different tutorial, so please ignore them for now.</p><h3 id="generate-the-html-for-the-new-site">Generate the HTML For the New Site</h3><p>Running the <code>hugo</code> command with no options will read all the available content and generate the HTML files. It will also copy all static files (that&rsquo;s everything that&rsquo;s not content). Since we have an empty site, it won&rsquo;t do much, but it will do it very quickly.</p><pre><code>$ hugo --verboseINFO: 2014/09/29 Using config file: config.tomlINFO: 2014/09/29 syncing from /Users/quoha/Sites/zafta/static/ to /Users/quoha/Sites/zafta/public/WARN: 2014/09/29 Unable to locate layout: [index.html _default/list.html _default/single.html]WARN: 2014/09/29 Unable to locate layout: [404.html]0 draft content0 future content0 pages created0 tags created0 categories createdin 2 ms$</code></pre><p>The &ldquo;<code>--verbose</code>&rdquo; flag gives extra information that will be helpful when we build the template. Every line of the output that starts with &ldquo;INFO:&rdquo; or &ldquo;WARN:&rdquo; is present because we used that flag. The lines that start with &ldquo;WARN:&rdquo; are warning messages. We&rsquo;ll go over them later.</p><p>We can verify that the command worked by looking at the directory again.</p><pre><code>$ ls -ltotal 8drwxr-xr-x 2 quoha staff 68 Sep 29 16:49 archetypes-rw-r--r-- 1 quoha staff 82 Sep 29 16:49 config.tomldrwxr-xr-x 2 quoha staff 68 Sep 29 16:49 contentdrwxr-xr-x 2 quoha staff 68 Sep 29 16:49 layoutsdrwxr-xr-x 4 quoha staff 136 Sep 29 17:02 publicdrwxr-xr-x 2 quoha staff 68 Sep 29 16:49 static$</code></pre><p>See that new public/ directory? Hugo placed all generated content there. When you&rsquo;re ready to publish your web site, that&rsquo;s the place to start. For now, though, let&rsquo;s just confirm that we have what we&rsquo;d expect from a site with no content.</p><pre><code>$ ls -l publictotal 16-rw-r--r-- 1 quoha staff 416 Sep 29 17:02 index.xml-rw-r--r-- 1 quoha staff 262 Sep 29 17:02 sitemap.xml$</code></pre><p>Hugo created two XML files, which is standard, but there are no HTML files.</p><h3 id="test-the-new-site">Test the New Site</h3><p>Verify that you can run the built-in web server. It will dramatically shorten your development cycle if you do. Start it by running the &ldquo;server&rdquo; command. If it is successful, you will see output similar to the following:</p><pre><code>$ hugo server --verboseINFO: 2014/09/29 Using config file: /Users/quoha/Sites/zafta/config.tomlINFO: 2014/09/29 syncing from /Users/quoha/Sites/zafta/static/ to /Users/quoha/Sites/zafta/public/WARN: 2014/09/29 Unable to locate layout: [index.html _default/list.html _default/single.html]WARN: 2014/09/29 Unable to locate layout: [404.html]0 draft content0 future content0 pages created0 tags created0 categories createdin 2 msServing pages from /Users/quoha/Sites/zafta/publicWeb Server is available at http://localhost:1313Press Ctrl+C to stop</code></pre><p>Connect to the listed URL (it&rsquo;s on the line that starts with &ldquo;Web Server&rdquo;). If everything is working correctly, you should get a page that shows the following:</p><pre><code>index.xmlsitemap.xml</code></pre><p>That&rsquo;s a listing of your public/ directory. Hugo didn&rsquo;t create a home page because our site has no content. When there&rsquo;s no index.html file in a directory, the server lists the files in the directory, which is what you should see in your browser.</p><p>Let’s go back and look at those warnings again.</p><pre><code>WARN: 2014/09/29 Unable to locate layout: [index.html _default/list.html _default/single.html]WARN: 2014/09/29 Unable to locate layout: [404.html]</code></pre><p>That second warning is easier to explain. We haven’t created a template to be used to generate “page not found errors.” The 404 message is a topic for a separate tutorial.</p><p>Now for the first warning. It is for the home page. You can tell because the first layout that it looked for was “index.html.” That’s only used by the home page.</p><p>I like that the verbose flag causes Hugo to list the files that it&rsquo;s searching for. For the home page, they are index.html, _default/list.html, and _default/single.html. There are some rules that we&rsquo;ll cover later that explain the names and paths. For now, just remember that Hugo couldn&rsquo;t find a template for the home page and it told you so.</p><p>At this point, you&rsquo;ve got a working installation and site that we can build upon. All that’s left is to add some content and a theme to display it.</p><h2 id="create-a-new-theme">Create a New Theme</h2><p>Hugo doesn&rsquo;t ship with a default theme. There are a few available (I counted a dozen when I first installed Hugo) and Hugo comes with a command to create new themes.</p><p>We&rsquo;re going to create a new theme called &ldquo;zafta.&rdquo; Since the goal of this tutorial is to show you how to fill out the files to pull in your content, the theme will not contain any CSS. In other words, ugly but functional.</p><p>All themes have opinions on content and layout. For example, Zafta uses &ldquo;post&rdquo; over &ldquo;blog&rdquo;. Strong opinions make for simpler templates but differing opinions make it tougher to use themes. When you build a theme, consider using the terms that other themes do.</p><h3 id="create-a-skeleton">Create a Skeleton</h3><p>Use the hugo &ldquo;new&rdquo; command to create the skeleton of a theme. This creates the directory structure and places empty files for you to fill out.</p><pre><code>$ hugo new theme zafta$ ls -ltotal 8drwxr-xr-x 2 quoha staff 68 Sep 29 16:49 archetypes-rw-r--r-- 1 quoha staff 82 Sep 29 16:49 config.tomldrwxr-xr-x 2 quoha staff 68 Sep 29 16:49 contentdrwxr-xr-x 2 quoha staff 68 Sep 29 16:49 layoutsdrwxr-xr-x 4 quoha staff 136 Sep 29 17:02 publicdrwxr-xr-x 2 quoha staff 68 Sep 29 16:49 staticdrwxr-xr-x 3 quoha staff 102 Sep 29 17:31 themes$ find themes -type f | xargs ls -l-rw-r--r-- 1 quoha staff 1081 Sep 29 17:31 themes/zafta/LICENSE.md-rw-r--r-- 1 quoha staff 0 Sep 29 17:31 themes/zafta/archetypes/default.md-rw-r--r-- 1 quoha staff 0 Sep 29 17:31 themes/zafta/layouts/_default/list.html-rw-r--r-- 1 quoha staff 0 Sep 29 17:31 themes/zafta/layouts/_default/single.html-rw-r--r-- 1 quoha staff 0 Sep 29 17:31 themes/zafta/layouts/index.html-rw-r--r-- 1 quoha staff 0 Sep 29 17:31 themes/zafta/layouts/partials/footer.html-rw-r--r-- 1 quoha staff 0 Sep 29 17:31 themes/zafta/layouts/partials/header.html-rw-r--r-- 1 quoha staff 93 Sep 29 17:31 themes/zafta/theme.toml$</code></pre><p>The skeleton includes templates (the files ending in .html), license file, a description of your theme (the theme.toml file), and an empty archetype.</p><p>Please take a minute to fill out the theme.toml and LICENSE.md files. They&rsquo;re optional, but if you&rsquo;re going to be distributing your theme, it tells the world who to praise (or blame). It&rsquo;s also nice to declare the license so that people will know how they can use the theme.</p><pre><code>$ vi themes/zafta/theme.tomlauthor = &quot;michael d henderson&quot;description = &quot;a minimal working template&quot;license = &quot;MIT&quot;name = &quot;zafta&quot;source_repo = &quot;&quot;tags = [&quot;tags&quot;, &quot;categories&quot;]:wq## also edit themes/zafta/LICENSE.md and change## the bit that says &quot;YOUR_NAME_HERE&quot;</code></pre><p>Note that the the skeleton&rsquo;s template files are empty. Don&rsquo;t worry, we&rsquo;ll be changing that shortly.</p><pre><code>$ find themes/zafta -name '*.html' | xargs ls -l-rw-r--r-- 1 quoha staff 0 Sep 29 17:31 themes/zafta/layouts/_default/list.html-rw-r--r-- 1 quoha staff 0 Sep 29 17:31 themes/zafta/layouts/_default/single.html-rw-r--r-- 1 quoha staff 0 Sep 29 17:31 themes/zafta/layouts/index.html-rw-r--r-- 1 quoha staff 0 Sep 29 17:31 themes/zafta/layouts/partials/footer.html-rw-r--r-- 1 quoha staff 0 Sep 29 17:31 themes/zafta/layouts/partials/header.html$</code></pre><h3 id="update-the-configuration-file-to-use-the-theme">Update the Configuration File to Use the Theme</h3><p>Now that we&rsquo;ve got a theme to work with, it&rsquo;s a good idea to add the theme name to the configuration file. This is optional, because you can always add &ldquo;-t zafta&rdquo; on all your commands. I like to put it the configuration file because I like shorter command lines. If you don&rsquo;t put it in the configuration file or specify it on the command line, you won&rsquo;t use the template that you&rsquo;re expecting to.</p><p>Edit the file to add the theme, add a title for the site, and specify that all of our content will use the TOML format.</p><pre><code>$ vi config.tomltheme = &quot;zafta&quot;baseurl = &quot;&quot;languageCode = &quot;en-us&quot;title = &quot;zafta - totally refreshing&quot;MetaDataFormat = &quot;toml&quot;:wq$</code></pre><h3 id="generate-the-site">Generate the Site</h3><p>Now that we have an empty theme, let&rsquo;s generate the site again.</p><pre><code>$ hugo --verboseINFO: 2014/09/29 Using config file: /Users/quoha/Sites/zafta/config.tomlINFO: 2014/09/29 syncing from /Users/quoha/Sites/zafta/themes/zafta/static/ to /Users/quoha/Sites/zafta/public/INFO: 2014/09/29 syncing from /Users/quoha/Sites/zafta/static/ to /Users/quoha/Sites/zafta/public/WARN: 2014/09/29 Unable to locate layout: [404.html theme/404.html]0 draft content0 future content0 pages created0 tags created0 categories createdin 2 ms$</code></pre><p>Did you notice that the output is different? The warning message for the home page has disappeared and we have an additional information line saying that Hugo is syncing from the theme&rsquo;s directory.</p><p>Let&rsquo;s check the public/ directory to see what Hugo&rsquo;s created.</p><pre><code>$ ls -l publictotal 16drwxr-xr-x 2 quoha staff 68 Sep 29 17:56 css-rw-r--r-- 1 quoha staff 0 Sep 29 17:56 index.html-rw-r--r-- 1 quoha staff 407 Sep 29 17:56 index.xmldrwxr-xr-x 2 quoha staff 68 Sep 29 17:56 js-rw-r--r-- 1 quoha staff 243 Sep 29 17:56 sitemap.xml$</code></pre><p>Notice four things:</p><ol><li>Hugo created a home page. This is the file public/index.html.</li><li>Hugo created a css/ directory.</li><li>Hugo created a js/ directory.</li><li>Hugo claimed that it created 0 pages. It created a file and copied over static files, but didn&rsquo;t create any pages. That&rsquo;s because it considers a &ldquo;page&rdquo; to be a file created directly from a content file. It doesn&rsquo;t count things like the index.html files that it creates automatically.</li></ol><h4 id="the-home-page-1">The Home Page</h4><p>Hugo supports many different types of templates. The home page is special because it gets its own type of template and its own template file. The file, layouts/index.html, is used to generate the HTML for the home page. The Hugo documentation says that this is the only required template, but that depends. Hugo&rsquo;s warning message shows that it looks for three different templates:</p><pre><code>WARN: 2014/09/29 Unable to locate layout: [index.html _default/list.html _default/single.html]</code></pre><p>If it can&rsquo;t find any of these, it completely skips creating the home page. We noticed that when we built the site without having a theme installed.</p><p>When Hugo created our theme, it created an empty home page template. Now, when we build the site, Hugo finds the template and uses it to generate the HTML for the home page. Since the template file is empty, the HTML file is empty, too. If the template had any rules in it, then Hugo would have used them to generate the home page.</p><pre><code>$ find . -name index.html | xargs ls -l-rw-r--r-- 1 quoha staff 0 Sep 29 20:21 ./public/index.html-rw-r--r-- 1 quoha staff 0 Sep 29 17:31 ./themes/zafta/layouts/index.html$</code></pre><h4 id="the-magic-of-static">The Magic of Static</h4><p>Hugo does two things when generating the site. It uses templates to transform content into HTML and it copies static files into the site. Unlike content, static files are not transformed. They are copied exactly as they are.</p><p>Hugo assumes that your site will use both CSS and JavaScript, so it creates directories in your theme to hold them. Remember opinions? Well, Hugo&rsquo;s opinion is that you&rsquo;ll store your CSS in a directory named css/ and your JavaScript in a directory named js/. If you don&rsquo;t like that, you can change the directory names in your theme directory or even delete them completely. Hugo&rsquo;s nice enough to offer its opinion, then behave nicely if you disagree.</p><pre><code>$ find themes/zafta -type d | xargs ls -lddrwxr-xr-x 7 quoha staff 238 Sep 29 17:38 themes/zaftadrwxr-xr-x 3 quoha staff 102 Sep 29 17:31 themes/zafta/archetypesdrwxr-xr-x 5 quoha staff 170 Sep 29 17:31 themes/zafta/layoutsdrwxr-xr-x 4 quoha staff 136 Sep 29 17:31 themes/zafta/layouts/_defaultdrwxr-xr-x 4 quoha staff 136 Sep 29 17:31 themes/zafta/layouts/partialsdrwxr-xr-x 4 quoha staff 136 Sep 29 17:31 themes/zafta/staticdrwxr-xr-x 2 quoha staff 68 Sep 29 17:31 themes/zafta/static/cssdrwxr-xr-x 2 quoha staff 68 Sep 29 17:31 themes/zafta/static/js$</code></pre><h2 id="the-theme-development-cycle">The Theme Development Cycle</h2><p>When you&rsquo;re working on a theme, you will make changes in the theme&rsquo;s directory, rebuild the site, and check your changes in the browser. Hugo makes this very easy:</p><ol><li>Purge the public/ directory.</li><li>Run the built in web server in watch mode.</li><li>Open your site in a browser.</li><li>Update the theme.</li><li>Glance at your browser window to see changes.</li><li>Return to step 4.</li></ol><p>I’ll throw in one more opinion: never work on a theme on a live site. Always work on a copy of your site. Make changes to your theme, test them, then copy them up to your site. For added safety, use a tool like Git to keep a revision history of your content and your theme. Believe me when I say that it is too easy to lose both your mind and your changes.</p><p>Check the main Hugo site for information on using Git with Hugo.</p><h3 id="purge-the-public-directory">Purge the public/ Directory</h3><p>When generating the site, Hugo will create new files and update existing ones in the <code>public/</code> directory. It will not delete files that are no longer used. For example, files that were created in the wrong directory or with the wrong title will remain. If you leave them, you might get confused by them later. I recommend cleaning out your site prior to generating it.</p><p>Note: If you&rsquo;re building on an SSD, you should ignore this. Churning on a SSD can be costly.</p><h3 id="hugos-watch-option">Hugo&rsquo;s Watch Option</h3><p>Hugo&rsquo;s &ldquo;<code>--watch</code>&rdquo; option will monitor the content/ and your theme directories for changes and rebuild the site automatically.</p><h3 id="live-reload">Live Reload</h3><p>Hugo&rsquo;s built in web server supports live reload. As pages are saved on the server, the browser is told to refresh the page. Usually, this happens faster than you can say, &ldquo;Wow, that&rsquo;s totally amazing.&rdquo;</p><h3 id="development-commands">Development Commands</h3><p>Use the following commands as the basis for your workflow.</p><pre><code>## purge old files. hugo will recreate the public directory.##$ rm -rf public#### run hugo in watch mode##$ hugo server --watch --verbose</code></pre><p>Here&rsquo;s sample output showing Hugo detecting a change to the template for the home page. Once generated, the web browser automatically reloaded the page. I&rsquo;ve said this before, it&rsquo;s amazing.</p><pre><code>$ rm -rf public$ hugo server --watch --verboseINFO: 2014/09/29 Using config file: /Users/quoha/Sites/zafta/config.tomlINFO: 2014/09/29 syncing from /Users/quoha/Sites/zafta/themes/zafta/static/ to /Users/quoha/Sites/zafta/public/INFO: 2014/09/29 syncing from /Users/quoha/Sites/zafta/static/ to /Users/quoha/Sites/zafta/public/WARN: 2014/09/29 Unable to locate layout: [404.html theme/404.html]0 draft content0 future content0 pages created0 tags created0 categories createdin 2 msWatching for changes in /Users/quoha/Sites/zafta/contentServing pages from /Users/quoha/Sites/zafta/publicWeb Server is available at http://localhost:1313Press Ctrl+C to stopINFO: 2014/09/29 File System Event: [&quot;/Users/quoha/Sites/zafta/themes/zafta/layouts/index.html&quot;: MODIFY|ATTRIB]Change detected, rebuilding siteWARN: 2014/09/29 Unable to locate layout: [404.html theme/404.html]0 draft content0 future content0 pages created0 tags created0 categories createdin 1 ms</code></pre><h2 id="update-the-home-page-template">Update the Home Page Template</h2><p>The home page is one of a few special pages that Hugo creates automatically. As mentioned earlier, it looks for one of three files in the theme&rsquo;s layout/ directory:</p><ol><li>index.html</li><li>_default/list.html</li><li>_default/single.html</li></ol><p>We could update one of the default templates, but a good design decision is to update the most specific template available. That&rsquo;s not a hard and fast rule (in fact, we&rsquo;ll break it a few times in this tutorial), but it is a good generalization.</p><h3 id="make-a-static-home-page">Make a Static Home Page</h3><p>Right now, that page is empty because we don&rsquo;t have any content and we don&rsquo;t have any logic in the template. Let&rsquo;s change that by adding some text to the template.</p><pre><code>$ vi themes/zafta/layouts/index.html&lt;!DOCTYPE html&gt;&lt;html&gt;&lt;body&gt; &lt;p&gt;hugo says hello!&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;:wq$</code></pre><p>Build the web site and then verify the results.</p><pre><code>$ hugo --verboseINFO: 2014/09/29 Using config file: /Users/quoha/Sites/zafta/config.tomlINFO: 2014/09/29 syncing from /Users/quoha/Sites/zafta/themes/zafta/static/ to /Users/quoha/Sites/zafta/public/INFO: 2014/09/29 syncing from /Users/quoha/Sites/zafta/static/ to /Users/quoha/Sites/zafta/public/WARN: 2014/09/29 Unable to locate layout: [404.html theme/404.html]0 draft content0 future content0 pages created0 tags created0 categories createdin 2 ms$ find public -type f -name '*.html' | xargs ls -l-rw-r--r-- 1 quoha staff 78 Sep 29 21:26 public/index.html$ cat public/index.html&lt;!DOCTYPE html&gt;&lt;html&gt;&lt;body&gt; &lt;p&gt;hugo says hello!&lt;/p&gt;&lt;/html&gt;</code></pre><h4 id="live-reload-1">Live Reload</h4><p>Note: If you&rsquo;re running the server with the <code>--watch</code> option, you&rsquo;ll see different content in the file:</p><pre><code>$ cat public/index.html&lt;!DOCTYPE html&gt;&lt;html&gt;&lt;body&gt; &lt;p&gt;hugo says hello!&lt;/p&gt;&lt;script&gt;document.write('&lt;script src=&quot;http://' + (location.host || 'localhost').split(':')[0] + ':1313/livereload.js?mindelay=10&quot;&gt;&lt;/' + 'script&gt;')&lt;/script&gt;&lt;/body&gt;&lt;/html&gt;</code></pre><p>When you use <code>--watch</code>, the Live Reload script is added by Hugo. Look for live reload in the documentation to see what it does and how to disable it.</p><h3 id="build-a-dynamic-home-page">Build a &ldquo;Dynamic&rdquo; Home Page</h3><p>&ldquo;Dynamic home page?&rdquo; Hugo&rsquo;s a static web site generator, so this seems an odd thing to say. I mean let&rsquo;s have the home page automatically reflect the content in the site every time Hugo builds it. We&rsquo;ll use iteration in the template to do that.</p><h4 id="create-new-posts">Create New Posts</h4><p>Now that we have the home page generating static content, let&rsquo;s add some content to the site. We&rsquo;ll display these posts as a list on the home page and on their own page, too.</p><p>Hugo has a command to generate a skeleton post, just like it does for sites and themes.</p><pre><code>$ hugo --verbose new post/first.mdINFO: 2014/09/29 Using config file: /Users/quoha/Sites/zafta/config.tomlINFO: 2014/09/29 attempting to create post/first.md of postINFO: 2014/09/29 curpath: /Users/quoha/Sites/zafta/themes/zafta/archetypes/default.mdERROR: 2014/09/29 Unable to Cast &lt;nil&gt; to map[string]interface{}$</code></pre><p>That wasn&rsquo;t very nice, was it?</p><p>The &ldquo;new&rdquo; command uses an archetype to create the post file. Hugo created an empty default archetype file, but that causes an error when there&rsquo;s a theme. For me, the workaround was to create an archetypes file specifically for the post type.</p><pre><code>$ vi themes/zafta/archetypes/post.md+++Description = &quot;&quot;Tags = []Categories = []+++:wq$ find themes/zafta/archetypes -type f | xargs ls -l-rw-r--r-- 1 quoha staff 0 Sep 29 21:53 themes/zafta/archetypes/default.md-rw-r--r-- 1 quoha staff 51 Sep 29 21:54 themes/zafta/archetypes/post.md$ hugo --verbose new post/first.mdINFO: 2014/09/29 Using config file: /Users/quoha/Sites/zafta/config.tomlINFO: 2014/09/29 attempting to create post/first.md of postINFO: 2014/09/29 curpath: /Users/quoha/Sites/zafta/themes/zafta/archetypes/post.mdINFO: 2014/09/29 creating /Users/quoha/Sites/zafta/content/post/first.md/Users/quoha/Sites/zafta/content/post/first.md created$ hugo --verbose new post/second.mdINFO: 2014/09/29 Using config file: /Users/quoha/Sites/zafta/config.tomlINFO: 2014/09/29 attempting to create post/second.md of postINFO: 2014/09/29 curpath: /Users/quoha/Sites/zafta/themes/zafta/archetypes/post.mdINFO: 2014/09/29 creating /Users/quoha/Sites/zafta/content/post/second.md/Users/quoha/Sites/zafta/content/post/second.md created$ ls -l content/posttotal 16-rw-r--r-- 1 quoha staff 104 Sep 29 21:54 first.md-rw-r--r-- 1 quoha staff 105 Sep 29 21:57 second.md$ cat content/post/first.md+++Categories = []Description = &quot;&quot;Tags = []date = &quot;2014-09-29T21:54:53-05:00&quot;title = &quot;first&quot;+++my first post$ cat content/post/second.md+++Categories = []Description = &quot;&quot;Tags = []date = &quot;2014-09-29T21:57:09-05:00&quot;title = &quot;second&quot;+++my second post$</code></pre><p>Build the web site and then verify the results.</p><pre><code>$ rm -rf public$ hugo --verboseINFO: 2014/09/29 Using config file: /Users/quoha/Sites/zafta/config.tomlINFO: 2014/09/29 syncing from /Users/quoha/Sites/zafta/themes/zafta/static/ to /Users/quoha/Sites/zafta/public/INFO: 2014/09/29 syncing from /Users/quoha/Sites/zafta/static/ to /Users/quoha/Sites/zafta/public/INFO: 2014/09/29 found taxonomies: map[string]string{&quot;category&quot;:&quot;categories&quot;, &quot;tag&quot;:&quot;tags&quot;}WARN: 2014/09/29 Unable to locate layout: [404.html theme/404.html]0 draft content0 future content2 pages created0 tags created0 categories createdin 4 ms$</code></pre><p>The output says that it created 2 pages. Those are our new posts:</p><pre><code>$ find public -type f -name '*.html' | xargs ls -l-rw-r--r-- 1 quoha staff 78 Sep 29 22:13 public/index.html-rw-r--r-- 1 quoha staff 0 Sep 29 22:13 public/post/first/index.html-rw-r--r-- 1 quoha staff 0 Sep 29 22:13 public/post/index.html-rw-r--r-- 1 quoha staff 0 Sep 29 22:13 public/post/second/index.html$</code></pre><p>The new files are empty because because the templates used to generate the content are empty. The homepage doesn&rsquo;t show the new content, either. We have to update the templates to add the posts.</p><h3 id="list-and-single-templates">List and Single Templates</h3><p>In Hugo, we have three major kinds of templates. There&rsquo;s the home page template that we updated previously. It is used only by the home page. We also have &ldquo;single&rdquo; templates which are used to generate output for a single content file. We also have &ldquo;list&rdquo; templates that are used to group multiple pieces of content before generating output.</p><p>Generally speaking, list templates are named &ldquo;list.html&rdquo; and single templates are named &ldquo;single.html.&rdquo;</p><p>There are three other types of templates: partials, content views, and terms. We will not go into much detail on these.</p><h3 id="add-content-to-the-homepage">Add Content to the Homepage</h3><p>The home page will contain a list of posts. Let&rsquo;s update its template to add the posts that we just created. The logic in the template will run every time we build the site.</p><pre><code>$ vi themes/zafta/layouts/index.html&lt;!DOCTYPE html&gt;&lt;html&gt;&lt;body&gt; {{ range first 10 .Data.Pages }} &lt;h1&gt;{{ .Title }}&lt;/h1&gt; {{ end }}&lt;/body&gt;&lt;/html&gt;:wq$</code></pre><p>Hugo uses the Go template engine. That engine scans the template files for commands which are enclosed between &ldquo;{{&rdquo; and &ldquo;}}&rdquo;. In our template, the commands are:</p><ol><li>range</li><li>.Title</li><li>end</li></ol><p>The &ldquo;range&rdquo; command is an iterator. We&rsquo;re going to use it to go through the first ten pages. Every HTML file that Hugo creates is treated as a page, so looping through the list of pages will look at every file that will be created.</p><p>The &ldquo;.Title&rdquo; command prints the value of the &ldquo;title&rdquo; variable. Hugo pulls it from the front matter in the Markdown file.</p><p>The &ldquo;end&rdquo; command signals the end of the range iterator. The engine loops back to the top of the iteration when it finds &ldquo;end.&rdquo; Everything between the &ldquo;range&rdquo; and &ldquo;end&rdquo; is evaluated every time the engine goes through the iteration. In this file, that would cause the title from the first ten pages to be output as heading level one.</p><p>It&rsquo;s helpful to remember that some variables, like .Data, are created before any output files. Hugo loads every content file into the variable and then gives the template a chance to process before creating the HTML files.</p><p>Build the web site and then verify the results.</p><pre><code>$ rm -rf public$ hugo --verboseINFO: 2014/09/29 Using config file: /Users/quoha/Sites/zafta/config.tomlINFO: 2014/09/29 syncing from /Users/quoha/Sites/zafta/themes/zafta/static/ to /Users/quoha/Sites/zafta/public/INFO: 2014/09/29 syncing from /Users/quoha/Sites/zafta/static/ to /Users/quoha/Sites/zafta/public/INFO: 2014/09/29 found taxonomies: map[string]string{&quot;tag&quot;:&quot;tags&quot;, &quot;category&quot;:&quot;categories&quot;}WARN: 2014/09/29 Unable to locate layout: [404.html theme/404.html]0 draft content0 future content2 pages created0 tags created0 categories createdin 4 ms$ find public -type f -name '*.html' | xargs ls -l-rw-r--r-- 1 quoha staff 94 Sep 29 22:23 public/index.html-rw-r--r-- 1 quoha staff 0 Sep 29 22:23 public/post/first/index.html-rw-r--r-- 1 quoha staff 0 Sep 29 22:23 public/post/index.html-rw-r--r-- 1 quoha staff 0 Sep 29 22:23 public/post/second/index.html$ cat public/index.html&lt;!DOCTYPE html&gt;&lt;html&gt;&lt;body&gt; &lt;h1&gt;second&lt;/h1&gt; &lt;h1&gt;first&lt;/h1&gt;&lt;/body&gt;&lt;/html&gt;$</code></pre><p>Congratulations, the home page shows the title of the two posts. The posts themselves are still empty, but let&rsquo;s take a moment to appreciate what we&rsquo;ve done. Your template now generates output dynamically. Believe it or not, by inserting the range command inside of those curly braces, you&rsquo;ve learned everything you need to know to build a theme. All that&rsquo;s really left is understanding which template will be used to generate each content file and becoming familiar with the commands for the template engine.</p><p>And, if that were entirely true, this tutorial would be much shorter. There are a few things to know that will make creating a new template much easier. Don&rsquo;t worry, though, that&rsquo;s all to come.</p><h3 id="add-content-to-the-posts">Add Content to the Posts</h3><p>We&rsquo;re working with posts, which are in the content/post/ directory. That means that their section is &ldquo;post&rdquo; (and if we don&rsquo;t do something weird, their type is also &ldquo;post&rdquo;).</p><p>Hugo uses the section and type to find the template file for every piece of content. Hugo will first look for a template file that matches the section or type name. If it can&rsquo;t find one, then it will look in the _default/ directory. There are some twists that we&rsquo;ll cover when we get to categories and tags, but for now we can assume that Hugo will try post/single.html, then _default/single.html.</p><p>Now that we know the search rule, let&rsquo;s see what we actually have available:</p><pre><code>$ find themes/zafta -name single.html | xargs ls -l-rw-r--r-- 1 quoha staff 132 Sep 29 17:31 themes/zafta/layouts/_default/single.html</code></pre><p>We could create a new template, post/single.html, or change the default. Since we don&rsquo;t know of any other content types, let&rsquo;s start with updating the default.</p><p>Remember, any content that we haven&rsquo;t created a template for will end up using this template. That can be good or bad. Bad because I know that we&rsquo;re going to be adding different types of content and we&rsquo;re going to end up undoing some of the changes we&rsquo;ve made. It&rsquo;s good because we&rsquo;ll be able to see immediate results. It&rsquo;s also good to start here because we can start to build the basic layout for the site. As we add more content types, we&rsquo;ll refactor this file and move logic around. Hugo makes that fairly painless, so we&rsquo;ll accept the cost and proceed.</p><p>Please see the Hugo documentation on template rendering for all the details on determining which template to use. And, as the docs mention, if you&rsquo;re building a single page application (SPA) web site, you can delete all of the other templates and work with just the default single page. That&rsquo;s a refreshing amount of joy right there.</p><h4 id="update-the-template-file">Update the Template File</h4><pre><code>$ vi themes/zafta/layouts/_default/single.html&lt;!DOCTYPE html&gt;&lt;html&gt;&lt;head&gt; &lt;title&gt;{{ .Title }}&lt;/title&gt;&lt;/head&gt;&lt;body&gt; &lt;h1&gt;{{ .Title }}&lt;/h1&gt; {{ .Content }}&lt;/body&gt;&lt;/html&gt;:wq$</code></pre><p>Build the web site and verify the results.</p><pre><code>$ rm -rf public$ hugo --verboseINFO: 2014/09/29 Using config file: /Users/quoha/Sites/zafta/config.tomlINFO: 2014/09/29 syncing from /Users/quoha/Sites/zafta/themes/zafta/static/ to /Users/quoha/Sites/zafta/public/INFO: 2014/09/29 syncing from /Users/quoha/Sites/zafta/static/ to /Users/quoha/Sites/zafta/public/INFO: 2014/09/29 found taxonomies: map[string]string{&quot;tag&quot;:&quot;tags&quot;, &quot;category&quot;:&quot;categories&quot;}WARN: 2014/09/29 Unable to locate layout: [404.html theme/404.html]0 draft content0 future content2 pages created0 tags created0 categories createdin 4 ms$ find public -type f -name '*.html' | xargs ls -l-rw-r--r-- 1 quoha staff 94 Sep 29 22:40 public/index.html-rw-r--r-- 1 quoha staff 125 Sep 29 22:40 public/post/first/index.html-rw-r--r-- 1 quoha staff 0 Sep 29 22:40 public/post/index.html-rw-r--r-- 1 quoha staff 128 Sep 29 22:40 public/post/second/index.html$ cat public/post/first/index.html&lt;!DOCTYPE html&gt;&lt;html&gt;&lt;head&gt; &lt;title&gt;first&lt;/title&gt;&lt;/head&gt;&lt;body&gt; &lt;h1&gt;first&lt;/h1&gt; &lt;p&gt;my first post&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;$ cat public/post/second/index.html&lt;!DOCTYPE html&gt;&lt;html&gt;&lt;head&gt; &lt;title&gt;second&lt;/title&gt;&lt;/head&gt;&lt;body&gt; &lt;h1&gt;second&lt;/h1&gt; &lt;p&gt;my second post&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;$</code></pre><p>Notice that the posts now have content. You can go to localhost:1313/post/first to verify.</p><h3 id="linking-to-content">Linking to Content</h3><p>The posts are on the home page. Let&rsquo;s add a link from there to the post. Since this is the home page, we&rsquo;ll update its template.</p><pre><code>$ vi themes/zafta/layouts/index.html&lt;!DOCTYPE html&gt;&lt;html&gt;&lt;body&gt; {{ range first 10 .Data.Pages }} &lt;h1&gt;&lt;a href=&quot;{{ .Permalink }}&quot;&gt;{{ .Title }}&lt;/a&gt;&lt;/h1&gt; {{ end }}&lt;/body&gt;&lt;/html&gt;</code></pre><p>Build the web site and verify the results.</p><pre><code>$ rm -rf public$ hugo --verboseINFO: 2014/09/29 Using config file: /Users/quoha/Sites/zafta/config.tomlINFO: 2014/09/29 syncing from /Users/quoha/Sites/zafta/themes/zafta/static/ to /Users/quoha/Sites/zafta/public/INFO: 2014/09/29 syncing from /Users/quoha/Sites/zafta/static/ to /Users/quoha/Sites/zafta/public/INFO: 2014/09/29 found taxonomies: map[string]string{&quot;tag&quot;:&quot;tags&quot;, &quot;category&quot;:&quot;categories&quot;}WARN: 2014/09/29 Unable to locate layout: [404.html theme/404.html]0 draft content0 future content2 pages created0 tags created0 categories createdin 4 ms$ find public -type f -name '*.html' | xargs ls -l-rw-r--r-- 1 quoha staff 149 Sep 29 22:44 public/index.html-rw-r--r-- 1 quoha staff 125 Sep 29 22:44 public/post/first/index.html-rw-r--r-- 1 quoha staff 0 Sep 29 22:44 public/post/index.html-rw-r--r-- 1 quoha staff 128 Sep 29 22:44 public/post/second/index.html$ cat public/index.html&lt;!DOCTYPE html&gt;&lt;html&gt;&lt;body&gt; &lt;h1&gt;&lt;a href=&quot;/post/second/&quot;&gt;second&lt;/a&gt;&lt;/h1&gt; &lt;h1&gt;&lt;a href=&quot;/post/first/&quot;&gt;first&lt;/a&gt;&lt;/h1&gt;&lt;/body&gt;&lt;/html&gt;$</code></pre><h3 id="create-a-post-listing">Create a Post Listing</h3><p>We have the posts displaying on the home page and on their own page. We also have a file public/post/index.html that is empty. Let&rsquo;s make it show a list of all posts (not just the first ten).</p><p>We need to decide which template to update. This will be a listing, so it should be a list template. Let&rsquo;s take a quick look and see which list templates are available.</p><pre><code>$ find themes/zafta -name list.html | xargs ls -l-rw-r--r-- 1 quoha staff 0 Sep 29 17:31 themes/zafta/layouts/_default/list.html</code></pre><p>As with the single post, we have to decide to update _default/list.html or create post/list.html. We still don&rsquo;t have multiple content types, so let&rsquo;s stay consistent and update the default list template.</p><h2 id="creating-top-level-pages">Creating Top Level Pages</h2><p>Let&rsquo;s add an &ldquo;about&rdquo; page and display it at the top level (as opposed to a sub-level like we did with posts).</p><p>The default in Hugo is to use the directory structure of the content/ directory to guide the location of the generated html in the public/ directory. Let&rsquo;s verify that by creating an &ldquo;about&rdquo; page at the top level:</p><pre><code>$ vi content/about.md+++title = &quot;about&quot;description = &quot;about this site&quot;date = &quot;2014-09-27&quot;slug = &quot;about time&quot;+++## about usi'm speechless:wq</code></pre><p>Generate the web site and verify the results.</p><pre><code>$ find public -name '*.html' | xargs ls -l-rw-rw-r-- 1 mdhender staff 334 Sep 27 15:08 public/about-time/index.html-rw-rw-r-- 1 mdhender staff 527 Sep 27 15:08 public/index.html-rw-rw-r-- 1 mdhender staff 358 Sep 27 15:08 public/post/first-post/index.html-rw-rw-r-- 1 mdhender staff 0 Sep 27 15:08 public/post/index.html-rw-rw-r-- 1 mdhender staff 342 Sep 27 15:08 public/post/second-post/index.html</code></pre><p>Notice that the page wasn&rsquo;t created at the top level. It was created in a sub-directory named &lsquo;about-time/&rsquo;. That name came from our slug. Hugo will use the slug to name the generated content. It&rsquo;s a reasonable default, by the way, but we can learn a few things by fighting it for this file.</p><p>One other thing. Take a look at the home page.</p><pre><code>$ cat public/index.html&lt;!DOCTYPE html&gt;&lt;html&gt;&lt;body&gt; &lt;h1&gt;&lt;a href=&quot;http://localhost:1313/post/theme/&quot;&gt;creating a new theme&lt;/a&gt;&lt;/h1&gt; &lt;h1&gt;&lt;a href=&quot;http://localhost:1313/about-time/&quot;&gt;about&lt;/a&gt;&lt;/h1&gt; &lt;h1&gt;&lt;a href=&quot;http://localhost:1313/post/second-post/&quot;&gt;second&lt;/a&gt;&lt;/h1&gt; &lt;h1&gt;&lt;a href=&quot;http://localhost:1313/post/first-post/&quot;&gt;first&lt;/a&gt;&lt;/h1&gt;&lt;script&gt;document.write('&lt;script src=&quot;http://' + (location.host || 'localhost').split(':')[0]+ ':1313/livereload.js?mindelay=10&quot;&gt;&lt;/' + 'script&gt;')&lt;/script&gt;&lt;/body&gt;&lt;/html&gt;</code></pre><p>Notice that the &ldquo;about&rdquo; link is listed with the posts? That&rsquo;s not desirable, so let&rsquo;s change that first.</p><pre><code>$ vi themes/zafta/layouts/index.html&lt;!DOCTYPE html&gt;&lt;html&gt;&lt;body&gt; &lt;h1&gt;posts&lt;/h1&gt; {{ range first 10 .Data.Pages }} {{ if eq .Type &quot;post&quot;}} &lt;h2&gt;&lt;a href=&quot;{{ .Permalink }}&quot;&gt;{{ .Title }}&lt;/a&gt;&lt;/h2&gt; {{ end }} {{ end }} &lt;h1&gt;pages&lt;/h1&gt; {{ range .Data.Pages }} {{ if eq .Type &quot;page&quot; }} &lt;h2&gt;&lt;a href=&quot;{{ .Permalink }}&quot;&gt;{{ .Title }}&lt;/a&gt;&lt;/h2&gt; {{ end }} {{ end }}&lt;/body&gt;&lt;/html&gt;:wq</code></pre><p>Generate the web site and verify the results. The home page has two sections, posts and pages, and each section has the right set of headings and links in it.</p><p>But, that about page still renders to about-time/index.html.</p><pre><code>$ find public -name '*.html' | xargs ls -l-rw-rw-r-- 1 mdhender staff 334 Sep 27 15:33 public/about-time/index.html-rw-rw-r-- 1 mdhender staff 645 Sep 27 15:33 public/index.html-rw-rw-r-- 1 mdhender staff 358 Sep 27 15:33 public/post/first-post/index.html-rw-rw-r-- 1 mdhender staff 0 Sep 27 15:33 public/post/index.html-rw-rw-r-- 1 mdhender staff 342 Sep 27 15:33 public/post/second-post/index.html</code></pre><p>Knowing that hugo is using the slug to generate the file name, the simplest solution is to change the slug. Let&rsquo;s do it the hard way and change the permalink in the configuration file.</p><pre><code>$ vi config.toml[permalinks]page = &quot;/:title/&quot;about = &quot;/:filename/&quot;</code></pre><p>Generate the web site and verify that this didn&rsquo;t work. Hugo lets &ldquo;slug&rdquo; or &ldquo;URL&rdquo; override the permalinks setting in the configuration file. Go ahead and comment out the slug in content/about.md, then generate the web site to get it to be created in the right place.</p><h2 id="sharing-templates">Sharing Templates</h2><p>If you&rsquo;ve been following along, you probably noticed that posts have titles in the browser and the home page doesn&rsquo;t. That&rsquo;s because we didn&rsquo;t put the title in the home page&rsquo;s template (layouts/index.html). That&rsquo;s an easy thing to do, but let&rsquo;s look at a different option.</p><p>We can put the common bits into a shared template that&rsquo;s stored in the themes/zafta/layouts/partials/ directory.</p><h3 id="create-the-header-and-footer-partials">Create the Header and Footer Partials</h3><p>In Hugo, a partial is a sugar-coated template. Normally a template reference has a path specified. Partials are different. Hugo searches for them along a TODO defined search path. This makes it easier for end-users to override the theme&rsquo;s presentation.</p><pre><code>$ vi themes/zafta/layouts/partials/header.html&lt;!DOCTYPE html&gt;&lt;html&gt;&lt;head&gt;&lt;title&gt;{{ .Title }}&lt;/title&gt;&lt;/head&gt;&lt;body&gt;:wq$ vi themes/zafta/layouts/partials/footer.html&lt;/body&gt;&lt;/html&gt;:wq</code></pre><h3 id="update-the-home-page-template-to-use-the-partials">Update the Home Page Template to Use the Partials</h3><p>The most noticeable difference between a template call and a partials call is the lack of path:</p><pre><code>{{ template &quot;theme/partials/header.html&quot; . }}</code></pre><p>versus</p><pre><code>{{ partial &quot;header.html&quot; . }}</code></pre><p>Both pass in the context.</p><p>Let&rsquo;s change the home page template to use these new partials.</p><pre><code>$ vi themes/zafta/layouts/index.html{{ partial &quot;header.html&quot; . }} &lt;h1&gt;posts&lt;/h1&gt; {{ range first 10 .Data.Pages }} {{ if eq .Type &quot;post&quot;}} &lt;h2&gt;&lt;a href=&quot;{{ .Permalink }}&quot;&gt;{{ .Title }}&lt;/a&gt;&lt;/h2&gt; {{ end }} {{ end }} &lt;h1&gt;pages&lt;/h1&gt; {{ range .Data.Pages }} {{ if or (eq .Type &quot;page&quot;) (eq .Type &quot;about&quot;) }} &lt;h2&gt;&lt;a href=&quot;{{ .Permalink }}&quot;&gt;{{ .Type }} - {{ .Title }} - {{ .RelPermalink }}&lt;/a&gt;&lt;/h2&gt; {{ end }} {{ end }}{{ partial &quot;footer.html&quot; . }}:wq</code></pre><p>Generate the web site and verify the results. The title on the home page is now &ldquo;your title here&rdquo;, which comes from the &ldquo;title&rdquo; variable in the config.toml file.</p><h3 id="update-the-default-single-template-to-use-the-partials">Update the Default Single Template to Use the Partials</h3><pre><code>$ vi themes/zafta/layouts/_default/single.html{{ partial &quot;header.html&quot; . }} &lt;h1&gt;{{ .Title }}&lt;/h1&gt; {{ .Content }}{{ partial &quot;footer.html&quot; . }}:wq</code></pre><p>Generate the web site and verify the results. The title on the posts and the about page should both reflect the value in the markdown file.</p><h2 id="add-date-published-to-posts">Add “Date Published” to Posts</h2><p>It&rsquo;s common to have posts display the date that they were written or published, so let&rsquo;s add that. The front matter of our posts has a variable named &ldquo;date.&rdquo; It&rsquo;s usually the date the content was created, but let&rsquo;s pretend that&rsquo;s the value we want to display.</p><h3 id="add-date-published-to-the-template">Add “Date Published” to the Template</h3><p>We&rsquo;ll start by updating the template used to render the posts. The template code will look like:</p><pre><code>{{ .Date.Format &quot;Mon, Jan 2, 2006&quot; }}</code></pre><p>Posts use the default single template, so we&rsquo;ll change that file.</p><pre><code>$ vi themes/zafta/layouts/_default/single.html{{ partial &quot;header.html&quot; . }} &lt;h1&gt;{{ .Title }}&lt;/h1&gt; &lt;h2&gt;{{ .Date.Format &quot;Mon, Jan 2, 2006&quot; }}&lt;/h2&gt; {{ .Content }}{{ partial &quot;footer.html&quot; . }}:wq</code></pre><p>Generate the web site and verify the results. The posts now have the date displayed in them. There&rsquo;s a problem, though. The &ldquo;about&rdquo; page also has the date displayed.</p><p>As usual, there are a couple of ways to make the date display only on posts. We could do an &ldquo;if&rdquo; statement like we did on the home page. Another way would be to create a separate template for posts.</p><p>The &ldquo;if&rdquo; solution works for sites that have just a couple of content types. It aligns with the principle of &ldquo;code for today,&rdquo; too.</p><p>Let&rsquo;s assume, though, that we&rsquo;ve made our site so complex that we feel we have to create a new template type. In Hugo-speak, we&rsquo;re going to create a section template.</p><p>Let&rsquo;s restore the default single template before we forget.</p><pre><code>$ mkdir themes/zafta/layouts/post$ vi themes/zafta/layouts/_default/single.html{{ partial &quot;header.html&quot; . }} &lt;h1&gt;{{ .Title }}&lt;/h1&gt; {{ .Content }}{{ partial &quot;footer.html&quot; . }}:wq</code></pre><p>Now we&rsquo;ll update the post&rsquo;s version of the single template. If you remember Hugo&rsquo;s rules, the template engine will use this version over the default.</p><pre><code>$ vi themes/zafta/layouts/post/single.html{{ partial &quot;header.html&quot; . }} &lt;h1&gt;{{ .Title }}&lt;/h1&gt; &lt;h2&gt;{{ .Date.Format &quot;Mon, Jan 2, 2006&quot; }}&lt;/h2&gt; {{ .Content }}{{ partial &quot;footer.html&quot; . }}:wq</code></pre><p>Note that we removed the date logic from the default template and put it in the post template. Generate the web site and verify the results. Posts have dates and the about page doesn&rsquo;t.</p><h3 id="dont-repeat-yourself">Don&rsquo;t Repeat Yourself</h3><p>DRY is a good design goal and Hugo does a great job supporting it. Part of the art of a good template is knowing when to add a new template and when to update an existing one. While you&rsquo;re figuring that out, accept that you&rsquo;ll be doing some refactoring. Hugo makes that easy and fast, so it&rsquo;s okay to delay splitting up a template.</p></description></item><item><title>(Hu)go Template Primer</title><link>https://omsf.io/post/goisforlovers/</link><pubDate>Wed, 02 Apr 2014 00:00:00 +0000</pubDate><guid>https://omsf.io/post/goisforlovers/</guid><description><p>Hugo uses the excellent <a href="http://golang.org/">go</a> <a href="http://golang.org/pkg/html/template/">html/template</a> library forits template engine. It is an extremely lightweight engine that provides a verysmall amount of logic. In our experience that it is just the right amount oflogic to be able to create a good static website. If you have used othertemplate systems from different languages or frameworks you will find a lot ofsimilarities in go templates.</p><p>This document is a brief primer on using go templates. The <a href="http://golang.org/pkg/html/template/">go docs</a>provide more details.</p><h2 id="introduction-to-go-templates">Introduction to Go Templates</h2><p>Go templates provide an extremely simple template language. It adheres to thebelief that only the most basic of logic belongs in the template or view layer.One consequence of this simplicity is that go templates parse very quickly.</p><p>A unique characteristic of go templates is they are content aware. Variables andcontent will be sanitized depending on the context of where they are used. Moredetails can be found in the <a href="http://golang.org/pkg/html/template/">go docs</a>.</p><h2 id="basic-syntax">Basic Syntax</h2><p>Go lang templates are html files with the addition of variables andfunctions.</p><p><strong>Go variables and functions are accessible within {{ }}</strong></p><p>Accessing a predefined variable &ldquo;foo&rdquo;:</p><pre><code>{{ foo }}</code></pre><p><strong>Parameters are separated using spaces</strong></p><p>Calling the add function with input of 1, 2:</p><pre><code>{{ add 1 2 }}</code></pre><p><strong>Methods and fields are accessed via dot notation</strong></p><p>Accessing the Page Parameter &ldquo;bar&rdquo;</p><pre><code>{{ .Params.bar }}</code></pre><p><strong>Parentheses can be used to group items together</strong></p><pre><code>{{ if or (isset .Params &quot;alt&quot;) (isset .Params &quot;caption&quot;) }} Caption {{ end }}</code></pre><h2 id="variables">Variables</h2><p>Each go template has a struct (object) made available to it. In hugo eachtemplate is passed either a page or a node struct depending on which type ofpage you are rendering. More details are available on the<a href="https://omsf.io/layout/variables">variables</a> page.</p><p>A variable is accessed by referencing the variable name.</p><pre><code>&lt;title&gt;{{ .Title }}&lt;/title&gt;</code></pre><p>Variables can also be defined and referenced.</p><pre><code>{{ $address := &quot;123 Main St.&quot;}}{{ $address }}</code></pre><h2 id="functions">Functions</h2><p>Go template ship with a few functions which provide basic functionality. The gotemplate system also provides a mechanism for applications to extend theavailable functions with their own. <a href="https://omsf.io/layout/functions">Hugo templatefunctions</a> provide some additional functionality we believeare useful for building websites. Functions are called by using their namefollowed by the required parameters separated by spaces. Templatefunctions cannot be added without recompiling hugo.</p><p><strong>Example:</strong></p><pre><code>{{ add 1 2 }}</code></pre><h2 id="includes">Includes</h2><p>When including another template you will pass to it the data it will beable to access. To pass along the current context please remember toinclude a trailing dot. The templates location will always be starting atthe /layout/ directory within Hugo.</p><p><strong>Example:</strong></p><pre><code>{{ template &quot;chrome/header.html&quot; . }}</code></pre><h2 id="logic">Logic</h2><p>Go templates provide the most basic iteration and conditional logic.</p><h3 id="iteration">Iteration</h3><p>Just like in go, the go templates make heavy use of range to iterate overa map, array or slice. The following are different examples of how to userange.</p><p><strong>Example 1: Using Context</strong></p><pre><code>{{ range array }} {{ . }}{{ end }}</code></pre><p><strong>Example 2: Declaring value variable name</strong></p><pre><code>{{range $element := array}} {{ $element }}{{ end }}</code></pre><p><strong>Example 2: Declaring key and value variable name</strong></p><pre><code>{{range $index, $element := array}} {{ $index }} {{ $element }}{{ end }}</code></pre><h3 id="conditionals">Conditionals</h3><p>If, else, with, or, &amp; and provide the framework for handling conditionallogic in Go Templates. Like range, each statement is closed with <code>end</code>.</p><p>Go Templates treat the following values as false:</p><ul><li>false</li><li>0</li><li>any array, slice, map, or string of length zero</li></ul><p><strong>Example 1: If</strong></p><pre><code>{{ if isset .Params &quot;title&quot; }}&lt;h4&gt;{{ index .Params &quot;title&quot; }}&lt;/h4&gt;{{ end }}</code></pre><p><strong>Example 2: If -&gt; Else</strong></p><pre><code>{{ if isset .Params &quot;alt&quot; }} {{ index .Params &quot;alt&quot; }}{{else}} {{ index .Params &quot;caption&quot; }}{{ end }}</code></pre><p><strong>Example 3: And &amp; Or</strong></p><pre><code>{{ if and (or (isset .Params &quot;title&quot;) (isset .Params &quot;caption&quot;)) (isset .Params &quot;attr&quot;)}}</code></pre><p><strong>Example 4: With</strong></p><p>An alternative way of writing &ldquo;if&rdquo; and then referencing the same valueis to use &ldquo;with&rdquo; instead. With rebinds the context <code>.</code> within its scope,and skips the block if the variable is absent.</p><p>The first example above could be simplified as:</p><pre><code>{{ with .Params.title }}&lt;h4&gt;{{ . }}&lt;/h4&gt;{{ end }}</code></pre><p><strong>Example 5: If -&gt; Else If</strong></p><pre><code>{{ if isset .Params &quot;alt&quot; }} {{ index .Params &quot;alt&quot; }}{{ else if isset .Params &quot;caption&quot; }} {{ index .Params &quot;caption&quot; }}{{ end }}</code></pre><h2 id="pipes">Pipes</h2><p>One of the most powerful components of go templates is the ability tostack actions one after another. This is done by using pipes. Borrowedfrom unix pipes, the concept is simple, each pipeline&rsquo;s output becomes theinput of the following pipe.</p><p>Because of the very simple syntax of go templates, the pipe is essentialto being able to chain together function calls. One limitation of thepipes is that they only can work with a single value and that valuebecomes the last parameter of the next pipeline.</p><p>A few simple examples should help convey how to use the pipe.</p><p><strong>Example 1 :</strong></p><pre><code>{{ if eq 1 1 }} Same {{ end }}</code></pre><p>is the same as</p><pre><code>{{ eq 1 1 | if }} Same {{ end }}</code></pre><p>It does look odd to place the if at the end, but it does provide a goodillustration of how to use the pipes.</p><p><strong>Example 2 :</strong></p><pre><code>{{ index .Params &quot;disqus_url&quot; | html }}</code></pre><p>Access the page parameter called &ldquo;disqus_url&rdquo; and escape the HTML.</p><p><strong>Example 3 :</strong></p><pre><code>{{ if or (or (isset .Params &quot;title&quot;) (isset .Params &quot;caption&quot;)) (isset .Params &quot;attr&quot;)}}Stuff Here{{ end }}</code></pre><p>Could be rewritten as</p><pre><code>{{ isset .Params &quot;caption&quot; | or isset .Params &quot;title&quot; | or isset .Params &quot;attr&quot; | if }}Stuff Here{{ end }}</code></pre><h2 id="context-aka-the-dot">Context (aka. the dot)</h2><p>The most easily overlooked concept to understand about go templates is that {{ . }}always refers to the current context. In the top level of your template thiswill be the data set made available to it. Inside of a iteration it will havethe value of the current item. When inside of a loop the context has changed. .will no longer refer to the data available to the entire page. If you need toaccess this from within the loop you will likely want to set it to a variableinstead of depending on the context.</p><p><strong>Example:</strong></p><pre><code> {{ $title := .Site.Title }} {{ range .Params.tags }} &lt;li&gt; &lt;a href=&quot;{{ $baseurl }}/tags/{{ . | urlize }}&quot;&gt;{{ . }}&lt;/a&gt; - {{ $title }} &lt;/li&gt; {{ end }}</code></pre><p>Notice how once we have entered the loop the value of {{ . }} has changed. Wehave defined a variable outside of the loop so we have access to it from withinthe loop.</p><h1 id="hugo-parameters">Hugo Parameters</h1><p>Hugo provides the option of passing values to the template languagethrough the site configuration (for sitewide values), or through the metadata of each specific piece of content. You can define any values of anytype (supported by your front matter/config format) and use them howeveryou want to inside of your templates.</p><h2 id="using-content-page-parameters">Using Content (page) Parameters</h2><p>In each piece of content you can provide variables to be used by thetemplates. This happens in the <a href="https://omsf.io/content/front-matter">front matter</a>.</p><p>An example of this is used in this documentation site. Most of the pagesbenefit from having the table of contents provided. Sometimes the TOC justdoesn&rsquo;t make a lot of sense. We&rsquo;ve defined a variable in our front matterof some pages to turn off the TOC from being displayed.</p><p>Here is the example front matter:</p><pre><code>---title: &quot;Permalinks&quot;date: &quot;2013-11-18&quot;aliases: - &quot;/doc/permalinks/&quot;groups: [&quot;extras&quot;]groups_weight: 30notoc: true---</code></pre><p>Here is the corresponding code inside of the template:</p><pre><code> {{ if not .Params.notoc }} &lt;div id=&quot;toc&quot; class=&quot;well col-md-4 col-sm-6&quot;&gt; {{ .TableOfContents }} &lt;/div&gt; {{ end }}</code></pre><h2 id="using-site-config-parameters">Using Site (config) Parameters</h2><p>In your top-level configuration file (eg, <code>config.yaml</code>) you can define siteparameters, which are values which will be available to you in chrome.</p><p>For instance, you might declare:</p><div class="highlight"><pre style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-yaml" data-lang="yaml"><span style="color:#f92672">params</span>: <span style="color:#f92672">CopyrightHTML</span>: <span style="color:#e6db74">&#34;Copyright &amp;#xA9; 2013 John Doe. All Rights Reserved.&#34;</span> <span style="color:#f92672">TwitterUser</span>: <span style="color:#e6db74">&#34;spf13&#34;</span> <span style="color:#f92672">SidebarRecentLimit</span>: <span style="color:#ae81ff">5</span></code></pre></div><p>Within a footer layout, you might then declare a <code>&lt;footer&gt;</code> which is onlyprovided if the <code>CopyrightHTML</code> parameter is provided, and if it is given,you would declare it to be HTML-safe, so that the HTML entity is not escapedagain. This would let you easily update just your top-level config file eachJanuary 1st, instead of hunting through your templates.</p><pre><code>{{if .Site.Params.CopyrightHTML}}&lt;footer&gt;&lt;div class=&quot;text-center&quot;&gt;{{.Site.Params.CopyrightHTML | safeHtml}}&lt;/div&gt;&lt;/footer&gt;{{end}}</code></pre><p>An alternative way of writing the &ldquo;if&rdquo; and then referencing the same valueis to use &ldquo;with&rdquo; instead. With rebinds the context <code>.</code> within its scope,and skips the block if the variable is absent:</p><pre><code>{{with .Site.Params.TwitterUser}}&lt;span class=&quot;twitter&quot;&gt;&lt;a href=&quot;https://twitter.com/{{.}}&quot; rel=&quot;author&quot;&gt;&lt;img src=&quot;/images/twitter.png&quot; width=&quot;48&quot; height=&quot;48&quot; title=&quot;Twitter: {{.}}&quot; alt=&quot;Twitter&quot;&gt;&lt;/a&gt;&lt;/span&gt;{{end}}</code></pre><p>Finally, if you want to pull &ldquo;magic constants&rdquo; out of your layouts, you can doso, such as in this example:</p><pre><code>&lt;nav class=&quot;recent&quot;&gt; &lt;h1&gt;Recent Posts&lt;/h1&gt; &lt;ul&gt;{{range first .Site.Params.SidebarRecentLimit .Site.Recent}} &lt;li&gt;&lt;a href=&quot;{{.RelPermalink}}&quot;&gt;{{.Title}}&lt;/a&gt;&lt;/li&gt; {{end}}&lt;/ul&gt;&lt;/nav&gt;</code></pre></description></item><item><title>Getting Started with Hugo</title><link>https://omsf.io/post/hugoisforlovers/</link><pubDate>Wed, 02 Apr 2014 00:00:00 +0000</pubDate><guid>https://omsf.io/post/hugoisforlovers/</guid><description><h2 id="step-1-install-hugo">Step 1. Install Hugo</h2><p>Goto <a href="https://github.com/spf13/hugo/releases">hugo releases</a> and download theappropriate version for your os and architecture.</p><p>Save it somewhere specific as we will be using it in the next step.</p><p>More complete instructions are available at <a href="https://omsf.io/overview/installing/">installing hugo</a></p><h2 id="step-2-build-the-docs">Step 2. Build the Docs</h2><p>Hugo has its own example site which happens to also be the documentation siteyou are reading right now.</p><p>Follow the following steps:</p><ol><li>Clone the <a href="http://github.com/spf13/hugo">hugo repository</a></li><li>Go into the repo</li><li>Run hugo in server mode and build the docs</li><li>Open your browser to http://localhost:1313</li></ol><p>Corresponding pseudo commands:</p><pre><code>git clone https://github.com/spf13/hugocd hugo/path/to/where/you/installed/hugo server --source=./docs&gt; 29 pages created&gt; 0 tags index created&gt; in 27 ms&gt; Web Server is available at http://localhost:1313&gt; Press ctrl+c to stop</code></pre><p>Once you&rsquo;ve gotten here, follow along the rest of this page on your local build.</p><h2 id="step-3-change-the-docs-site">Step 3. Change the docs site</h2><p>Stop the Hugo process by hitting ctrl+c.</p><p>Now we are going to run hugo again, but this time with hugo in watch mode.</p><pre><code>/path/to/hugo/from/step/1/hugo server --source=./docs --watch&gt; 29 pages created&gt; 0 tags index created&gt; in 27 ms&gt; Web Server is available at http://localhost:1313&gt; Watching for changes in /Users/spf13/Code/hugo/docs/content&gt; Press ctrl+c to stop</code></pre><p>Open your <a href="http://vim.spf13.com">favorite editor</a> and change one of the sourcecontent pages. How about changing this very file to <em>fix the typo</em>. How about changing this very file to <em>fix the typo</em>.</p><p>Content files are found in <code>docs/content/</code>. Unless otherwise specified, filesare located at the same relative location as the url, in our case<code>docs/content/overview/quickstart.md</code>.</p><p>Change and save this file.. Notice what happened in your terminal.</p><pre><code>&gt; Change detected, rebuilding site&gt; 29 pages created&gt; 0 tags index created&gt; in 26 ms</code></pre><p>Refresh the browser and observe that the typo is now fixed.</p><p>Notice how quick that was. Try to refresh the site before it&rsquo;s finished building.. I double dare you.Having nearly instant feedback enables you to have your creativity flow without waiting for long builds.</p><h2 id="step-4-have-fun">Step 4. Have fun</h2><p>The best way to learn something is to play with it.</p></description></item><item><title>Migrate to Hugo from Jekyll</title><link>https://omsf.io/post/migrate-from-jekyll/</link><pubDate>Mon, 10 Mar 2014 00:00:00 +0000</pubDate><guid>https://omsf.io/post/migrate-from-jekyll/</guid><description><h2 id="move-static-content-to-static">Move static content to <code>static</code></h2><p>Jekyll has a rule that any directory not starting with <code>_</code> will be copied as-is to the <code>_site</code> output. Hugo keeps all static content under <code>static</code>. You should therefore move it all there.With Jekyll, something that looked like</p><pre><code>▾ &lt;root&gt;/ ▾ images/ logo.png</code></pre><p>should become</p><pre><code>▾ &lt;root&gt;/ ▾ static/ ▾ images/ logo.png</code></pre><p>Additionally, you&rsquo;ll want any files that should reside at the root (such as <code>CNAME</code>) to be moved to <code>static</code>.</p><h2 id="create-your-hugo-configuration-file">Create your Hugo configuration file</h2><p>Hugo can read your configuration as JSON, YAML or TOML. Hugo supports parameters custom configuration too. Refer to the <a href="https://omsf.io/overview/configuration/">Hugo configuration documentation</a> for details.</p><h2 id="set-your-configuration-publish-folder-to-_site">Set your configuration publish folder to <code>_site</code></h2><p>The default is for Jekyll to publish to <code>_site</code> and for Hugo to publish to <code>public</code>. If, like me, you have <a href="http://blog.blindgaenger.net/generate_github_pages_in_a_submodule.html"><code>_site</code> mapped to a git submodule on the <code>gh-pages</code> branch</a>, you&rsquo;ll want to do one of two alternatives:</p><ol><li><p>Change your submodule to point to map <code>gh-pages</code> to public instead of <code>_site</code> (recommended).</p><pre><code> git submodule deinit _site git rm _site git submodule add -b gh-pages [email protected]:your-username/your-repo.git public</code></pre></li><li><p>Or, change the Hugo configuration to use <code>_site</code> instead of <code>public</code>.</p><pre><code> { .. &quot;publishdir&quot;: &quot;_site&quot;, .. }</code></pre></li></ol><h2 id="convert-jekyll-templates-to-hugo-templates">Convert Jekyll templates to Hugo templates</h2><p>That&rsquo;s the bulk of the work right here. The documentation is your friend. You should refer to <a href="http://jekyllrb.com/docs/templates/">Jekyll&rsquo;s template documentation</a> if you need to refresh your memory on how you built your blog and <a href="https://omsf.io/layout/templates/">Hugo&rsquo;s template</a> to learn Hugo&rsquo;s way.</p><p>As a single reference data point, converting my templates for <a href="http://heyitsalex.net/">heyitsalex.net</a> took me no more than a few hours.</p><h2 id="convert-jekyll-plugins-to-hugo-shortcodes">Convert Jekyll plugins to Hugo shortcodes</h2><p>Jekyll has <a href="http://jekyllrb.com/docs/plugins/">plugins</a>; Hugo has <a href="https://omsf.io/doc/shortcodes/">shortcodes</a>. It&rsquo;s fairly trivial to do a port.</p><h3 id="implementation">Implementation</h3><p>As an example, I was using a custom <a href="https://github.com/alexandre-normand/alexandre-normand/blob/74bb12036a71334fdb7dba84e073382fc06908ec/_plugins/image_tag.rb"><code>image_tag</code></a> plugin to generate figures with caption when running Jekyll. As I read about shortcodes, I found Hugo had a nice built-in shortcode that does exactly the same thing.</p><p>Jekyll&rsquo;s plugin:</p><pre><code>module Jekyll class ImageTag &lt; Liquid::Tag @url = nil @caption = nil @class = nil @link = nil // Patterns IMAGE_URL_WITH_CLASS_AND_CAPTION = IMAGE_URL_WITH_CLASS_AND_CAPTION_AND_LINK = /(\w+)(\s+)((https?:\/\/|\/)(\S+))(\s+)&quot;(.*?)&quot;(\s+)-&gt;((https?:\/\/|\/)(\S+))(\s*)/i IMAGE_URL_WITH_CAPTION = /((https?:\/\/|\/)(\S+))(\s+)&quot;(.*?)&quot;/i IMAGE_URL_WITH_CLASS = /(\w+)(\s+)((https?:\/\/|\/)(\S+))/i IMAGE_URL = /((https?:\/\/|\/)(\S+))/i def initialize(tag_name, markup, tokens) super if markup =~ IMAGE_URL_WITH_CLASS_AND_CAPTION_AND_LINK @class = $1 @url = $3 @caption = $7 @link = $9 elsif markup =~ IMAGE_URL_WITH_CLASS_AND_CAPTION @class = $1 @url = $3 @caption = $7 elsif markup =~ IMAGE_URL_WITH_CAPTION @url = $1 @caption = $5 elsif markup =~ IMAGE_URL_WITH_CLASS @class = $1 @url = $3 elsif markup =~ IMAGE_URL @url = $1 end end def render(context) if @class source = &quot;&lt;figure class='#{@class}'&gt;&quot; else source = &quot;&lt;figure&gt;&quot; end if @link source += &quot;&lt;a href=\&quot;#{@link}\&quot;&gt;&quot; end source += &quot;&lt;img src=\&quot;#{@url}\&quot;&gt;&quot; if @link source += &quot;&lt;/a&gt;&quot; end source += &quot;&lt;figcaption&gt;#{@caption}&lt;/figcaption&gt;&quot; if @caption source += &quot;&lt;/figure&gt;&quot; source end endendLiquid::Template.register_tag('image', Jekyll::ImageTag)</code></pre><p>is written as this Hugo shortcode:</p><pre><code>&lt;!-- image --&gt;&lt;figure {{ with .Get &quot;class&quot; }}class=&quot;{{.}}&quot;{{ end }}&gt; {{ with .Get &quot;link&quot;}}&lt;a href=&quot;{{.}}&quot;&gt;{{ end }} &lt;img src=&quot;{{ .Get &quot;src&quot; }}&quot; {{ if or (.Get &quot;alt&quot;) (.Get &quot;caption&quot;) }}alt=&quot;{{ with .Get &quot;alt&quot;}}{{.}}{{else}}{{ .Get &quot;caption&quot; }}{{ end }}&quot;{{ end }} /&gt; {{ if .Get &quot;link&quot;}}&lt;/a&gt;{{ end }} {{ if or (or (.Get &quot;title&quot;) (.Get &quot;caption&quot;)) (.Get &quot;attr&quot;)}} &lt;figcaption&gt;{{ if isset .Params &quot;title&quot; }} {{ .Get &quot;title&quot; }}{{ end }} {{ if or (.Get &quot;caption&quot;) (.Get &quot;attr&quot;)}}&lt;p&gt; {{ .Get &quot;caption&quot; }} {{ with .Get &quot;attrlink&quot;}}&lt;a href=&quot;{{.}}&quot;&gt; {{ end }} {{ .Get &quot;attr&quot; }} {{ if .Get &quot;attrlink&quot;}}&lt;/a&gt; {{ end }} &lt;/p&gt; {{ end }} &lt;/figcaption&gt; {{ end }}&lt;/figure&gt;&lt;!-- image --&gt;</code></pre><h3 id="usage">Usage</h3><p>I simply changed:</p><pre><code>{% image full http://farm5.staticflickr.com/4136/4829260124_57712e570a_o_d.jpg &quot;One of my favorite touristy-type photos. I secretly waited for the good light while we were &quot;having fun&quot; and took this. Only regret: a stupid pole in the top-left corner of the frame I had to clumsily get rid of at post-processing.&quot; -&gt;http://www.flickr.com/photos/alexnormand/4829260124/in/set-72157624547713078/ %}</code></pre><p>to this (this example uses a slightly extended version named <code>fig</code>, different than the built-in <code>figure</code>):</p><pre><code>{{% fig class=&quot;full&quot; src=&quot;http://farm5.staticflickr.com/4136/4829260124_57712e570a_o_d.jpg&quot; title=&quot;One of my favorite touristy-type photos. I secretly waited for the good light while we were having fun and took this. Only regret: a stupid pole in the top-left corner of the frame I had to clumsily get rid of at post-processing.&quot; link=&quot;http://www.flickr.com/photos/alexnormand/4829260124/in/set-72157624547713078/&quot; %}}</code></pre><p>As a bonus, the shortcode named parameters are, arguably, more readable.</p><h2 id="finishing-touches">Finishing touches</h2><h3 id="fix-content">Fix content</h3><p>Depending on the amount of customization that was done with each post with Jekyll, this step will require more or less effort. There are no hard and fast rules here except that <code>hugo server --watch</code> is your friend. Test your changes and fix errors as needed.</p><h3 id="clean-up">Clean up</h3><p>You&rsquo;ll want to remove the Jekyll configuration at this point. If you have anything else that isn&rsquo;t used, delete it.</p><h2 id="a-practical-example-in-a-diff">A practical example in a diff</h2><p><a href="http://heyitsalex.net/">Hey, it&rsquo;s Alex</a> was migrated in less than a <em>father-with-kids day</em> from Jekyll to Hugo. You can see all the changes (and screw-ups) by looking at this <a href="https://github.com/alexandre-normand/alexandre-normand/compare/869d69435bd2665c3fbf5b5c78d4c22759d7613a...b7f6605b1265e83b4b81495423294208cc74d610">diff</a>.</p></description></item></channel></rss>