Linklogs with Jekyll

I’m a big fan of John Gruber’s Daring Fireball, a blog that makes great use of linked posts. If you’re interested in configuring Jekyll as a linklog, here’s how.

Jekyll doesn’t have built-in support for linklogs like Octopress does, but with a few small tweaks you can make it work.

First thing’s first: to publish linked posts, you’ll need a custom front matter variable. I use the key external-url:

---
title: MacBook Shuffle Released
layout: post
external-url: http://apple.com
---

Now in your index.html file, you’ll need to redirect link posts to the external URL instead of the post URL, like so:

{% if post.external-url %}
  <a href="{{ post.external-url }}">
    {{ post.title }}
  </a>
{% else %}
  <a href="{{ post.url }}">
    {{ post.title }}
  </a>
{% endif %}

You’ll also want to add something similar to your atom.xml file:

{% if post.external-url %}
  <link href="{{ post.external-url }}"/>
{% else %}
  <link href="{{ site.url }}{{ post.url }}"/>
{% endif %}

Then you’re all set! Add a value for the external-url front matter variable in any post and it will behave as a linked post.


More Reading