Moving from Blogger to Wordpress

Over the weekend I migrated from Blogger (hosted by Google) to Wordpress (hosted by me). Overall, Wordpress feels far superior, but the migration was not without problems. Here's a short guide to what I had to do:

Get Wordpress

First, grab the latest version of Wordpress. Being a PHP application, it just drops into a directory and works :)

Create a database, set config

Wordpress has a setup script but being a bit of a noob I couldn't give it write permission to my filesystem. If you are also afflicted by such inadequacies the following steps may help you. For clarity I'll call my DB 'wordpress'. First, set up your database:

  • mysql -u root
  • CREATE DATABASE wordpress;
  • GRANT ALL on wordpress.* TO 'wordpress'@'localhost' identified by 'wordpress';

You'll need a wp-config.php file - Wordpress comes with a default one which you can copy thusly (in the root directory of your wordpress directory):

cp wp-config-sample.php wp-config.php
cp wp-config-sample.php wp-config.php

Now edit wp-config.php, and fill in the details to make it look a little like this:

// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define('DB_NAME', 'wordpress');

/** MySQL database username */
define('DB_USER', 'wordpress');

/** MySQL database password */
define('DB_PASSWORD', 'wordpress');

/** MySQL hostname */
define('DB_HOST', 'localhost');
// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define('DB_NAME', 'wordpress');

/** MySQL database username */
define('DB_USER', 'wordpress');

/** MySQL database password */
define('DB_PASSWORD', 'wordpress');

/** MySQL hostname */
define('DB_HOST', 'localhost');

Hitting the site now should show a default Wordpress installation with some dummy content. Whoop.

Import from Blogger

Importing from Blogger is pleasingly simple - just use the Tools -> Import option on the menu. It'll ask you to verify access and then pull down all your posts and comments.

It's not perfect though - for me the post Tags were imported as Categories. To get them to be Tags again, go to the Posts -> Categories menu and use the handy Categories to Tags converter.

I found that the imported Post markup was pretty mangled (I think this is Blogger's fault, not Wordpress') -
s everywhere and no line breaks. To resolve this I cracked open mysql again and ran the following:

  • use wordpress;
  • UPDATE wp_posts SET post_content = REPLACE(post_content, "
    ", "n"); That sorted me out alright. Next we need to set up how our permalinks work. Set this in the Settings -> Permalinks menu, and use the following format to mimic the Blogger urls:

/%year%/%monthnum%/%postname%.html

Wordpress will either write a .htaccess file for you at this point, or tell you it can't write to the filesystem and give you a short text config which you must manually copy into a file called .htaccess.

One final thing to note is that Wordpress constructs its slug urls differently to Blogger (Wordpress would use 'the-trouble-with-new' vs Blogger's 'trouble-with-new', for example). If you're importing blog posts this means your urls won't always match, so any incoming links will be broken. I couldn't find an easier way to correct them than just copy/paste by hand - doesn't take long though.

Syntax Highlighting

This whole step is entirely optional.

Because I'm a geek I post code fairly often. I used the SyntaxHighlighter library back in the Blogger days and wanted to keep using it. You can install the Wordpress plugin version from http://www.viper007bond.com/wordpress-plugins/syntaxhighlighter/. The old syntax didn't seem to work, so I needed to go back into mysql and run the following:


UPDATE wp_posts SET post_content = REPLACE(post_content, "<pre name="code" class="js">", "[c0de language="js"]");
UPDATE wp_posts SET post_content = REPLACE(post_content, "</pre>", "[/c0de]");


UPDATE wp_posts SET post_content = REPLACE(post_content, "<pre name="code" class="js">", "[c0de language="js"]");
UPDATE wp_posts SET post_content = REPLACE(post_content, "</pre>", "[/c0de]");

NOTE: So that Wordpress doesn't interpret those tags above I've changed the 'o' in code to a '0'. You need to change it back :)

This just swaps all your old

 and 
tags for [c0de language="js"]and [/c0de] respectively. Repeat the first line for any other languages you have used (for me this was xml, css, html and ruby).

Fixing feeds

Wordpress doesn't like the world to see your content via RSS. Odd, isn't it? There's an option in Settings -> Reading which claims to output the full text of each article into your feed, but it doesn't seem to work. Instead, what you need to do is hack your theme a little. You'll need to edit the wp-includes/feed-rss2.php file and change line 47 from <?php the_excerpt_rss() ?> to <?php the_content() ?>.

If you're using Feedburner or similar, don't forget to give it your new feed url too. In this case you should also update wp-content/themes/yourTheme/header.php and swap out the occurrences with your Feedburner url.

Upload and update DNS

At this point everything should be working nicely, so upload your blog folder and update your DNS settings. I'm guessing if you're hosting Wordpress yourself you don't need help with this. I've made my own blog into a git repository up on Github, allowing me to deploy any changes I make using Capistrano. It's a nice solution - for more information see this lovely post by the gentlemen at imedo.

Share Post:

What to Read Next

On Leaving Sencha

As some of you may know, I left Sencha last week to move to another startup just up the road in San