I used to host my dev blog on Posterous. Twitter bought them out, and they were shutting down shop. I had to move my blog, but I didn't know where. I knew I didn't want much hassle which made me lean towards finding a hosted solution like wordpress. But I also knew I wanted something that would be good for sharing code snippets. At one time, Posterous had support for code snippets and markdown, which was great. Their support of it...not so much. I got so tired of their lack of support that I started just writing markdown in Github gists and pointed people to it. And then I started wondering if I could somehow strike a balance between a no-hassle solution and using gists.
I already had a Github user page setup with my custom domain. I started it with an automatically generated site with the theme that I chose, which saved me from shopping for another theme too. And since it uses Jekyll, which I've never used but have been wanting to learn, I gave it a shot.
Luckily, Jekyll even had a built-in Posterous importer. However, I lost all the comments that were hosted by Posterous. Not a deal breaker, but I still want a commenting system. I really didn't want to integrate some 3rd party service, nor do it myself.
I suddenly remembered that Github gists are easily embeddable. On each gist page is an HTML script tag snippet to embed the gist. It's a little 1-liner that does everything for you. It even includes a stylesheet. I only had to tweak the CSS font to get it to look closer to what you see when viewed on github.
Comments don't show up on my page, but that's not a big deal. I just added a note to tell people to go there to see/add comments. And because they are hosted by github, comments will be more dev-friendly too.
It gets better. I can edit an existing blog entry without touching my static jekyll site! I get just about everything that comes along with gists including support for a wide range of syntax highlighting. I doubt any blogging service can offer that. Github gist is a dev-blogger's best friend!
I can easily paste in the embed snippet to each and every blog post. But every time you do that, Dave Thomas dies a little inside. Let's DRY it up using Jekyll.
---
layout: post
title: Piggyback Github gists for dev blogging
categories: dev_blog
gist_id: 5266899
---
That's it. That's all Jekyll needs to know about a post. With just a gist_id from github and some meta data, I can quickly publish a new post.
The layout just needs to construct the snippet:
<script src="https://gist.github.com/{{ page.gist_id }}.js"></script>
Update: Jekyll 1.0 now has [built-in support for embedding gists using liquid] (https://github.com/mojombo/jekyll/blob/v1.0.0/lib/jekyll/tags/gist.rb). This doesn't quite work here because it takes the argument literally (i.e. it will use the literal string page.gist_id
and the post will not compile correctly).
Now I have a simple, easy-to-use, static-site (but actually easy to edit) blog with Github-flavored markdown, comments, fast hosting, all for free. Awesome.
I made a minimal, starter repository for you to clone/fork and play around with. You can see the full code for my site here.
What about content indexing for i.e. google?
Did you think about some solution for that?