<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>GitHub Pages, Jekyll and Liquid on Much Ado About IT</title><link>https://it.knightnet.org.uk/kb/ghjekyll/</link><description>
Recent content about GitHub Pages, Jekyll and Liquid from Much Ado About IT |
Ramblings and rantings from IT Architect &amp; Designer, Julian Knight</description><generator>Hugo | gohugo.io | Theme twenty-sixteen</generator><language>en-gb</language><copyright>This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.</copyright><lastBuildDate>Mon, 24 Apr 2023 21:27:28 +0000</lastBuildDate><atom:link href="https://it.knightnet.org.uk/kb/ghjekyll/feed.xml" rel="self" type="application/rss+xml"/><item><title>Alternate static site generators to Jekyll</title><link>https://it.knightnet.org.uk/kb/ghjekyll/alternate-generators/</link><guid isPermaLink="true">https://it.knightnet.org.uk/kb/ghjekyll/alternate-generators/</guid><pubDate>Sun, 07 Jan 2018 22:00:00 +0000</pubDate><guid>https://it.knightnet.org.uk/kb/ghjekyll/alternate-generators/</guid><description><div>Jekyll is built on Ruby which is a pain to work with on Windows. It also doesn't match my chosen development language of JavaScript.
Here are some possible alternatives to Jekyll along with some strengths and weaknesses.</div><div>&lt;h2 id="golang-based">GoLang Based&lt;/h2>
&lt;ul>
&lt;li>
&lt;p>&lt;strong>Hugo&lt;/strong> - By far the best I&amp;rsquo;ve found out of all possibilities.
Although I don&amp;rsquo;t know Go, with Hugo, I only need to know a few basics and I don&amp;rsquo;t need to install it.&lt;/p>
&lt;ul>
&lt;li>✅ Can use YAML configuration and Front Matter like Jekyll does. (TOML also supported)&lt;/li>
&lt;li>✅ Simple initial set-up. A single executable is everything required.
Although Hugo is based on GoLang, it is packaged into a single executable for those who
don&amp;rsquo;t want or need to mess with Go itself.&lt;/li>
&lt;li>✅ Being able to easily run the build locally means full access to any error messages.&lt;/li>
&lt;li>✅ Executable has a development server built in.&lt;/li>
&lt;li>✅ Supported by a number of free, cloud-based deployment and CMS tools such as &lt;a href="https://www.netlify.com">Netlify&lt;/a> and &lt;a href="https://forestry.io">Forestry.IO&lt;/a>.&lt;/li>
&lt;li>✅ Easily handles both page- and post-based sites and combinations of both.&lt;/li>
&lt;li>✅ Active and helpful online community, regular updates.&lt;/li>
&lt;li>✅ Lots of automation hooks available such as multiple output types for generating alternative forms of data.&lt;/li>
&lt;li>✅ Simple integration of data-driven outputs.&lt;/li>
&lt;li>✅ Relatively simple to generate new themes. I built a new theme from scratch in less than a week of casual, out-of-hours writing.&lt;/li>
&lt;li>❌ Logic and flow can be complex to comprehend and reason about. Usually takes several readings of the documentation to work out how to do things if it isn&amp;rsquo;t immediately obvious.&lt;/li>
&lt;li>❌ Use of GoLang as the underlying code language results in distinctly non-standard structures for templates.&lt;/li>
&lt;li>❌ Some of the built-in templates and shortcodes are hard to understand without digging through the Hugo source code as they are poorly documented.&lt;/li>
&lt;li>❌ The speed of change of Hugo can result in documentation lagging behind the actual code. (Generally, the key contributors do a good job of keeping up though).&lt;/li>
&lt;/ul>
&lt;/li>
&lt;/ul>
&lt;h2 id="nodejs-based">Node.JS Based&lt;/h2>
&lt;p>All of this list use Node.JS to underpin the generation of static pages.&lt;/p>
&lt;ul>
&lt;li>
&lt;p>&lt;strong>Hexo&lt;/strong> - seemed promising at first sight. But a quick dig through the impressive list of addins reveals many of them to be out of date or not working properly.&lt;/p>
&lt;ul>
&lt;li>✅ Uses YAML configuration and Front Matter like Jekyll does.&lt;/li>
&lt;li>✅ Large list of plugins, all published on NPM.&lt;/li>
&lt;li>✅ Simple initial set-up.&lt;/li>
&lt;li>❌ Many plugins out-of-date or not fully working.&lt;/li>
&lt;li>❌ Many plugins very poorly documented or documented in Chinese.&lt;/li>
&lt;li>❌ Does not handle page-based sites well. Focussed on blogging (posts).&lt;/li>
&lt;li>❌ Needs plugins to provide more rounded capabilities.&lt;/li>
&lt;/ul>
&lt;/li>
&lt;li>
&lt;p>&lt;strong>Gatsby&lt;/strong> - Complex but comprehensive&lt;/p>
&lt;ul>
&lt;li>✅ &lt;a href="https://www.npmjs.com/browse/keyword/gatsby">Large list of plugins published on NPM&lt;/a> &amp;amp; &lt;a href="https://github.com/topics/gatsby">GitHub&lt;/a>.&lt;/li>
&lt;li>✅ Large number of contributors.&lt;/li>
&lt;li>✅ Powerful.&lt;/li>
&lt;li>❌ Complex to configure, lots of moving parts.&lt;/li>
&lt;li>❌ An awful lot of &amp;ldquo;magic&amp;rdquo; happens! While the file system is reasonably well arranged it is very hard to reason about the logic.&lt;/li>
&lt;/ul>
&lt;/li>
&lt;/ul></div></description><author>Julian Knight</author><category domain="https://it.knightnet.org.uk/categories/development">Development</category><category domain="https://it.knightnet.org.uk/tags/jekyll">Jekyll</category><category domain="https://it.knightnet.org.uk/tags/hugo">Hugo</category><category domain="https://it.knightnet.org.uk/tags/static-site-generators">Static Site Generators</category></item><item><title>Jekyll default variables</title><link>https://it.knightnet.org.uk/kb/ghjekyll/standard-attributes/</link><guid isPermaLink="true">https://it.knightnet.org.uk/kb/ghjekyll/standard-attributes/</guid><pubDate>Fri, 05 Jan 2018 22:00:00 +0000</pubDate><guid>https://it.knightnet.org.uk/kb/ghjekyll/standard-attributes/</guid><description><div>These are the default attributes (variables) that you get with each part of the Jekyll domain.</div><div>&lt;h2 id="front-matter">Front Matter&lt;/h2>
&lt;p>&lt;a href="https://jekyllrb.com/docs/frontmatter/">Front matter&lt;/a> is a simple YAML-based specification for adding metadata to Jekyll files. You can add it to pages, posts and collections. It goes at the top of the file between two lines containing &lt;code>---&lt;/code>.&lt;/p>
&lt;p>There are some standard front matter attributes:&lt;/p>
&lt;ul>
&lt;li>
&lt;p>&lt;code>layout&lt;/code> If set, this specifies the layout file to use. Use the layout file name without the file extension. Layout files must be placed in the &lt;code>_layouts&lt;/code> directory.&lt;/p>
&lt;p>Using &lt;code>null&lt;/code> will produce a file without using a layout file. However this is overridden if the file is a post/document and has a layout defined in the front matter defaults. Starting from version 3.5.0, using &lt;code>none&lt;/code> in a post/document will produce a file without using a layout file regardless of front matter defaults. Using &lt;code>none&lt;/code> in a page, however, will cause Jekyll to attempt to use a layout named &amp;ldquo;none&amp;rdquo;.&lt;/p>
&lt;/li>
&lt;li>
&lt;p>&lt;code>permalink&lt;/code> If you need your processed blog post URLs to be something other than the site-wide style (default /year/month/day/title.html), then you can set this variable and it will be used as the final URL.&lt;/p>
&lt;/li>
&lt;li>
&lt;p>&lt;code>published&lt;/code> Set to &lt;code>false&lt;/code> if you don’t want a specific &lt;em>post&lt;/em> to show up when the site is generated.&lt;/p>
&lt;/li>
&lt;li>
&lt;p>&lt;code>date&lt;/code> A date here overrides the date from the name of the &lt;em>post&lt;/em>. This can be used to ensure correct sorting of posts. A date is specified in the format YYYY-MM-DD HH:MM:SS +/-TTTT; hours, minutes, seconds, and timezone offset are optional.&lt;/p>
&lt;/li>
&lt;li>
&lt;p>&lt;code>category&lt;/code>, &lt;code>categories&lt;/code> Instead of placing &lt;em>posts&lt;/em> inside of folders, you can specify one or more categories that the post belongs to. When the site is generated the post will act as though it had been set with these categories normally. Categories (plural key) can be specified as a YAML list or a space-separated string.&lt;/p>
&lt;/li>
&lt;li>
&lt;p>&lt;code>tags&lt;/code> Similar to categories, one or multiple tags can be added to a &lt;em>post&lt;/em>. Also like categories, tags can be specified as a YAML list or a space-separated string.&lt;/p>
&lt;/li>
&lt;li>
&lt;p>&lt;code>title&lt;/code> While not specifically a standard, many templates make use of page/post titles&lt;/p>
&lt;/li>
&lt;li>
&lt;p>&lt;code>description&lt;/code> While not specifically a standard, many templates make use of page/post descriptions. Start the description value with &amp;ldquo;&amp;gt; &amp;quot; to enable multi-line text, indent the multi-line text.&lt;/p>
&lt;/li>
&lt;/ul>
&lt;h2 id="global-variables">Global Variables&lt;/h2>
&lt;ul>
&lt;li>&lt;code>site&lt;/code> Site wide information + configuration settings from _config.yml. See below for details.&lt;/li>
&lt;li>&lt;code>page&lt;/code> Page specific information + the YAML front matter. Custom variables set via the YAML Front Matter will be available here. See below for details.&lt;/li>
&lt;li>&lt;code>layout&lt;/code> Layout specific information + the YAML front matter. Custom variables set via the YAML Front Matter in layouts will be available here.&lt;/li>
&lt;li>&lt;code>content&lt;/code> &lt;em>In layout files&lt;/em>, the rendered content of the Post or Page being wrapped. &lt;strong>Not defined in Post or Page files&lt;/strong>.&lt;/li>
&lt;li>&lt;code>paginator&lt;/code> When the paginate configuration option is set, this variable becomes available for use. See &lt;a href="https://jekyllrb.com/docs/pagination/">Pagination&lt;/a> for details.&lt;/li>
&lt;/ul>
&lt;h2 id="sitexxxx-variables">site.xxxx Variables&lt;/h2>
&lt;ul>
&lt;li>
&lt;p>&lt;code>site.categories.[CATEGORY]&lt;/code> The list of all &lt;em>Posts&lt;/em> in category [CATEGORY].&lt;/p>
&lt;/li>
&lt;li>
&lt;p>&lt;code>site.collections&lt;/code> A list of all the &lt;em>collections&lt;/em>.&lt;/p>
&lt;/li>
&lt;li>
&lt;p>&lt;code>site.data&lt;/code> A list containing the data loaded from the YAML files located in the &lt;code>_data&lt;/code> directory.&lt;/p>
&lt;/li>
&lt;li>
&lt;p>&lt;code>site.documents&lt;/code> An array of all the &lt;em>documents&lt;/em> in every &lt;em>collection&lt;/em>. Each entry contains the &lt;code>page.&lt;/code> properties for the document. To get a list of all collection documents &lt;strong>and&lt;/strong> pages: &lt;code>{{ site.pages | concat: site.documents }}&lt;/code>&lt;/p>
&lt;/li>
&lt;li>
&lt;p>&lt;code>site.html_files&lt;/code> A subset of &lt;code>site.static_files&lt;/code> listing those which end in &lt;code>.html&lt;/code>.&lt;/p>
&lt;/li>
&lt;li>
&lt;p>&lt;code>site.html_pages&lt;/code> A subset of &lt;code>site.pages&lt;/code> listing those which end in &lt;code>.html&lt;/code>.&lt;/p>
&lt;/li>
&lt;li>
&lt;p>&lt;code>site.pages&lt;/code> An array of all &lt;em>Pages&lt;/em>. Each entry contains the &lt;code>page.&lt;/code> properties for the page&lt;/p>
&lt;/li>
&lt;li>
&lt;p>&lt;code>site.posts&lt;/code> A reverse chronological list of all &lt;em>Posts&lt;/em>.&lt;/p>
&lt;/li>
&lt;li>
&lt;p>&lt;code>site.related_posts&lt;/code> If the page being processed is a &lt;em>Post&lt;/em>, this contains a list of up to ten related Posts. By default, these are the ten most recent posts. For high quality but slow to compute results, run the jekyll command with the &amp;ndash;lsi (latent semantic indexing) option. Also note GitHub Pages does not support the lsi option when generating sites.&lt;/p>
&lt;/li>
&lt;li>
&lt;p>&lt;code>site.static_files&lt;/code> A list of all &lt;em>static files&lt;/em> (i.e. files not processed by Jekyll&amp;rsquo;s converters or the Liquid renderer). Each file has three properties: path, modified_time and extname.&lt;/p>
&lt;/li>
&lt;li>
&lt;p>&lt;code>site.tags.[TAG]&lt;/code> The list of all &lt;em>Posts&lt;/em> with tag [TAG].&lt;/p>
&lt;/li>
&lt;li>
&lt;p>&lt;code>site.time&lt;/code> The current time (when you run the jekyll command).&lt;/p>
&lt;/li>
&lt;li>
&lt;p>&lt;code>site.url&lt;/code> Contains the url of your site as it is configured in the _config.yml. For example, if you have url: &lt;code>http://mysite.com&lt;/code> in your configuration file, then it will be accessible in Liquid as site.url. For the development environment there is an exception, if you are running jekyll serve in a development environment site.url will be set to the value of host, port, and SSL-related options. This defaults to url: &lt;code>http://localhost:4000&lt;/code>.&lt;/p>
&lt;/li>
&lt;li>
&lt;p>&lt;code>site.[CONFIGURATION_DATA]&lt;/code> All the variables set via the command line and your _config.yml are available through the site variable. For example, if you have foo: bar in your configuration file, then it will be accessible in Liquid as site.foo. Jekyll does not parse changes to _config.yml in watch mode, you must restart Jekyll to see changes to variables.&lt;/p>
&lt;/li>
&lt;/ul>
&lt;h3 id="sitedocuments-and-sitepages">site.documents and site.pages&lt;/h3>
&lt;p>Both of these are arrays of objects. The objects contain the following properties.&lt;/p>
&lt;ul>
&lt;li>categories&lt;/li>
&lt;li>collection&lt;/li>
&lt;li>comments&lt;/li>
&lt;/ul>
&lt;h2 id="pagexxxx-variables">page.xxxx Variables&lt;/h2>
&lt;ul>
&lt;li>
&lt;p>&lt;code>page.content&lt;/code> The content of the Page, rendered or un-rendered depending upon what Liquid is being processed and what page is.&lt;/p>
&lt;/li>
&lt;li>
&lt;p>&lt;code>page.title&lt;/code> The title of the Page (if set)&lt;/p>
&lt;/li>
&lt;li>
&lt;p>&lt;code>page.excerpt&lt;/code> The un-rendered excerpt of the Page.&lt;/p>
&lt;/li>
&lt;li>
&lt;p>&lt;code>page.url&lt;/code> The URL of the Post without the domain, but with a leading slash, e.g. /2008/12/14/my-post.html&lt;/p>
&lt;/li>
&lt;li>
&lt;p>&lt;code>page.date&lt;/code> The Date assigned to the Post. This can be overridden in a Post’s front matter by specifying a new date/time in the format YYYY-MM-DD HH:MM:SS (assuming UTC), or YYYY-MM-DD HH:MM:SS +/-TTTT (to specify a time zone using an offset from UTC. e.g. 2008-12-14 10:30:00 +0900).&lt;/p>
&lt;/li>
&lt;li>
&lt;p>&lt;code>page.id&lt;/code> An identifier unique to a document in a &lt;em>Collection&lt;/em> or a &lt;em>Post&lt;/em> (useful in RSS feeds). e.g. /2008/12/14/my-post /my-collection/my-document&lt;/p>
&lt;/li>
&lt;li>
&lt;p>&lt;code>page.categories&lt;/code> The list of categories to which this &lt;em>post&lt;/em> belongs. Categories are derived from the directory structure above the _posts directory. For example, a post at /work/code/_posts/2008-12-24-closures.md would have this field set to [&amp;lsquo;work&amp;rsquo;, &amp;lsquo;code&amp;rsquo;]. These can also be specified in the YAML Front Matter. Available to collection documents but not to Pages(?).&lt;/p>
&lt;/li>
&lt;li>
&lt;p>&lt;code>page.tags&lt;/code> The list of tags to which this post belongs. These can be specified in the YAML Front Matter.&lt;/p>
&lt;/li>
&lt;li>
&lt;p>&lt;code>page.path&lt;/code> The path to the &lt;em>raw&lt;/em> post, page or collection document. Example usage: Linking back to the page or post’s source on GitHub. This can be overridden in the YAML Front Matter.&lt;/p>
&lt;/li>
&lt;li>
&lt;p>&lt;code>page.next&lt;/code> The next post relative to the position of the current post in site.posts. Returns nil for the last entry.&lt;/p>
&lt;/li>
&lt;li>
&lt;p>&lt;code>page.previous&lt;/code> The previous post relative to the position of the current post in site.posts. Returns nil for the first entry.&lt;/p>
&lt;/li>
&lt;/ul>
&lt;h3 id="these-are-_not_-described-in-the-jekyll-docs-section-on-pages-but-are-certainly-available">These are &lt;em>not&lt;/em> described in the Jekyll docs section on Pages but are certainly available&lt;/h3>
&lt;ul>
&lt;li>&lt;code>dir&lt;/code> - Only available to &lt;em>pages&lt;/em>, not to collection documents.&lt;/li>
&lt;li>&lt;code>name&lt;/code> - Only available to &lt;em>pages&lt;/em>, not to collection documents. Source name of document.&lt;/li>
&lt;/ul>
&lt;h2 id="posts">Posts&lt;/h2>
&lt;ul>
&lt;li>categories&lt;/li>
&lt;li>tags&lt;/li>
&lt;li>content&lt;/li>
&lt;li>date&lt;/li>
&lt;li>dir&lt;/li>
&lt;li>draft?&lt;/li>
&lt;li>excerpt&lt;/li>
&lt;li>excerpt_separator&lt;/li>
&lt;li>id&lt;/li>
&lt;li>next previous&lt;/li>
&lt;li>path&lt;/li>
&lt;li>title&lt;/li>
&lt;li>url&lt;/li>
&lt;/ul>
&lt;h2 id="collection-document-variables">Collection document variables&lt;/h2>
&lt;ul>
&lt;li>&lt;code>page.categories&lt;/code>&lt;/li>
&lt;li>&lt;code>page.collection&lt;/code>&lt;/li>
&lt;li>&lt;code>page.comments&lt;/code>&lt;/li>
&lt;li>&lt;code>page.content&lt;/code>&lt;/li>
&lt;li>&lt;code>page.draft&lt;/code>&lt;/li>
&lt;li>&lt;code>page.excerpt&lt;/code>&lt;/li>
&lt;li>&lt;code>page.id&lt;/code>&lt;/li>
&lt;li>&lt;code>page.layout&lt;/code>&lt;/li>
&lt;li>&lt;code>page.next&lt;/code>&lt;/li>
&lt;li>&lt;code>page.output&lt;/code> - rendered output of collection document&lt;/li>
&lt;li>&lt;code>page.path&lt;/code>&lt;/li>
&lt;li>&lt;code>page.previous&lt;/code>&lt;/li>
&lt;li>&lt;code>page.relative_path&lt;/code>&lt;/li>
&lt;li>&lt;code>url&lt;/code>&lt;/li>
&lt;li>&lt;code>layout&lt;/code>&lt;/li>
&lt;/ul>
&lt;h2 id="collections-variables-sitecollectionsxxxx">Collections variables (site.collections.xxxx)&lt;/h2>
&lt;h2 id="files">Files&lt;/h2>
&lt;p>Files can be accessed via &lt;code>site.static_files&lt;/code>. They are typically kept in the &lt;code>assets&lt;/code> folder.&lt;/p>
&lt;ul>
&lt;li>&lt;code>path&lt;/code> - The relative path to the file, e.g. &lt;code>/assets/img/image.jpg&lt;/code>&lt;/li>
&lt;li>&lt;code>modified_time&lt;/code> - The &lt;code>Time&lt;/code> the file was last modified, e.g. &lt;code>2016-04-01 16:35:26 +0200&lt;/code>&lt;/li>
&lt;li>&lt;code>name&lt;/code> - The string name of the file e.g. &lt;code>image.jpg&lt;/code> for &lt;code>image.jpg&lt;/code>&lt;/li>
&lt;li>&lt;code>basename&lt;/code> - The string basename of the file e.g. &lt;code>image&lt;/code> for &lt;code>image.jpg&lt;/code>&lt;/li>
&lt;li>&lt;code>extname&lt;/code> - The extension name for the file, e.g. &lt;code>.jpg&lt;/code> for &lt;code>image.jpg&lt;/code>&lt;/li>
&lt;/ul>
&lt;p>While front-matter variables can&amp;rsquo;t be added directly to files, they can be made accessible via the &lt;code>defaults&lt;/code> section of &lt;code>_config.yml&lt;/code>.&lt;/p>
&lt;h2 id="includes-files-variable">Includes files variable&lt;/h2>
&lt;p>When using the &lt;code>_includes&lt;/code> folder, any include files that allow parameters gain an &lt;code>include&lt;/code> object variable.&lt;/p>
&lt;p>The object will contain a key for each variable passed as a parameter in the calling page.&lt;/p>
&lt;p>Example - in the calling page: &lt;code>{% include note.html content=&amp;quot;This is my sample note.&amp;quot; %}&lt;/code> and in the include page: &lt;code>{{ include.content }}&lt;/code>&lt;/p>
&lt;p>If you need to send the contents of Jekyll/Liquid variables to the included page, you can do so directly. For example: &lt;code>{% include note.html title=page.title %}&lt;/code> - note the lack of quotes.&lt;/p>
&lt;h2 id="github-metadata-sitegithubxxxx">Github Metadata (site.github.xxxx)&lt;/h2>
&lt;ul>
&lt;li>&lt;code>versions&lt;/code> object containing version numbers for Jekyll, Ruby and other plugins (e.g. keys: jekyll, kramdown, liquid, maruku, rdiscount, redcarpet, RedCloth, jemoji, jekyll-mentions, jekyll-redirect-from, jekyll-sitemap, github-pages, ruby)&lt;/li>
&lt;li>&lt;code>hostname&lt;/code> &amp;ldquo;github.com&amp;rdquo;&lt;/li>
&lt;/ul>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-yaml" data-lang="yaml">&lt;span class="line">&lt;span class="cl">&lt;span class="nt">pages_hostname&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="s2">&amp;#34;github.io&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="nt">api_url&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="s2">&amp;#34;https://api.github.com&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="nt">help_url&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="s2">&amp;#34;https://help.github.com&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="nt">environment&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="s2">&amp;#34;dotcom&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="nt">pages_env&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="s2">&amp;#34;dotcom&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="nt">public_repositories&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="p">[&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="l">Repository Objects ],&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="nt">organization_members&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="p">[&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="l">User Objects ],&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="nt">build_revision&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="s2">&amp;#34;cbd866ebf142088896cbe71422b949de7f864bce&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="nt">project_title&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="s2">&amp;#34;metadata-example&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="nt">project_tagline&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="s2">&amp;#34;A GitHub Pages site to showcase repository metadata&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="nt">owner_name&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="s2">&amp;#34;github&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="nt">owner_url&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="s2">&amp;#34;https://github.com/github&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="nt">owner_gravatar_url&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="s2">&amp;#34;https://github.com/github.png&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="nt">repository_url&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="s2">&amp;#34;https://github.com/github/metadata-example&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="nt">repository_nwo&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="s2">&amp;#34;github/metadata-example&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="nt">repository_name&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="s2">&amp;#34;metadata-example&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="nt">zip_url&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="s2">&amp;#34;https://github.com/github/metadata-example/zipball/gh-pages&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="nt">tar_url&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="s2">&amp;#34;https://github.com/github/metadata-example/tarball/gh-pages&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="nt">clone_url&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="s2">&amp;#34;https://github.com/github/metadata-example.git&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="nt">releases_url&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="s2">&amp;#34;https://github.com/github/metadata-example/releases&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="nt">issues_url&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="s2">&amp;#34;https://github.com/github/metadata-example/issues&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="nt">wiki_url&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="s2">&amp;#34;https://github.com/github/metadata-example/wiki&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="nt">language&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="kc">null&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="nt">is_user_page&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="kc">false&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="nt">is_project_page&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="kc">true&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="nt">show_downloads&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="kc">true&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="nt">url&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="s2">&amp;#34;http://username.github.io/metadata-example&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="l">// (or the CNAME)&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="nt">baseurl&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="s2">&amp;#34;/metadata-example&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="nt">contributors&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="p">[&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="l">User Objects ],&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="nt">releases&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="p">[&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="l">Release Objects ],&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="nt">latest_release&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="p">[&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="l">Release Object ],&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="nt">private&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="kc">false&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="nt">license&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">key&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="s2">&amp;#34;mit&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">name&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="s2">&amp;#34;MIT License&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">spdx_id&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="s2">&amp;#34;MIT&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">url&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="s2">&amp;#34;https://api.github.com/licenses/mit&amp;#34;&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="nt">source&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">branch&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="s2">&amp;#34;gh-pages&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">path&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="s2">&amp;#34;/&amp;#34;&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-yaml" data-lang="yaml">&lt;span class="line">&lt;span class="cl">&lt;span class="nt">defaults&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>- &lt;span class="nt">scope&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">path&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="s2">&amp;#34;assets/img&amp;#34;&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">values&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">image&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="kc">true&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div></div></description><author>Julian Knight</author><category domain="https://it.knightnet.org.uk/categories/development">Development</category><category domain="https://it.knightnet.org.uk/tags/jekyll">Jekyll</category><category domain="https://it.knightnet.org.uk/tags/static-site-generators">Static Site Generators</category></item><item><title>List of problems and issues with Jekyll and GitHub Pages</title><link>https://it.knightnet.org.uk/kb/ghjekyll/github-pages-issues/</link><guid isPermaLink="true">https://it.knightnet.org.uk/kb/ghjekyll/github-pages-issues/</guid><pubDate>Fri, 05 Jan 2018 17:05:00 +0000</pubDate><guid>https://it.knightnet.org.uk/kb/ghjekyll/github-pages-issues/</guid><description><div>While sites generated using GitHub pages can use Jekyll to enhance them, there are some limitations and, it seems, a number of problems.</div><div>&lt;h2 id="advantages-not-matched-by-alternatives">Advantages (not matched by alternatives)&lt;/h2>
&lt;ul>
&lt;li>
&lt;p>The Jekyll build process runs on the GitHub back end, no need for the horrible (on Windows anyway) installation of Ruby and Jekyll. (UPDATE: See Hugo alternative for a better alternative).&lt;/p>
&lt;/li>
&lt;li>
&lt;p>GitHub provides an existing set of data about the owning organisation/person and their repos.&lt;/p>
&lt;/li>
&lt;/ul>
&lt;p>Sorry, can&amp;rsquo;t think of any others that aren&amp;rsquo;t matched by alternative tools.&lt;/p>
&lt;h2 id="github-pages-issues">GitHub Pages Issues&lt;/h2>
&lt;ul>
&lt;li>
&lt;p>Build failures generate error messages that are worse than useless. Often not even identifying the page that the build failed on.&lt;/p>
&lt;p>Hint: Connect the repo to cloundcannon.com - it will do builds and give more detailed error messages.&lt;/p>
&lt;/li>
&lt;li>
&lt;p>Looks like there may be some issues when creating pages directly from the GitHub web interface. I&amp;rsquo;ve managed to create several pages that show inconsistent metadata - I suspect they were all created via the web interface first. See &lt;a href="https://github.com/jekyll/jekyll/issues/6661">Issue #6661&lt;/a> and &lt;a href="https://totallyinformation.github.io/github-pages/test">this test page&lt;/a>. You can see that the test page is not able to reference its frontmatter metadata.&lt;/p>
&lt;/li>
&lt;li>
&lt;p>Jekyll uses Kramdown to render markdown files. This does not quite match the default GFM format. While this is improving, the version used is typically behind the current one, often by a fair margin.&lt;/p>
&lt;/li>
&lt;/ul>
&lt;h2 id="minima-theme-issues">Minima Theme Issues&lt;/h2>
&lt;p>While the Minima theme is pretty good, it has a few issues of its own.&lt;/p>
&lt;ul>
&lt;li>
&lt;p>The documentation states that all you need to do to enable Disqus is to add your shortcode to &lt;code>_config.yml&lt;/code>. However, this is not quite correct as Disqus in only added to posts and not to pages or collection documents, nor to the home page.&lt;/p>
&lt;/li>
&lt;li>
&lt;p>The main menu does not work quite as expected. If a page doesn&amp;rsquo;t have a title, it is ignored, not terribly safe an assumption since an xml document might have a title but shouldn&amp;rsquo;t be shown or perhaps a page needed in the menu doesn&amp;rsquo;t have/need a title. Also, it excludes collection documents which isn&amp;rsquo;t too helpful if trying to switch to collections for better content management. A better selection would be {%raw%}&lt;code>site.pages | concat: site.documents | where: &amp;quot;layout&amp;quot;,&amp;quot;page&amp;quot;&lt;/code>{%endraw%} or something similar.&lt;/p>
&lt;/li>
&lt;/ul>
&lt;h2 id="jekyll-issues">Jekyll Issues&lt;/h2>
&lt;p>This list is about Jekyll failings, not specific to GitHub Pages.&lt;/p>
&lt;ul>
&lt;li>
&lt;p>The sort filter does not work correctly. I have some code that includes &lt;code>{% for item in collection | sort: &amp;quot;title&amp;quot; %}&lt;/code> but several entries are incorrectly sorted.&lt;/p>
&lt;/li>
&lt;li>
&lt;p>Jekyll documentation is, in my opinion, poor. Information is badly spread between pages. For example, trying to find a comprehensive list of variable filters that actually work with Jekyll is difficult. Some documentation is left up to the core documentation of the Liquid templating engine. However, while that is comprehensive, it applies to the use of Liquid in its original environment, not everything works in Jekyll.&lt;/p>
&lt;/li>
&lt;li>
&lt;p>There are too many inconsistent differences between different parts of Jekyll. For example, why are there so many differences in the schema definitions for Pages, Posts and Collection Documents?&lt;/p>
&lt;/li>
&lt;li>
&lt;p>In the &lt;code>page&lt;/code> object, not all properties are set as one might expect. &lt;code>page.date&lt;/code> for example is not set unless you create it manually in the frontmatter. Again, not all page properties actually apply to &amp;ldquo;Pages&amp;rdquo;, some only apply to posts or collection documents. Highly confusing.&lt;/p>
&lt;/li>
&lt;li>
&lt;p>In variable filters, the &lt;code>:&lt;/code> is an unnecessary source of bugs. It serves no real purpose, a simple space would be sufficient.&lt;/p>
&lt;/li>
&lt;/ul></div></description><author>Julian Knight</author><category domain="https://it.knightnet.org.uk/categories/development">Development</category><category domain="https://it.knightnet.org.uk/tags/jekyll">Jekyll</category><category domain="https://it.knightnet.org.uk/tags/static-site-generators">Static Site Generators</category><category domain="https://it.knightnet.org.uk/tags/github">GitHub</category><category domain="https://it.knightnet.org.uk/tags/github-pages">GitHub Pages</category></item><item><title>How to generate a list of collection documents</title><link>https://it.knightnet.org.uk/kb/ghjekyll/list-collection/</link><guid isPermaLink="true">https://it.knightnet.org.uk/kb/ghjekyll/list-collection/</guid><pubDate>Fri, 05 Jan 2018 17:00:00 +0000</pubDate><guid>https://it.knightnet.org.uk/kb/ghjekyll/list-collection/</guid><description><div>The following code automatically generates a list of collection documents.
It assumes that the collection uses `output: true` and optionally includes a collection title and description defined in the `_config.yml` configuration file.</div><div>&lt;h3 id="collection_doc_listerhtml-include-file">collection_doc_lister.html include file&lt;/h3>
&lt;p>Create this as a file in your _includes folder&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-html" data-lang="html">&lt;span class="line">&lt;span class="cl">{% assign colName = include.collection %}
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">{% assign col = site.collections | where: &amp;#39;label&amp;#39;,colName | first %}
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="p">&amp;lt;&lt;/span>&lt;span class="nt">div&lt;/span> &lt;span class="na">class&lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="s">&amp;#34;collection-list&amp;#34;&lt;/span>&lt;span class="p">&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">{% if col %}
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> {% assign collection = site[col.label] %}
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> {% assign colTitle = col.title | default: colName | replace: &amp;#39;_&amp;#39;,&amp;#39; &amp;#39; | replace: &amp;#39;-&amp;#39;, &amp;#39; &amp;#39; | capitalize %}
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">&amp;lt;&lt;/span>&lt;span class="nt">h2&lt;/span>&lt;span class="p">&amp;gt;&amp;lt;&lt;/span>&lt;span class="nt">a&lt;/span> &lt;span class="na">href&lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="s">&amp;#34;{{ colName | prefix: &amp;#39;/&amp;#39; | append: &amp;#39;/&amp;#39; }}&amp;#34;&lt;/span>&lt;span class="p">&amp;gt;&lt;/span>{{ colTitle }}&lt;span class="p">&amp;lt;/&lt;/span>&lt;span class="nt">a&lt;/span>&lt;span class="p">&amp;gt;&amp;lt;/&lt;/span>&lt;span class="nt">h2&lt;/span>&lt;span class="p">&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> {% if col.description %}&lt;span class="p">&amp;lt;&lt;/span>&lt;span class="nt">p&lt;/span>&lt;span class="p">&amp;gt;&lt;/span>{{ col.description }}&lt;span class="p">&amp;lt;/&lt;/span>&lt;span class="nt">p&lt;/span>&lt;span class="p">&amp;gt;&lt;/span>{% endif %}
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">&amp;lt;&lt;/span>&lt;span class="nt">div&lt;/span>&lt;span class="p">&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">&amp;lt;&lt;/span>&lt;span class="nt">ul&lt;/span>&lt;span class="p">&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> {% for item in collection | sort: &amp;#34;title&amp;#34; %}
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">&amp;lt;&lt;/span>&lt;span class="nt">li&lt;/span>&lt;span class="p">&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> {% assign mytitle = item.title | default: item.url %}
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">&amp;lt;&lt;/span>&lt;span class="nt">a&lt;/span> &lt;span class="na">href&lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="s">&amp;#34;{{ item.url }}&amp;#34;&lt;/span>&lt;span class="p">&amp;gt;&lt;/span>{{ mytitle | replace:&amp;#39;_&amp;#39;,&amp;#39; &amp;#39; | replace:&amp;#39;-&amp;#39;,&amp;#39; &amp;#39; }}&lt;span class="p">&amp;lt;/&lt;/span>&lt;span class="nt">a&lt;/span>&lt;span class="p">&amp;gt;&lt;/span> {% if item.date %}({{ item.date | date: &amp;#34;%Y-%m-%d %H:%M&amp;#34; }}){% endif %}
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">&amp;lt;&lt;/span>&lt;span class="nt">p&lt;/span>&lt;span class="p">&amp;gt;&lt;/span>{% if item.description %}
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> {{ item.description }}
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> {% else %}
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> {{ item.excerpt | strip_html }}
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> {% endif %}&lt;span class="p">&amp;lt;/&lt;/span>&lt;span class="nt">p&lt;/span>&lt;span class="p">&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">&amp;lt;/&lt;/span>&lt;span class="nt">li&lt;/span>&lt;span class="p">&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> {% endfor %}
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">&amp;lt;/&lt;/span>&lt;span class="nt">ul&lt;/span>&lt;span class="p">&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">&amp;lt;/&lt;/span>&lt;span class="nt">div&lt;/span>&lt;span class="p">&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">{% else %}
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">&amp;lt;&lt;/span>&lt;span class="nt">p&lt;/span>&lt;span class="p">&amp;gt;&lt;/span>There is no site collection called &lt;span class="p">&amp;lt;&lt;/span>&lt;span class="nt">code&lt;/span>&lt;span class="p">&amp;gt;&lt;/span>{{ colName }}&lt;span class="p">&amp;lt;/&lt;/span>&lt;span class="nt">code&lt;/span>&lt;span class="p">&amp;gt;&lt;/span>.&lt;span class="p">&amp;lt;/&lt;/span>&lt;span class="nt">p&lt;/span>&lt;span class="p">&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">{% endif %}
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="p">&amp;lt;/&lt;/span>&lt;span class="nt">div&lt;/span>&lt;span class="p">&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;h3 id="using-the-include-file">Using the include file&lt;/h3>
&lt;p>To use, place the following code wherever you want a list of the output files - such as the index.md for the collection folder.&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-markdown" data-lang="markdown">&lt;span class="line">&lt;span class="cl">{% include collection_doc_lister.html collection=&amp;#39;github-pages&amp;#39; %}
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>Note the reference to the collection name which is passed to the include file.&lt;/p></div></description><author>Julian Knight</author><category domain="https://it.knightnet.org.uk/categories/development">Development</category><category domain="https://it.knightnet.org.uk/tags/jekyll">Jekyll</category><category domain="https://it.knightnet.org.uk/tags/static-site-generators">Static Site Generators</category></item><item><title>How to generate a list of pages in a given folder</title><link>https://it.knightnet.org.uk/kb/ghjekyll/list-folder-pages/</link><guid isPermaLink="true">https://it.knightnet.org.uk/kb/ghjekyll/list-folder-pages/</guid><pubDate>Fri, 05 Jan 2018 17:00:00 +0000</pubDate><guid>https://it.knightnet.org.uk/kb/ghjekyll/list-folder-pages/</guid><description><div>The following code automatically generates a list of pages that exist in a given folder.</div><div>&lt;h3 id="page_listerhtml-include-file">page_lister.html include file&lt;/h3>
&lt;p>Create this as a file in your _includes folder&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-html" data-lang="html">&lt;span class="line">&lt;span class="cl">{% assign dir = include.dir | default: page.dir %}
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="p">&amp;lt;&lt;/span>&lt;span class="nt">div&lt;/span> &lt;span class="na">class&lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="s">&amp;#34;page-list&amp;#34;&lt;/span>&lt;span class="p">&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">{% assign mypages = site.pages | where:&amp;#34;dir&amp;#34;, dir | where_exp:&amp;#34;item&amp;#34;, &amp;#34;item.name != page.name&amp;#34; %}
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">{% if mypages.length &amp;gt; 0 %}
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">&amp;lt;&lt;/span>&lt;span class="nt">ul&lt;/span>&lt;span class="p">&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> {% for item in mypages | sort: &amp;#34;title&amp;#34; %}
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> {% assign mytitle = item.title | default: item.url %}
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">&amp;lt;&lt;/span>&lt;span class="nt">li&lt;/span>&lt;span class="p">&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">&amp;lt;&lt;/span>&lt;span class="nt">a&lt;/span> &lt;span class="na">href&lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="s">&amp;#34;{{ item.url }}&amp;#34;&lt;/span>&lt;span class="p">&amp;gt;&lt;/span>{{ mytitle | replace:&amp;#39;_&amp;#39;,&amp;#39; &amp;#39; | replace:&amp;#39;-&amp;#39;,&amp;#39; &amp;#39; }}&lt;span class="p">&amp;lt;/&lt;/span>&lt;span class="nt">a&lt;/span>&lt;span class="p">&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">&amp;lt;&lt;/span>&lt;span class="nt">p&lt;/span>&lt;span class="p">&amp;gt;&lt;/span>{% if item.description %}
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> {{ item.description }}
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> {% else %}
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> {{ item.excerpt | strip_html }}
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> {% endif %}&lt;span class="p">&amp;lt;/&lt;/span>&lt;span class="nt">p&lt;/span>&lt;span class="p">&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">&amp;lt;/&lt;/span>&lt;span class="nt">li&lt;/span>&lt;span class="p">&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> {% endfor %}
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">&amp;lt;/&lt;/span>&lt;span class="nt">ul&lt;/span>&lt;span class="p">&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">{% else %}
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">&amp;lt;&lt;/span>&lt;span class="nt">p&lt;/span>&lt;span class="p">&amp;gt;&lt;/span>No pages found in folder &lt;span class="p">&amp;lt;&lt;/span>&lt;span class="nt">code&lt;/span>&lt;span class="p">&amp;gt;&lt;/span>{{ dir }}&lt;span class="p">&amp;lt;/&lt;/span>&lt;span class="nt">code&lt;/span>&lt;span class="p">&amp;gt;&lt;/span>.&lt;span class="p">&amp;lt;/&lt;/span>&lt;span class="nt">p&lt;/span>&lt;span class="p">&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">{% endif %}
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="p">&amp;lt;/&lt;/span>&lt;span class="nt">div&lt;/span>&lt;span class="p">&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;h3 id="using-the-include-file">Using the include file&lt;/h3>
&lt;p>To use, place the following code wherever you want a list of the output files - such as the index.md for the collection folder.&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-markdown" data-lang="markdown">&lt;span class="line">&lt;span class="cl">{% include page_lister.html dir=&amp;#34;/vscode/&amp;#34; %}
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>Note the reference to the folder directory name (with leading/trailing slashes as per the &lt;code>.dir&lt;/code> attribute) which is passed to the include file.&lt;/p></div></description><author>Julian Knight</author><category domain="https://it.knightnet.org.uk/categories/development">Development</category><category domain="https://it.knightnet.org.uk/tags/jekyll">Jekyll</category><category domain="https://it.knightnet.org.uk/tags/static-site-generators">Static Site Generators</category></item><item><title>Jekyll and Liquid reference information</title><link>https://it.knightnet.org.uk/kb/ghjekyll/reference-information/</link><guid isPermaLink="true">https://it.knightnet.org.uk/kb/ghjekyll/reference-information/</guid><pubDate>Thu, 04 Jan 2018 22:00:00 +0000</pubDate><guid>https://it.knightnet.org.uk/kb/ghjekyll/reference-information/</guid><description><div>Some reference sites and links for Jekyll and Liquid.</div><div>&lt;h2 id="reference-help-and-tips">Reference, help and tips&lt;/h2>
&lt;ul>
&lt;li>&lt;a href="https://jekyllrb.com/docs/home/">Jekyll Official Documentation&lt;/a>&lt;/li>
&lt;li>&lt;a href="https://talk.jekyllrb.com/">Jekyll Discussion Groups&lt;/a>&lt;/li>
&lt;li>&lt;a href="https://shopify.github.io/liquid/">Liquid Reference on GitHub&lt;/a>&lt;/li>
&lt;li>&lt;a href="https://help.shopify.com/themes/liquid">Liquid Reference&lt;/a> - the official documentation for Liquid which is used by Jekyll&lt;/li>
&lt;li>&lt;a href="https://learn.cloudcannon.com/">CloudCannon Academy&lt;/a> - getting started with Jekyll&lt;/li>
&lt;li>&lt;a href="https://jekyllcodex.org/getting-started/">Jekyll Codex&lt;/a> - General information plus snippets that require not plugins (useful for GitHub Pages).&lt;/li>
&lt;li>&lt;a href="https://gist.github.com/smutnyleszek/9803727">Jekyll &amp;amp; Liquid Cheatsheet&lt;/a> - &amp;ldquo;A list of the most common functionalities in Jekyll&amp;rdquo;&lt;/li>
&lt;/ul>
&lt;h2 id="cloud-services">Cloud services&lt;/h2>
&lt;ul>
&lt;li>&lt;a href="https://cloudcannon.com/">CloudCannon&lt;/a> - Build and host Jekyll websites
Free for test sites with GitHub and Dropbox source syncing.
Can use this to do the donkey work of compiling the static site which can then be hosted anywhere. More options than GitHub Pages.&lt;/li>
&lt;/ul>
&lt;h2 id="interesting-themes">Interesting Themes&lt;/h2>
&lt;ul>
&lt;li>&lt;a href="https://github.com/pages-themes/tactile">Tactile&lt;/a> - Not perfect but I like the dark themed syntax highlighting.&lt;/li>
&lt;li>&lt;a href="https://github.com/jekyll/minima">Minima&lt;/a> - GitHub supported, seems to be about the most popular.&lt;/li>
&lt;/ul></div></description><author>Julian Knight</author><category domain="https://it.knightnet.org.uk/categories/development">Development</category><category domain="https://it.knightnet.org.uk/tags/jekyll">Jekyll</category><category domain="https://it.knightnet.org.uk/tags/static-site-generators">Static Site Generators</category></item><item><title>Jekyll/Liquid Tags</title><link>https://it.knightnet.org.uk/kb/ghjekyll/liquid-tags/</link><guid isPermaLink="true">https://it.knightnet.org.uk/kb/ghjekyll/liquid-tags/</guid><pubDate>Thu, 04 Jan 2018 17:00:00 +0000</pubDate><guid>https://it.knightnet.org.uk/kb/ghjekyll/liquid-tags/</guid><description><div>This is a list of `tags` that can be used in Jekyll.</div><div>&lt;p>Tags appear within &lt;code>{% tagname %}&lt;/code> markup.
Matching end-tags are shown in brackets.&lt;/p>
&lt;p>GitHub pages use Jekyll which in turn uses &lt;a href="https://help.shopify.com/themes/liquid">Liquid&lt;/a>.
See also the &lt;a href="https://help.shopify.com/themes/liquid/tags">official tags reference&lt;/a>.&lt;/p>
&lt;h2 id="control-flow-tags">Control flow tags&lt;/h2>
&lt;ul>
&lt;li>
&lt;p>&lt;a href="https://help.shopify.com/themes/liquid/tags/control-flow-tags#case-when">case&lt;/a> (when, else, endcase) - a switch statement&lt;/p>
&lt;/li>
&lt;li>
&lt;p>if (else, elsif, endif) - execute block only if the condition is met&lt;/p>
&lt;p>Note the odd spelling of &lt;code>elsif&lt;/code> (e.g. no second &lt;code>e&lt;/code>)&lt;/p>
&lt;p>Conditional tests support &lt;code>and&lt;/code> and &lt;code>or&lt;/code> to link conditions together
e.g. &lt;code>{% if line_item.grams &amp;gt; 20000 and customer_address.city == 'Ottawa' %}&lt;/code>&lt;/p>
&lt;/li>
&lt;li>
&lt;p>raw (endraw) - stops Liquid from parsing the content so that you can include double braces for example.&lt;/p>
&lt;/li>
&lt;li>
&lt;p>unless (endunless) - execute block only if the condition is &lt;strong>not&lt;/strong> met&lt;/p>
&lt;/li>
&lt;/ul>
&lt;h2 id="iteration-tags">Iteration tags&lt;/h2>
&lt;ul>
&lt;li>
&lt;p>&lt;a href="https://help.shopify.com/themes/liquid/tags/iteration-tags#cycle">cycle&lt;/a> - must be used in a for-loop. Cycles through the parameters
e.g. &lt;code>{% cycle 'a', 'b' %} {% cycle 'a', 'b' %} {% cycle 'a', 'b' %} #=&amp;gt; a b a&lt;/code>&lt;/p>
&lt;p>Can also specify a group name - see the documentation for more complex examples.&lt;/p>
&lt;/li>
&lt;li>
&lt;p>for (endfor, else, break, continue) - basic loop.&lt;/p>
&lt;p>For-loop parameters:&lt;/p>
&lt;ul>
&lt;li>
&lt;p>Limit the iterations using the &lt;code>limit&lt;/code> parameter
e.g. &lt;code>{% for item in numbers limit:2 %} {{ item }} {% endfor %}&lt;/code>&lt;/p>
&lt;/li>
&lt;li>
&lt;p>Use the &lt;code>offset&lt;/code> parameter to start at a particular index.&lt;/p>
&lt;/li>
&lt;li>
&lt;p>Use the &lt;em>range&lt;/em> parameter to create a number range to loop over, range numbers can be variables.
e.g. &lt;code>{% for i in (1..100) %} {{ i }} {% endfor %}&lt;/code>&lt;/p>
&lt;/li>
&lt;li>
&lt;p>Use the &lt;code>reversed&lt;/code> parameter to reverse the order of the loop&lt;/p>
&lt;p>For-loop variables - in a for-loop, we get the &lt;code>forloop&lt;/code> object (&lt;a href="https://help.shopify.com/themes/liquid/objects/for-loops">ref&lt;/a>):&lt;/p>
&lt;/li>
&lt;li>
&lt;p>forloop.first/last - true when the loop is at the first/last iteration&lt;/p>
&lt;/li>
&lt;li>
&lt;p>forloop.index/index0 - 1/0-based index number for the current iteration&lt;/p>
&lt;/li>
&lt;li>
&lt;p>forloop.rindex/rindex0 - 1/0-based reverse index number for the current iteration&lt;/p>
&lt;/li>
&lt;li>
&lt;p>forloop.length - the length of the array being looped over&lt;/p>
&lt;/li>
&lt;/ul>
&lt;/li>
&lt;li>
&lt;p>&lt;a href="https://help.shopify.com/themes/liquid/tags/iteration-tags#tablerow">tablerow&lt;/a> (endtablerow) - Generate rows for an HTML table.&lt;/p>
&lt;p>Includes parameters: &lt;code>cols&lt;/code> (defines the number of columns), &lt;code>limit&lt;/code>, &lt;code>offset&lt;/code>, &lt;code>range&lt;/code>, &lt;code>first&lt;/code>, &lt;code>col&lt;/code>, &lt;code>col_first&lt;/code> and others. See the &lt;a href="https://help.shopify.com/themes/liquid/objects/tablerow">documentation&lt;/a> for details&lt;/p>
&lt;/li>
&lt;/ul>
&lt;h2 id="themerendering-tags">Theme/rendering tags&lt;/h2>
&lt;ul>
&lt;li>
&lt;p>comment (endcomment)&lt;/p>
&lt;/li>
&lt;li>
&lt;p>form&lt;/p>
&lt;/li>
&lt;li>
&lt;p>&lt;a href="https://jekyllrb.com/docs/includes/">include&lt;/a>&lt;/p>
&lt;/li>
&lt;li>
&lt;p>include_relative&lt;/p>
&lt;/li>
&lt;li>
&lt;p>javascript&lt;/p>
&lt;/li>
&lt;li>
&lt;p>layout&lt;/p>
&lt;/li>
&lt;li>
&lt;p>paginate&lt;/p>
&lt;/li>
&lt;li>
&lt;p>raw (endraw) - temporarily disables tag processing. Useful for generating content (eg, Mustache, Handlebars) which uses conflicting syntax.&lt;/p>
&lt;/li>
&lt;li>
&lt;p>schema&lt;/p>
&lt;/li>
&lt;li>
&lt;p>section&lt;/p>
&lt;/li>
&lt;li>
&lt;p>stylesheet&lt;/p>
&lt;/li>
&lt;li>
&lt;p>&lt;a href="https://jekyllrb.com/docs/templates/#code-snippet-highlighting">highlight&lt;/a> - render a code block with syntax highlighting, optional line numbers. Note that filters are processed inside code blocks so wrap the block with and endraw tags if it contains curly braces. To find the appropriate identifier to use for the language you want to highlight, look for the “short name” on the &lt;a href="https://github.com/jayferd/rouge/wiki/List-of-supported-languages-and-lexers">Rouge wiki&lt;/a> or the &lt;a href="http://pygments.org/docs/lexers/">Pygments’ Lexers page&lt;/a>.&lt;/p>
&lt;/li>
&lt;li>
&lt;p>&lt;a href="https://jekyllrb.com/docs/templates/#links">link&lt;/a> - create an html link to another page in the Jekyll site. &lt;strong>WARNING: MUST CONTAIN A VALID SOURCE DOCUMENT NAME including folder and source extension otherwise the Jekyll build fails - on GitHub an immensely unhelpful generic error message is produced that does not allow you to identify the document causing the issue.&lt;/strong>&lt;/p>
&lt;/li>
&lt;/ul>
&lt;h2 id="variable-tags">Variable tags&lt;/h2>
&lt;ul>
&lt;li>assign - Assign a value to a variable. e.g. &lt;code>{% assign name = 'freestyle' %}&lt;/code>&lt;/li>
&lt;li>capture (endcapture) - Combine a number of outputs and assign to a variable.
e.g. &lt;code>{% capture attribute_name %}{{ item.title | handleize }}-{{ i }}-color{% endcapture %}&lt;/code>&lt;/li>
&lt;li>decrement&lt;/li>
&lt;li>increment&lt;/li>
&lt;/ul></div></description><author>Julian Knight</author><category domain="https://it.knightnet.org.uk/categories/development">Development</category><category domain="https://it.knightnet.org.uk/tags/jekyll">Jekyll</category><category domain="https://it.knightnet.org.uk/tags/static-site-generators">Static Site Generators</category></item><item><title>Jekyll/Liquid Variable Filters</title><link>https://it.knightnet.org.uk/kb/ghjekyll/liquid-filters/</link><guid isPermaLink="true">https://it.knightnet.org.uk/kb/ghjekyll/liquid-filters/</guid><pubDate>Wed, 03 Jan 2018 17:00:00 +0000</pubDate><guid>https://it.knightnet.org.uk/kb/ghjekyll/liquid-filters/</guid><description><div>A comprehensive list of filters available to modify/format Jekyll variables.</div><div>&lt;p>GitHub pages use Jekyll which in turn uses &lt;a href="https://help.shopify.com/themes/liquid">Liquid&lt;/a>.&lt;/p>
&lt;p>Liquid provides the variable filters that can be used to amend/format the variable for output.&lt;/p>
&lt;p>This is a more comprehensive list than you will find in most places, it is combined from multiple lists including the &lt;a href="http://www.rubydoc.info/gems/liquid/Liquid/StandardFilters">source documentation&lt;/a>. For more details on these filters, see the &lt;a href="https://help.shopify.com/themes/liquid/filters">official filter documentation&lt;/a>.&lt;/p>
&lt;ul>
&lt;li>
&lt;p>abs - absolute value&lt;/p>
&lt;/li>
&lt;li>
&lt;p>absolute_url - Prepend the &lt;code>url&lt;/code> and &lt;code>baseurl&lt;/code> value to the input. e.g. &lt;code>{{ &amp;quot;/assets/style.css&amp;quot; | absolute_url }} #=&amp;gt; http://example.com/my-baseurl/assets/style.css&lt;/code>&lt;/p>
&lt;/li>
&lt;li>
&lt;p>append - append a string e.g. &lt;code>{{ 'foo' | append:'bar' }} #=&amp;gt; 'foobar'&lt;/code>&lt;/p>
&lt;/li>
&lt;li>
&lt;p>array_to_sentence_string - Convert an array into a sentence. Useful for listing tags. Optional argument for connector. e.g. &lt;code>{{ page.tags | array_to_sentence_string: 'or' }} #=&amp;gt; foo, bar, or baz&lt;/code>&lt;/p>
&lt;/li>
&lt;li>
&lt;p>capitalize - capitalize words in the input sentence&lt;/p>
&lt;/li>
&lt;li>
&lt;p>ceil - rounds a number up to the nearest integer, e.g. &lt;code>{{ 4.6 | ceil }} #=&amp;gt; 5&lt;/code>&lt;/p>
&lt;/li>
&lt;li>
&lt;p>compact - Remove nils within an array provide optional property with which to check for nil.&lt;/p>
&lt;/li>
&lt;li>
&lt;p>&lt;a href="https://help.shopify.com/themes/liquid/filters/array-filters#concat">concat&lt;/a> - Concatenates (combines) an array with another array&lt;/p>
&lt;/li>
&lt;li>
&lt;p>cgi_escape - Replaces any special characters with appropriate &lt;code>%XX&lt;/code> replacements. CGI escape normally replaces a space with a plus &lt;code>+&lt;/code> sign.&lt;/p>
&lt;/li>
&lt;li>
&lt;p>date - reformat a date (&lt;a href="http://docs.shopify.com/themes/liquid-documentation/filters/additional-filters#date">syntax reference&lt;/a>)&lt;/p>
&lt;p>Reformat a date using Ruby&amp;rsquo;s core &lt;code>Time#strftime( string ) -&amp;gt; string&lt;/code>&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-fallback" data-lang="fallback">&lt;span class="line">&lt;span class="cl">%a - The abbreviated weekday name (``Sun&amp;#39;&amp;#39;)
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">%A - The full weekday name (``Sunday&amp;#39;&amp;#39;)
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">%b - The abbreviated month name (``Jan&amp;#39;&amp;#39;)
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">%B - The full month name (``January&amp;#39;&amp;#39;)
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">%c - The preferred local date and time representation
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">%d - Day of the month (01..31)
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">%H - Hour of the day, 24-hour clock (00..23)
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">%I - Hour of the day, 12-hour clock (01..12)
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">%j - Day of the year (001..366)
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">%m - Month of the year (01..12)
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">%M - Minute of the hour (00..59)
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">%p - Meridian indicator (``AM&amp;#39;&amp;#39; or ``PM&amp;#39;&amp;#39;)
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">%s - Number of seconds since 1970-01-01 00:00:00 UTC.
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">%S - Second of the minute (00..60)
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">%U - Week number of the current year,
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> starting with the first Sunday as the first
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> day of the first week (00..53)
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">%W - Week number of the current year,
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> starting with the first Monday as the first
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> day of the first week (00..53)
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">%w - Day of the week (Sunday is 0, 0..6)
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">%x - Preferred representation for the date alone, no time
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">%X - Preferred representation for the time alone, no date
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">%y - Year without a century (00..99)
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">%Y - Year with century
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">%Z - Time zone name
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">%% - Literal ``%&amp;#39;&amp;#39; character
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>See also: &lt;a href="http://www.ruby-doc.org/core/Time.html#method-i-strftime">http://www.ruby-doc.org/core/Time.html#method-i-strftime&lt;/a>&lt;/p>
&lt;/li>
&lt;li>
&lt;p>date_to_long_string - Format a date to long format. e.g. &lt;code>07 November 2008&lt;/code>&lt;/p>
&lt;/li>
&lt;li>
&lt;p>date_to_rfc822 - Convert a Date into the RFC-822 format used for RSS feeds.&lt;/p>
&lt;/li>
&lt;li>
&lt;p>date_to_string - Convert a date to short format. e.g. &lt;code>07 Nov 2008&lt;/code>&lt;/p>
&lt;/li>
&lt;li>
&lt;p>date_to_xmlschema - Convert a Date into XML Schema (ISO 8601) format.&lt;/p>
&lt;/li>
&lt;li>
&lt;p>default - returns the given variable unless it is null or the empty string, when it will return the given value,
e.g. &lt;code>{{ undefined_variable | default: &amp;quot;Default value&amp;quot; }} #=&amp;gt; &amp;quot;Default value&amp;quot;&lt;/code>&lt;/p>
&lt;/li>
&lt;li>
&lt;p>default_errors -&lt;/p>
&lt;/li>
&lt;li>
&lt;p>default_pagination -&lt;/p>
&lt;/li>
&lt;li>
&lt;p>divided_by - integer division e.g. &lt;code>{{ 10 | divided_by:3 }} #=&amp;gt; 3&lt;/code>&lt;/p>
&lt;/li>
&lt;li>
&lt;p>downcase - convert an input string to lowercase&lt;/p>
&lt;/li>
&lt;li>
&lt;p>escape - html escape a string&lt;/p>
&lt;/li>
&lt;li>
&lt;p>escape_once - returns an escaped version of html without affecting existing escaped entities&lt;/p>
&lt;/li>
&lt;li>
&lt;p>first - get the first element of the passed-in array&lt;/p>
&lt;/li>
&lt;li>
&lt;p>floor - rounds a number down to the nearest integer, e.g. &lt;code>{{ 4.6 | floor }} #=&amp;gt; 4&lt;/code>&lt;/p>
&lt;/li>
&lt;li>
&lt;p>&lt;strong>gist&lt;/strong> (provided by &lt;a href="https://github.com/jekyll/jekyll-gist">jekyll-gist plugin&lt;/a>) - display a gist. e.g. &lt;code>{% gist c08ee0f2726fd0e3909d %}&lt;/code>&lt;/p>
&lt;/li>
&lt;li>
&lt;p>group_by - group elements from array by given property: &lt;code>{{ site.posts | group_by:&amp;quot;category&amp;quot; }}&lt;/code>&lt;/p>
&lt;/li>
&lt;li>
&lt;p>group_by_exp - Group an array&amp;rsquo;s items using a Liquid expression. e.g. &lt;code>{{ site.members | group_by_exp:&amp;quot;item&amp;quot;,&amp;quot;item.graduation_year | truncate: 3, \&amp;quot;\&amp;quot;&amp;quot; }} #=&amp;gt; [{&amp;quot;name&amp;quot;=&amp;gt;&amp;quot;201...&amp;quot;, &amp;quot;items&amp;quot;=&amp;gt;[...]},{&amp;quot;name&amp;quot;=&amp;gt;&amp;quot;200...&amp;quot;, &amp;quot;items&amp;quot;=&amp;gt;[...]}]&lt;/code>&lt;/p>
&lt;/li>
&lt;li>
&lt;p>&lt;a href="https://help.shopify.com/themes/liquid/filters/additional-filters#highlight">highlight&lt;/a> - Wraps words inside search results with an HTML &lt;code>&amp;lt;strong&amp;gt;&lt;/code> tag with the class highlight if it matches the submitted search.terms. Has to be used in a search form. &lt;strong>Does this work in Jekyll?&lt;/strong> Not to be confused with the &lt;code>highlight&lt;/code> &lt;strong>tag&lt;/strong>.&lt;/p>
&lt;/li>
&lt;li>
&lt;p>highlight_active_tag - Wraps a tag link in a &lt;code>&amp;lt;span&amp;gt;&lt;/code> with the class active if that tag is being used to filter a collection.&lt;/p>
&lt;/li>
&lt;li>
&lt;p>img_tag - generate an img html tag&lt;/p>
&lt;/li>
&lt;li>
&lt;p>inspect - Convert an object into its String representation for debugging. Returns a JSON stringified version of a variable so use as &lt;code>&amp;lt;pre&amp;gt;{{ page | inspect }}&amp;lt;/pre&amp;gt;&lt;/code> - possibly references Ruby&amp;rsquo;s inspect function?&lt;/p>
&lt;/li>
&lt;li>
&lt;p>join - join elements of the array with certain character between them&lt;/p>
&lt;/li>
&lt;li>
&lt;p>&lt;a href="https://help.shopify.com/themes/liquid/filters/additional-filters#json">json&lt;/a> - Converts a string into JSON format.&lt;/p>
&lt;p>You do not have to wrap the Liquid output in quotations - the json filter will add them in. The json filter will also escape quotes as needed inside the output. The json filter can also used to make Liquid objects readable by JavaScript.&lt;/p>
&lt;/li>
&lt;li>
&lt;p>jsonify - convert data to JSON: &lt;code>{{ site.data.dinosaurs | jsonify }}&lt;/code>&lt;/p>
&lt;/li>
&lt;li>
&lt;p>last - get the last element of the passed in array&lt;/p>
&lt;/li>
&lt;li>
&lt;p>lstrip - strips all whitespace from the beginning of a string&lt;/p>
&lt;/li>
&lt;li>
&lt;p>map - map/collect an array on a given property&lt;/p>
&lt;/li>
&lt;li>
&lt;p>markdownify - convert markdown to HTML&lt;/p>
&lt;/li>
&lt;li>
&lt;p>minus - subtraction e.g. &lt;code>{{ 4 | minus:2 }} #=&amp;gt; 2&lt;/code>&lt;/p>
&lt;/li>
&lt;li>
&lt;p>modulo - remainder, e.g. &lt;code>{{ 3 | modulo:2 }} #=&amp;gt; 1&lt;/code>&lt;/p>
&lt;/li>
&lt;li>
&lt;p>newline_to_br - replace each newline (&lt;code>\n&lt;/code>) with html break&lt;/p>
&lt;/li>
&lt;li>
&lt;p>normalize_whitespace - Replace any occurrence of whitespace with a single space.&lt;/p>
&lt;/li>
&lt;li>
&lt;p>number_of_words - Count the number of words in some text.&lt;/p>
&lt;/li>
&lt;li>
&lt;p>placeholder_svg_tag&lt;/p>
&lt;/li>
&lt;li>
&lt;p>plus - addition e.g. &lt;code>{{ '1' | plus:'1' }} #=&amp;gt; 2, {{ 1 | plus:1 }} #=&amp;gt; 2&lt;/code>&lt;/p>
&lt;/li>
&lt;li>
&lt;p>pop - Remove an entry from the end of an array. Non-destructive, makes a copy of the array and changes that.&lt;/p>
&lt;/li>
&lt;li>
&lt;p>prepend - prepend a string e.g. &lt;code>{{ 'bar' | prepend:'foo' }} #=&amp;gt; 'foobar'&lt;/code>&lt;/p>
&lt;/li>
&lt;li>
&lt;p>push - Add entry to the end of an array. Non-destructive, makes a copy of the array and changes that.&lt;/p>
&lt;/li>
&lt;li>
&lt;p>relative_url - Prepend the baseurl value to the input. Useful if your site is hosted at a subpath rather than the root of the domain. e.g. &lt;code>{{ &amp;quot;/assets/style.css&amp;quot; | relative_url }} #=&amp;gt; /my-baseurl/assets/style.css&lt;/code>&lt;/p>
&lt;/li>
&lt;li>
&lt;p>remove - remove each occurrence e.g. &lt;code>{{ 'foobarfoobar' | remove:'foo' }} #=&amp;gt; 'barbar'&lt;/code>&lt;/p>
&lt;/li>
&lt;li>
&lt;p>remove_first - remove the first occurrence e.g. &lt;code>{{ 'barbar' | remove_first:'bar' }} #=&amp;gt; 'bar'&lt;/code>&lt;/p>
&lt;/li>
&lt;li>
&lt;p>replace - replace each occurrence e.g. &lt;code>{{ 'foofoo' | replace:'foo','bar' }} #=&amp;gt; 'barbar'&lt;/code>&lt;/p>
&lt;/li>
&lt;li>
&lt;p>replace_first - replace the first occurrence e.g. &lt;code>{{ 'barbar' | replace_first:'bar','foo' }} #=&amp;gt; 'foobar'&lt;/code>&lt;/p>
&lt;/li>
&lt;li>
&lt;p>reverse - reverses the passed in array&lt;/p>
&lt;/li>
&lt;li>
&lt;p>round - rounds input to the nearest integer or specified number of decimals e.g. &lt;code>{{ 4.5612 | round: 2 }} #=&amp;gt; 4.56&lt;/code>&lt;/p>
&lt;/li>
&lt;li>
&lt;p>rstrip - strips all whitespace from the end of a string&lt;/p>
&lt;/li>
&lt;li>
&lt;p>sample - Pick a random value from an array. Optionally provide a number to pick multiple values.&lt;/p>
&lt;/li>
&lt;li>
&lt;p>sassify - Convert a Sass-formatted string into CSS.&lt;/p>
&lt;/li>
&lt;li>
&lt;p>script_tag - generate a script html tag&lt;/p>
&lt;/li>
&lt;li>
&lt;p>scssify - Convert a Scss-formatted string into CSS.&lt;/p>
&lt;/li>
&lt;li>
&lt;p>shift - Add entry to the start of an array. Non-destructive, makes a copy of the array and changes that.&lt;/p>
&lt;/li>
&lt;li>
&lt;p>size - return the size of an array or string&lt;/p>
&lt;/li>
&lt;li>
&lt;p>slice - slice a string. Takes an offset and length, e.g. &lt;code>{{ &amp;quot;hello&amp;quot; | slice: -3, 3 }} #=&amp;gt; llo&lt;/code>&lt;/p>
&lt;/li>
&lt;li>
&lt;p>slugify - Convert a string into a lowercase URL &amp;ldquo;slug&amp;rdquo;. &lt;a href="https://jekyllrb.com/docs/templates/#options-for-the-slugify-filter">Optionally takes a style parameter&lt;/a>: none, raw, default, pretty, ascii, latin. &lt;a href="https://jekyllrb.com/docs/permalinks/#builtinpermalinkstyles">Definitions for permalink styles&lt;/a>&lt;/p>
&lt;/li>
&lt;li>
&lt;p>sort - sort elements of the array&lt;/p>
&lt;/li>
&lt;li>
&lt;p>sort_natural - Sort elements of an array ignoring case if strings provide optional property with which to sort an array of hashes or drops.&lt;/p>
&lt;/li>
&lt;li>
&lt;p>smartify - Convert &amp;ldquo;quotes&amp;rdquo; into “smart quotes.”&lt;/p>
&lt;/li>
&lt;li>
&lt;p>split - split a string on a matching pattern e.g. &lt;code>{{ &amp;quot;a~b&amp;quot; | split:&amp;quot;~&amp;quot; }} #=&amp;gt; ['a','b']&lt;/code>&lt;/p>
&lt;/li>
&lt;li>
&lt;p>strip - strips all whitespace from both ends of the string&lt;/p>
&lt;/li>
&lt;li>
&lt;p>strip_html - strip html from string&lt;/p>
&lt;/li>
&lt;li>
&lt;p>strip_newlines - strip all newlines (&lt;code>\n&lt;/code>) from string&lt;/p>
&lt;/li>
&lt;li>
&lt;p>stylesheet_tag - generate a stylesheet html tag&lt;/p>
&lt;/li>
&lt;li>
&lt;p>times - multiplication e.g &lt;code>{{ 5 | times:4 }} #=&amp;gt; 20&lt;/code>&lt;/p>
&lt;/li>
&lt;li>
&lt;p>to_integer - Convert a string or boolean to integer.&lt;/p>
&lt;/li>
&lt;li>
&lt;p>truncate - truncate a string down to x characters. It also accepts a second parameter that will append to the string
e.g. &lt;code>{{ 'foobarfoobar' | truncate: 5, '.' }} #=&amp;gt; 'foob.'&lt;/code>&lt;/p>
&lt;/li>
&lt;li>
&lt;p>truncatewords - truncate a string down to x words&lt;/p>
&lt;/li>
&lt;li>
&lt;p>uniq - remove duplicate elements from an array, optionally using a given property to test for uniqueness&lt;/p>
&lt;/li>
&lt;li>
&lt;p>unshift - Remove an entry from the start of an array. Non-destructive, makes a copy of the array and changes that.&lt;/p>
&lt;/li>
&lt;li>
&lt;p>upcase - convert an input string to uppercase&lt;/p>
&lt;/li>
&lt;li>
&lt;p>uri_escape - Percent encodes any special characters in a URI. URI escape normally replaces a space with &lt;code>%20&lt;/code>. Reserved characters will not be escaped.&lt;/p>
&lt;/li>
&lt;li>
&lt;p>url_decode - url decode a string&lt;/p>
&lt;/li>
&lt;li>
&lt;p>url_encode - url encode a string&lt;/p>
&lt;/li>
&lt;li>
&lt;p>where - select elements from array with given property value: &lt;code>{{ site.posts | where:&amp;quot;category&amp;quot;,&amp;quot;foo&amp;quot; }}&lt;/code>&lt;/p>
&lt;/li>
&lt;li>
&lt;p>where_exp - Select all the objects in an array where the expression is true. Jekyll v3.2.0 &amp;amp; later. e.g. &lt;code>{{ site.members | where_exp:&amp;quot;item&amp;quot;,&amp;quot;item.graduation_year == 2014&amp;quot; }} {{ site.members | where_exp:&amp;quot;item&amp;quot;,&amp;quot;item.graduation_year &amp;lt; 2014&amp;quot; }} {{ site.members | where_exp:&amp;quot;item&amp;quot;,&amp;quot;item.projects contains 'foo'&amp;quot; }}&lt;/code>&lt;/p>
&lt;/li>
&lt;li>
&lt;p>xml_escape - Escape some text for use in XML.&lt;/p>
&lt;/li>
&lt;/ul>
&lt;h2 id="liquid-filters-that-dont-work-in-jekyll">Liquid filters that don&amp;rsquo;t work in Jekyll&lt;/h2>
&lt;ul>
&lt;li>
&lt;p>These math filters don&amp;rsquo;t work:&lt;/p>
&lt;ul>
&lt;li>at_least - Limits a number to a minimum value.&lt;/li>
&lt;li>&lt;a href="https://help.shopify.com/themes/liquid/filters/math-filters#at_most">at_most&lt;/a> - Limits a number to a maximum value.&lt;/li>
&lt;/ul>
&lt;/li>
&lt;li>
&lt;p>Not all of the string filters work:&lt;/p>
&lt;ul>
&lt;li>The hashing filters don&amp;rsquo;t work&lt;/li>
&lt;li>camelcase&lt;/li>
&lt;li>pluralize&lt;/li>
&lt;li>time_tag&lt;/li>
&lt;/ul>
&lt;/li>
&lt;li>
&lt;p>Not all of the utility filters work:&lt;/p>
&lt;ul>
&lt;li>weight_with_unit - Formats a number with the default weight unit. The unit can be overridden by passing it into the filter.&lt;/li>
&lt;li>format_address&lt;/li>
&lt;/ul>
&lt;/li>
&lt;li>
&lt;p>The money filters don&amp;rsquo;t appear to work.&lt;/p>
&lt;/li>
&lt;li>
&lt;p>The colour filters don&amp;rsquo;t seem to work:&lt;/p>
&lt;ul>
&lt;li>&lt;a href="https://help.shopify.com/themes/liquid/filters/color-filters#color_brightness">color_brightness&lt;/a> - Calculates the perceived brightness of the given color. Uses &lt;a href="https://www.w3.org/TR/AERT#color-contrast">W3C recommendations for calculating perceived brightness&lt;/a>, for the purpose of ensuring adequate contrast.&lt;/li>
&lt;li>color_darken - Darkens the input color. Takes a value between 0 and 100 percent.&lt;/li>
&lt;li>color_desaturate - Desaturates the input color. Takes a value between 0 and 100 percent.&lt;/li>
&lt;li>color_extract - Extracts a component from the color. Valid components are alpha, red, green, blue, hue, saturation and lightness.&lt;/li>
&lt;li>color_lighten - Lightens the input color. Takes a value between 0 and 100 percent.&lt;/li>
&lt;li>color_mix - Blends together two colors. Blend factor should be a value value between 0 and 100 percent.&lt;/li>
&lt;li>color_modify - Modifies the given component of a color. &lt;code>{{ '#7ab55c' | color_modify: 'red', 255 }} #=&amp;gt; #ffb55c&lt;/code>&lt;/li>
&lt;li>color_saturate - Saturates the input color. Takes a value between 0 and 100 percent.&lt;/li>
&lt;li>color_to_hex - Converts a CSS color string to hex6 format.&lt;/li>
&lt;li>color_to_hsl - Converts a CSS color string to CSS &lt;code>hsl()&lt;/code> format.&lt;/li>
&lt;li>&lt;a href="https://help.shopify.com/themes/liquid/filters/color-filters#color_to_rgb">color_to_rgb&lt;/a> - Converts a CSS color string to CSS &lt;code>rgb()&lt;/code> format.&lt;/li>
&lt;/ul>
&lt;/li>
&lt;/ul></div></description><author>Julian Knight</author><category domain="https://it.knightnet.org.uk/categories/development">Development</category><category domain="https://it.knightnet.org.uk/tags/jekyll">Jekyll</category><category domain="https://it.knightnet.org.uk/tags/static-site-generators">Static Site Generators</category></item><item><title>Add Disqus to Jekyll pages</title><link>https://it.knightnet.org.uk/kb/ghjekyll/add-disqus/</link><guid isPermaLink="true">https://it.knightnet.org.uk/kb/ghjekyll/add-disqus/</guid><pubDate>Tue, 02 Jan 2018 17:11:00 +0000</pubDate><guid>https://it.knightnet.org.uk/kb/ghjekyll/add-disqus/</guid><description><div>Example code to add to every page as a footer to enable the Disqus comments service.</div><div>&lt;p>Create &lt;code>footer.html&lt;/code> in your site &lt;code>_includes&lt;/code> folder or include this in the default layout in &lt;code>_layouts&lt;/code>.&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-html" data-lang="html">&lt;span class="line">&lt;span class="cl">{% if page.comments %}
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="p">&amp;lt;&lt;/span>&lt;span class="nt">div&lt;/span> &lt;span class="na">id&lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="s">&amp;#34;disqus_thread&amp;#34;&lt;/span>&lt;span class="p">&amp;gt;&amp;lt;/&lt;/span>&lt;span class="nt">div&lt;/span>&lt;span class="p">&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="p">&amp;lt;&lt;/span>&lt;span class="nt">script&lt;/span>&lt;span class="p">&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="kd">var&lt;/span> &lt;span class="nx">disqus_config&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="kd">function&lt;/span> &lt;span class="p">()&lt;/span> &lt;span class="p">{&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="k">this&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="nx">page&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="nx">url&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="s1">&amp;#39;{{ page.url | absolute_url }}&amp;#39;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="k">this&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="nx">page&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="nx">identifier&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="s1">&amp;#39;{{ page.id }}&amp;#39;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">};&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">(&lt;/span>&lt;span class="kd">function&lt;/span>&lt;span class="p">()&lt;/span> &lt;span class="p">{&lt;/span> &lt;span class="kd">var&lt;/span> &lt;span class="nx">d&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="nb">document&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="nx">s&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="nx">d&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="nx">createElement&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="s1">&amp;#39;script&amp;#39;&lt;/span>&lt;span class="p">);&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nx">s&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="nx">src&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="s1">&amp;#39;https://&amp;lt;&amp;lt;set_this_from_disqus_settings&amp;gt;&amp;gt;.disqus.com/embed.js&amp;#39;&lt;/span>&lt;span class="p">;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nx">s&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="nx">setAttribute&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="s1">&amp;#39;data-timestamp&amp;#39;&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="o">+&lt;/span>&lt;span class="k">new&lt;/span> &lt;span class="nb">Date&lt;/span>&lt;span class="p">());&lt;/span> &lt;span class="p">(&lt;/span>&lt;span class="nx">d&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="nx">head&lt;/span> &lt;span class="o">||&lt;/span> &lt;span class="nx">d&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="nx">body&lt;/span>&lt;span class="p">).&lt;/span>&lt;span class="nx">appendChild&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="nx">s&lt;/span>&lt;span class="p">);&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">})();&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="p">&amp;lt;/&lt;/span>&lt;span class="nt">script&lt;/span>&lt;span class="p">&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="p">&amp;lt;&lt;/span>&lt;span class="nt">noscript&lt;/span>&lt;span class="p">&amp;gt;&lt;/span>Please enable JavaScript to view the &lt;span class="p">&amp;lt;&lt;/span>&lt;span class="nt">a&lt;/span> &lt;span class="na">href&lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="s">&amp;#34;https://disqus.com/?ref_noscript&amp;#34;&lt;/span>&lt;span class="p">&amp;gt;&lt;/span>comments powered by Disqus.&lt;span class="p">&amp;lt;/&lt;/span>&lt;span class="nt">a&lt;/span>&lt;span class="p">&amp;gt;&amp;lt;/&lt;/span>&lt;span class="nt">noscript&lt;/span>&lt;span class="p">&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">{% endif %}
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="p">&amp;lt;&lt;/span>&lt;span class="nt">div&lt;/span>&lt;span class="p">&amp;gt;&lt;/span>Updated: {{ page.date | default: site.time | date: &amp;#34;%Y-%m-%d %H:%M&amp;#34; }} &lt;span class="p">&amp;lt;&lt;/span>&lt;span class="nt">a&lt;/span> &lt;span class="na">href&lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="s">&amp;#34;#top&amp;#34;&lt;/span>&lt;span class="p">&amp;gt;&lt;/span>Top&lt;span class="p">&amp;lt;/&lt;/span>&lt;span class="nt">a&lt;/span>&lt;span class="p">&amp;gt;&amp;lt;/&lt;/span>&lt;span class="nt">div&lt;/span>&lt;span class="p">&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>Note that the default &lt;code>minima&lt;/code> theme for Jekyll/GitHub pages includes a setting for this in _config.yml but currently does &lt;strong>not&lt;/strong> include the appropriate include file to let you use it!&lt;/p>
&lt;p>Also note that you have very little control over the styling. In particular, the width is set to 100% so make sure that this code is wrapped in a div that is limited to your normal content width.&lt;/p></div></description><author>Julian Knight</author><category domain="https://it.knightnet.org.uk/categories/development">Development</category><category domain="https://it.knightnet.org.uk/tags/jekyll">Jekyll</category><category domain="https://it.knightnet.org.uk/tags/static-site-generators">Static Site Generators</category><category domain="https://it.knightnet.org.uk/tags/disqus">Disqus</category></item><item><title>How to create a page toc</title><link>https://it.knightnet.org.uk/kb/ghjekyll/generate-toc/</link><guid isPermaLink="true">https://it.knightnet.org.uk/kb/ghjekyll/generate-toc/</guid><pubDate>Tue, 02 Jan 2018 17:00:00 +0000</pubDate><guid>https://it.knightnet.org.uk/kb/ghjekyll/generate-toc/</guid><description><div>If you want to generate a table of contents list (toc) for a markdown file, you can use the native Kramdown feature.</div><div>&lt;p>If you want to generate an in-page table of contents using markdown headings, you can do so with the following code.&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-markdown" data-lang="markdown">&lt;span class="line">&lt;span class="cl">&lt;span class="k">*&lt;/span> This list entry is required but will not be shown, it is replaced by the toc
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">{:toc}
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div></div></description><author>Julian Knight</author><category domain="https://it.knightnet.org.uk/categories/development">Development</category><category domain="https://it.knightnet.org.uk/tags/jekyll">Jekyll</category><category domain="https://it.knightnet.org.uk/tags/static-site-generators">Static Site Generators</category><category domain="https://it.knightnet.org.uk/tags/markdown">Markdown</category><category domain="https://it.knightnet.org.uk/tags/kramdown">Kramdown</category></item></channel></rss>