Switched to Jekyll

Posted by Moser on 15 Jan 2011

When I first installed WordPress I really liked it. But keeping it and it’s plugins up to date is a pain for me. Furthermore, running a PHP application feels kind of strange for me who feels disgust when thinking of this language. While my server does not run anything of great value, it is surely more secure not to run a dynamic application for something that is rather static.

So I decided to switch my blog to jekyll. The import of my old posts worked quite well, I just had to reformat them a bit. My layout just needed minor adaptions.

Permalinks of my WP blog were formatted according to the pattern moserei.de/index.php/:id/:slug. I could have generated a similar directory structure with jekyll, but I like the default format (moserei.de/:year/:month/:day/:slug). So I crafted a little rack app which redirects requests to old permalink URLs to the new ones.

class RedirectPermalinks
  Mapping = { '0' => "/",
              '3' => '/2008/09/15/started.html' 
               #... 
            }
  def call(env)
    id = "0"
    if env["QUERY_STRING"] =~ /p=([0-9]+)/ || 
       env["REQUEST_URI"] =~ /\/([0-9]+)\//
      id = $1
    end
    [ 301, 
      { "Content-Type" => "text/plain", 
        "Location" => "http://moserei.de#{id && Mapping[id] || ""}" }, 
      [""] ]
  end
end

It is deployed inside a directory called index.php and redirects requests to the abovementioned permalink URLs and to index.php/?p=:id to the corresponding articles. All other requests are redirected to /.

Comments are now managed by Disqus. Disqus has awesome tools for import and migration. I imported comments from a WXR file exported from WP and migrated the post URLs using a CSV file I extracted from WP’s database.

blog comments powered by Disqus