A weblog by Rik Chilvers.

N.B.: I meant to make this the first post but (typically) took ages to finish it. Since starting it in early February there's been a growth in interest towards static sites. The motivation appears to be speed: having your site linked to on Daring Fireball, for example, will punish an uncached dynamic site. Luckily (hah) for me that's not an issue, and was not my motivation, but it's nice to see people exploring their options. Variety, as they say, is the spice of life.

When I was a child, building things out of Lego was always more fun than playing with them. I'd build a spaceship, fly it around for an afternoon, and then decide that what this mission really needed was a sort of agile tank thing with big wheels. So I'd break up the spaceship and start again. That's what it's been like with blogging too; over the past few years I've probably tried more blogging platforms than I've written posts. First it was Wordpress, then Habari, Textpattern, and finally Tumblr. I think I even flirted with ExpressionEngine at one point. Much like changing pens won't make you a better, or more prolific, novelist, changing blogging engines won't help you post more.

By the beginning of this year it was beginning to look like there was little point in having a domain at all. So I made a decision: either post to the blog or get rid of it. Do something, at least, to reduce the black hole of money it had become: I was paying £10 a month for something I didn't use.

Getting rid of it entirely seemed a little drastic. I'd like to develop my writing and a blog is a fantastic, low-friction way to do that. If I wasn't going to delete the thing entirely I needed to find a way to make it cheaper. Enter NearlyFreeSpeech and Jekyll.

Nearly Free

With most web hosting companies you pay a fixed monthly rate for a set package. This usually includes a fixed amount of bandwidth, a certain number of MySQL databases, a fixed amount of disk space for your site and so on. While this is great, and must work for lots of people, in my case even the smallest packages on offer are far more than I need. The traffic to my site is low, I only store text files and the odd image, and even when I was running a database based CMS with Mint I was only using 2 MySQL databases.

Which is where NearlyFreeSpeech, who provide a pay-as-you-go system, come in. You are charged only for the bandwidth and storage you use, and the costs scale. Other services, such as PHP, MySQL, and DNS resolving, cost a fixed amount per day and can be switched on and off as needed. On a site such as mine the monthly cost of hosting can easily be as low as $1 a month.

I'm surprised I hadn't heard of NFS before. I've enjoyed constant uptime (as far as I can tell), their site management backend is custom and much easier to understand and navigate than what I'd previously been using (cPanel), and they're cheap.

At the same time as finding NFS, I came across Jekyll. Jekyll is a Ruby powered "blog aware, static site generator"; which means it takes Markdown formatted text files and spits out a blog of flat HTML files. I'll be the first to note the irony of lamenting my constant switching of blogging tools, only to switch again. In defence of this move, however, I'll assert it's in the interest of bringing the cost of my hosting down: on NFS hosting static files is cheaper than having a dynamically generated site. There are other benefits too: the site has much higher portability, since it's just a folder of HTML files; backing up is easier for the same reason; there are no security issues; and it's much, much faster.

Dr Jekyll

As well as the above benefits there is something rather pleasing about having your website as text files. I swear by the combination of Simplenote, Notational Velocity, and Dropbox; having my website as a bunch of text files seems like a natural extension of this. Being able to effectively track changes using Git is nice too. Additionally, I'm reasonably comfortable with Ruby, much more so than I am with PHP, which means I've got a decent idea of what Jekyll is doing; Wordpress's PHP was always a bit of a black box to me. Not feeling constantly at sea with my blog's code is pleasant.

Making the move to Jekyll was relatively painless. I referred a lot to Paul Stamatious's post on his switch from Wordpress, which helped a great deal. In fact, this site is generated with his fork so as to make use of his MultiViews addition. I also added Henrik's mod_rewrite magic to my .htaccess file, which not only keeps the root of my server tidy, but also allows me to have a a sensible URL structure.

Talking of URL structure, something I've noticed in quite a lot of Jekyll powered blogs is that the URLs break too easily. For example, on the venerable Tom Preston-Werner's blog a post URL might look like http://tom.preston-werner.com/2008/11/17/blogging-like-a-hacker.html. Fine, but this suggests that http://tom.preston-werner.com/2008 is a valid URL. Nuh-uh. Jekyll has a flexible permalink structure which can be changed on a whim. This is fantastic, and allows you to fashion your blog as you'd like; however, a side effect are these brittle URLs.

There's an easy workaround though. URLs for this blog are structured like this: http://double.plus.gd/archive/git-bash-aliases. Which means Jekyll is creating a folder called 'archive' and placing all the generated posts in it. So, to create a sturdy URL instead of having an archive.html file for the archives nest it, like so: archive/index.html. Jekyll sees there is a folder called 'archive' and merrily pops all the generated posts along with the index file in it when it creates the site. This means the user can visit http://double.plus.gd/archive and be served up the index file; or a specific post URL, and be served up the correct post. Awesome.

If you're interested in seeing the code for this blog it's over on Github. The Rakefile may be of particular interest since it contains deployment code, and some rake tasks for creating template posts.

Bells and Whistles

As I mentioned above I'd planned on having a flat site on a static server to keep the costs as low as possible (PHP costs an extra $0.01/day). Eventually though I got sick of Google Analytics and have moved back to Mint (adding another $0.02/day for MySQL). It's not ideal, in the sense that it would be nice to keep this setup as sparse as possible, but it doesn't add too much to the hosting cost. Indeed, you could easily host your dynamic site on NFS for peanuts; although you wouldn't get all the benefits of a static site like Jekyll provides. Having PHP enabled also lets me play around with little projects like this from Shaun Inman.

Closing Thoughts

This is by no means a setup that would work for everyone, but I'm very happy with it. The code base for Jekyll is only around 2000 lines long, so it's easy to get to grips with; I can edit my posts in Textmate (I love me some IR_Black); and it's fast, stable, light, and portable. I finally feel like I can stop fighting with the blog, and just get down to writing. Let's see how it goes.