Changed Permalinks and More Blog Tweaks

I’m really liking Jekyll as a blog engine, and have been tweaking a few things on the site. One big change is permalinks. To follow Jekyll’s preferred convention, I’ve switched my post’s permalinks from /blog/YYYY/MM/DD to just /YYYY/MM/DD. Thanks to Apache’s mod_rewrite, old links will still work, but I find mod_rewrite rules a bit of a dark art. So, for convenience and future reference, here are the rules I’ve used:

# .htaccess
RewriteBase /
# Don't redirect if URL is a real file
RewriteCond %{REQUEST_URI} !-f
# Redirect requests for /blog/some/page.html to /some/page.html
RewriteCond %{REQUEST_URI}% ^/blog(.*)
RewriteRule blog/(.*) http://chrisblunt.com/$1 [R=301,NC,L]
 
# Redirect requests for /feed to Feedburner
RewriteCond %{REQUEST_URI}% ^/feed/?(.*)
RewriteRule ^(.*) http://feeds.feedburner.com/chrisblunt [R=301,NC,L]

For now, the changed permalink structure means that Disqus comments are not available. I’ve contacted Disqus about this though, and hope to move those comments to the new format soon.

In the meantime, everything else seems to be running smoothly on Jekyll. I’ve tweaked my site’s design back to a fairly minimal theme – influenced by other Jekyll sites that I’ve seen.

I’ve kept deployments simple too; rather than using git hooks, I use a Rakefile and rsync combination based on this post. The Rakefile lets me use a fork of Jekyll to compile and upload the site with a simple call to rake deploy:

# /Rakefile
def jekyll(opts = "", path = "../jekyll/bin/")
  sh "rm -rf _site"
  sh path + "jekyll " + opts
end
 
def rsync(options = {})
  options = {
    :domain => 'servername',
    :deploy_to => 'filesystem path',
    :port => ssh_port,
    :user => 'ssh_username'
  }.update(options)
 
  sh "rsync -rtz -e 'ssh -p #{options[:port]}' _site/ #{options[:user]}@#{options[:domain]}:#{options[:deploy_to]}/"
end
 
desc "Perform a jekyll rebuild of the site"
task :build do
  jekyll
  Rake::Task["sitemap:build"].invoke
end
 
desc "Serve on Localhost with port 4000"
task :local do
  jekyll("--server --auto --limit-posts 5")
end
 
desc "Rebuild and Deploy to Live"
task :deploy => :build do
  rsync
  Rake::Task["sitemap:ping"].invoke
end
 
desc "Deploy the currently cached build to Live"
task :cached do
  rsync
  Rake::Task["sitemap:ping"].invoke
end
 
namespace :sitemap do
  desc "Rebuild the sitemap.xml using gen_sitemap.rb"
  task :build do
    generate_sitemap_bin = File.dirname(__FILE__) + "/_tools/gen_sitemap.rb"
    cmd = "cd _site && ruby #{generate_sitemap_bin} '.' > sitemap.xml"
    `#{cmd}`
  end
 
  desc 'Notify Google of the new sitemap'
  task :ping do
    require 'net/http'
    require 'uri'
    Net::HTTP.get(
        'www.google.com',
        '/webmasters/tools/ping?sitemap=' +
        URI.escape('http://chrisblunt.com/sitemap.xml')
    )
  end
end

Overall everything feels a lot lighter and easier to manage, and vim now sits at the heart of my blog workflow. This is great as I find it hard work to use any other text editor since learning vim. Static HTML means the site is served quickly as well, and I feel safe in the knowledge that my data is stored in a git repository rather than a single database.

One caveat is that the site can’t include external dynamic content; at least not without some Javascript. I figure, though, that there are plenty of ways to follow my Twitter ramblings or photostreams and so on without adding distraction to the site.

So hopefully the transition is complete. Once the Disqus comments are linked, I’ll be able to get back to writing some content to fill the blog! There’s plenty to write about, with the recent release of Rails 3 beta, and my upcoming travels. I’ll also document more about Amberleaf‘s development, post more Rails tips as I learn, and discuss a new mobile app for Android I’m starting.

Are you using Jekyll or something similar to power your site? How have you found the transition if you’ve switched from bigger engines like WordPress or Mephisto?

Switching to Jekyll

For several years now, I’ve used WordPress to power this site. As I’ve learned to use new tools for coding (vim, git and so on), WordPress has started to seem a little too heavy, especially for just writing posts. A textarea editor just can’t cut it when you’ve been using vim for a couple of years.

So I started looking for alternative blogging engines. After trying out a few Rails-powered engines, I eventually stumbled across Jekyll.

Jekyll is described as a “blog-aware static site generator”, and I set about giving it a try. After a few minutes, I knew that Jekyll was what I’d been looking for. It lets me edit my site in a text editor of my choosing, generates static HTML files (no more heavy server-side tech), and sits perfectly in a Rails-esque git push; rake deploy workflow.

So after a few days migrating from WordPress, this site is now 100% Jekyll powered: there is no back-end PHP; no database connection to worry about; and everything is versioned and backed-up through git. I’ve used a fork of Jekyll that lets me write templates in Haml rather than stock HTML.

There have been a few bumps along the way, but thanks to the growing Jekyll community and wiki, there are plenty of helpful guides and tricks available to solve any problems I’ve had. Here’s a quick overview of how I’ve switched to Jekyll.

Pure Text

Jekyll uses plain text for everything. Plain text is great – it’s small and portable; can be edited using your editor of choice, and is easily versionable using tools like git.

Deploying

With a suitable Rakefile, managing my site is as simple as writing a post and running rake deploy. Rather that git post-commit hooks, I’ve used rsync (as described in this post) to push files into my server’s blog directory.

Comments

Having no server-side scripting means that Jekyll sites have no way to submit and process comments. The Jekyll sites I’ve seen either don’t use comments, or implement them through a hosted service such as Disqus or IntenseDebate.

I like the conversation that comments bring, so I went with Disqus to manage this site’s comments. The process was fairly simple, and just involved adding a couple of