The Notepad is old and grody

How to move from Blogger to another CMS

Scribbled  · PDF · ◊Pollen source

When I started this blog it was at Blogger. I eventually decided I wanted to move the blog into a system I owned and controlled. I chose Kirby on a lark. It’s very simple; no database, just a collection of text files.

There are a lot of guides for moving from Blogger to Wordpress, but nothing about moving to any other type of blog. Nearly all of those guides are incomplete, but by adapting and adding to them I was able to achieve all my goals for the move:

1. Migrating Posts, Comments and Images

First of all, download a copy of your Blogger blog: once logged in to Blogger, go to the dashboard for your blog, then click SettingsOther. There will be a link at the top to export your blog–this will allow you to download a .xml file containing your entire blog, including your template, all configuration settings, posts and comments.

The bulk of my work in this projects was in writing a script to get the data I wanted out of that big hairy file.

The blogger2kirby script is on Github. To use it you will need Python3 and a number of libraries installed–there are simple instructions for this in the Readme file at Github.

Place the .xml file exported from Blogger in the same folder as the script, then open Terminal and run the script with the command python3

The script will create a folder called out containing subfolders for each post. These subfolders are named using a straightforward pattern:

Upload all these folders to the relevant content folder on your Kirby site and they will be available immediately.

The folders include copies of any images referenced in the post, and all image links in each post are converted to Kirby’s own format.

2. Redirecting From the Old Blog

Create a folder blogger on the server for your new website, accessible at the URL Make a file in that folder called index.php and paste in this code:

/* Make sure to replace below
   with your own blog address. /*

    $old_url = $_GET['q'];
    if ($old_url != "") {
        $tld_fix = preg_replace("/blogspot.[a-zA-Z0-9]+/", "", $old_url);
        $permalink = explode("", $tld_fix);

        $new_url = preg_replace('/.+?([^\/]+)\.html/', '$1', $permalink[1]);
        header ("HTTP/1.1 301 Moved Permanently");
    } else {
        echo "<!DOCTYPE html><html><head><title>BOO</title></head><body><h1>BOO!</h1></body></html>";

This creates a handler on your new blog that will take incoming requests from your old blog and point them to the correct location on the new blog:

Incoming request:
Redirected to:

Now that your new blog is ready to receive incoming hits, we’ll start redirecting your old blog.

You will need to revert to “Classic templates” on your old blogspot site.

Edit the template and past in the following code just before the </head> tag:

    <link rel="canonical" href="" />
    <link rel="canonical" href="<$BlogItemPermalinkURL$>" />

This does two things.

  1. It sets a link rel="canonical" tag for each page on your blog listing the new URL for that page on your new site. Several search engines (including Google) use this tag to update their search results with the new URL instead of the old one. This ensures you continue to get traffic from search engines at the new blog instead of the old one.
  2. It uses javascript to instantly redirect visitors to a page at your new blog.

Once you’ve saved this template, any hit to any page on your old blog should magically land you at the new one.

I’d advise leaving the old blog in place for as long as possible (at least a year).

Update, 4 Feb 2016