Feeds, Maps, and Tweaks

By Will Angley
15 May 2014

The blog should be effectively set up now. I’ve added an RSS feed to the home page, so you can follow along with a reader like ReadKit; a Sitemap so search engines can follow along too; a custom 404 page, that you will hopefully never see; and turned on emoji , that you hopefully will :wink:.

Read on if you’re interested in the technical details of how this was done. All together, these changes took half a day to make and write up.

RSS feed

Jekyll now supplies an RSS feed page with the default template, but the earlier versions of Jekyll do not. Since this site’s template is based on an earlier version default, I had to backport the feed template.

This turned out to be an issue of changing some variables in the _config.yml file, made a bit more annoying by some of the variable names having changed. The jekyll serve --watch command does not reload the configuration file, which made for a lot of stopping and restarting the development server.

The default template uses an explicit hyperlink to add the RSS feed to the main page, which doesn’t really fit in well with the older version template, so I added it using a <link> tag instead. The code that does this, added within the <head> tags in the _layout for the index page, is:

{% if page.url == "/index.html" %}
<link rel="alternate" type="application/rss+xml" href="/feed.xml" title="Site RSS feed">
{% endif  %}

Sitemap

Google, and other search engines, like having a sitemap at root level. This both points to pages on the site that might not be discovered otherwise, and provides a straightforward way for the engine to find changed pages without spidering the whole site.

Jekyll doesn’t supply a template for this. Inspired by the default RSS template, and thinking that if someone else had made this it would surely be in Jekyll by now, I hacked together one of my own based on the protocol spec, tested it with Google Webmaster Tools, and found it promptly failed with errors. It took about an hour to get to zero errors, after which I submitted my sitemap and went to bed.

It was late when I did this last night. When I searched for [jekyll sitemap] today, I found four implementations on the first page and two bugs in my own, now fixed. A bit more digging showed that pull requests jekyll/jekyll#1995 and jekyll/jekyll#2259 were opened for this, and both rejected :frowning:.

Last, I added a robots.txt file with a reference to the sitemap, so other robots can find and use it too.