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]((http://disqus.com/) comments are not available. I've contacted [Disqus](http://disqus.com/overview/) 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](http://tom.preston-werner.com/) by [other](http://alexyoung.org/) Jekyll [sites](http://wiki.github.com/mojombo/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](http://tatey.com/2009/10/29/simpler-deployment-for-jekyll-using-a-rakefile-and-rsync/). The Rakefile lets me use [a fork of Jekyll](http://github.com/cblunt/jekyll) to compile and upload the site with a simple call to `rake deploy`:

```ruby# /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](https://twitter.com/cblunt) or [photostreams](http://flickr.com/photos/cbl2001) 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](http://weblog.rubyonrails.org/2010/2/5/rails-3-0-beta-release/), and my upcoming travels. I'll also document more about [Amberleaf](http://bit.ly/5C5iL9 "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](http://github.com/mojombo/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?