Blogger to WordPress migration

March 10th, 2010 by Alistair MacDonald Leave a reply »

This blog post summarises my move from a Blogger blog that is published using the (soon to be deprecated) FTP publishing, to a locally installed version of WordPress. My aim is to keep a majority the URLs the same, and seamlessly redirecting users and search engines on the ones I can not. I suggest at least skimming the blog post before starting the move. I also strongly recommend not skipping the backup. Okay, let’s go…

The first thing to do is to set up new installation of WordPress. This is well documented else where so I will not go through that here. I am assuming you have the technical ability to do that, and if you do not then perhaps WordPress is not for you.

Next make a backup of your Blogger blog. Do this by selecting “Export blog” from the “Basic” settings on the “Settings” tab in Blogger. This is important as the migration process will destroy your comments and loose other settings. If it goes wrong you will need this file to go back and try again.

Next you need to switch your blog to a “” address for an FTP published blog. To do this select “Publishing” from the top of the “Settings” tab in Blogger, click to option to switch to “ (Blogger’s free hosting service)”, enter a temporary Blog*Spot address (that can be literally any text and you don’t need to remember it) and save the settings.

We are now ready to import the blogs in to WordPress. Log in to WordPress and select “Import” from the “Tools” menu. Select Blogger (obviously) , click the “Authorise” button, and then “Grant Access”. With luck You should be able to click the import button next to the blog you want to, well, import. Wait while it does it’s magic. For some reason it thought I had fewer comments than I did that made the progress bar go mad, but I left it a while and it worked okay.

Next to fix the premalinks.

Set the WordPress permalinks setting so the format reflects your current blog. You can finds the setting in “Permalinks” from the “Tools” menu. If your old archive settings were for monthly archives with a php extension (like mine) then your new setting will be “/%year%/%monthnum%/%postname%.php”. Add a “/%day%”, remove the “/%month%”, or change the “.php” as required. Remember to created the .htaccess file as requested when saving. If you archived by week then my apologies, but you are on your own with that one as there is no direct mapping between old and new.

Now to change the “slugs” so that the new post URLs are the same as the old ones. To do this we need to run some SQL and I will have to leave you to figure out how to do this on your hosting provider. Most ISP control panels will have a link to phpMyAdmin somewhere.

You can optionally find out what will need to be changed by running the following. This is totally optional and you don’t need to run this if you don’t want to. Not that if you run this at any time you unpublished posts will show up as hey don’t have any slug yet.

SELECT posts.`post_name`, meta.`meta_value`
FROM `wp_posts` AS posts, `wp_postmeta` AS meta
WHERE ( posts.`ID` = meta.`post_id` ) AND ( meta.`meta_key` = 'blogger_permalink' ) AND ( posts.`post_name` <> SUBSTRING_INDEX(SUBSTRING_INDEX(`meta_value`,'.',1),'/',-1) )

If you changed the default settings when installing WordPress remember to replace the “wp_” prefix with the one you changed it to. Do this will all the SQL in this post.

One difference between Blogger and WordPress is that Blogger allows you to have multiple posts with the same files names posted of different days, weeks, months or years (depending on your old Blogger settings), while WordPress requires a unique “slug” filename regardless of the date. With four years of blogging I have been lucky and had no duplicates. If you do have a duplicate then WordPress will rename one of them by editing the post after the import. You can find out how many times each name is used by running the following (rather quick and messy) SQL…

SELECT SUBSTRING_INDEX(SUBSTRING_INDEX(`meta_value`,'.',1),'/',-1), COUNT( SUBSTRING_INDEX(SUBSTRING_INDEX(`meta_value`,'.',1),'/',-1) )
FROM `wp_posts` AS posts, `wp_postmeta` AS meta
WHERE ( posts.`ID` = meta.`post_id` ) AND ( meta.`meta_key` = 'blogger_permalink' ) AND ( posts.`post_name` <> '')

If you have a duplicated name where count is greater than 1, then make a note of it and rename one of them after the import. If you want to make the old URL point at the new page you will need to add something to the htaccess file.

Now we are ready to change the slugs. To do that just run the following SQL script…

UPDATE `wp_posts` AS posts, `wp_postmeta` AS meta
SET posts.`post_name` = SUBSTRING_INDEX(SUBSTRING_INDEX(meta.`meta_value`,'.',1),'/',-1)
WHERE ( posts.`ID` = meta.`post_id` ) AND  ( meta.`meta_key` = 'blogger_permalink' ) AND ( posts.`post_name` <> '')

Now we need to fix the links to the archives and the labels. To do this I got the server to direct the browser from the old URLs to the new ones using a 301 (permanent) redirect.

First I create a directory called “archive”, create a file in it called “.htaccess” and cut and paste the following code in to it…

RewriteEngine On
RewriteBase /blog/
RewriteRule ^([0-9]+)_([0-9]+)_([0-9]+)_(.*)$ $1/$2/ [R=301,L]

My blog is stored in a subdirectory “blog”. Simply change the RewriteBase line to reflect your blogs location. If you used the day in your old archives then add “$3/” after “$2/”, and remove the “$2/” if you archive by year.

Now for the labels create a directory called “labels”, create another file in it called “.htaccess” in it, and cut and paste the following code in to it…

RewriteEngine On
RewriteBase /blog/
RewriteRule ^(.+)\.(.*)?$ category/$1/ [R=301,L]

Again change the RewriteBase for your blog. This should work whatever your blog settings are.

Finally the RSS feed has also changed so add the following to your blog’s main .htaccess file.

RewriteRule ^atom\.xml$ /feed [R=301,L]
RewriteRule ^rss\.xml$ /feed [R=301,L]

If you don’t want to take down your web site while you are doing this then you can install the blog elsewhere to do the port, and then move the WordPress install in to place. You will also need to change all the references in the database from the temporary URL to the normal one. Just changing the settings in WordPress is not enough. I did the install on a subdomain using the same file structure at the live site, backed up the database as SQL (after the port), did a find a replace of the SQL replacing the temporary domain name to the normal one, and finally run that SQL to replace the old data. Then when I copied the WordPress files across it just worked.

I hope this is of help and I wish you luck in your move. I really can not help with dozens of noddy questions, but if you are really stuck then feel free to get in touch and I sell see if I can help.

UPDATE: There appears to be a bug affecting at least a few of us. The WordPress import process is only importing the latest 50 comments. To work around this follow import process above, but after the posts have been migrated, and before running the scripts, do the following. Delete all the comment on the blog (to avoid duplicates), run your Blogger backup through and import the file produces. I am hoping that is all you need to do and you can continue with the instructions above. Personally I then had to manually go through the log of imported posts and manually merge them, and if you have run the scripts then you will need to do the same, but I an hoping you will not need to do this if you do not run the scripts first.

i love Quidco GreenWhite


  1. alistair says:

    I almost forgot to mention, don’t forget to leave the directories uploaded_files and uploaded_images in place as your old posts on the new blog still link to them.

  2. Jim says:

    I thought I had everything working, and then I discovered that WordPress was only importing part of my comments.

    I had used a lot of your ideas and another quick and easy script to change all the posts back to their original file names that were being used by the FTP Blogger system of posting.

    However, like I said, I soon discovered that only part of the comments were being imported to the new WP system on my server. So, I tried deleting the new imported Blogger to WP posts and tried again with a fresh import. Same exact thing.

    I don’t have the option on my WordPress blog to import from an XML Blogger exported and saved local file. But, at and the blogs that are hosted there, there is an option to import from an XML file. Do you know the details about this and getting the XML file import option via a plugin to WordPress?

    I was ready to go live, and then after this discovery, I had to revert back to using the old files and folders at my website. I had everything tested out, including new .htaccess files at various locations and then this slight roadblock showed up.

    By the way, it seems that if I have over 40 or 50 comments in a posting, only the first 40 or 50 get imported. I have several posts with over a hundred comments.

    Any info would be much appreciated.



  3. alistair says:

    Bother, well spotted. It appears that the WordPress import will only bring in 50 comments maximum at the moment.

    I have got all the comments in by using although the Blogger labels are brought in as tags and not categories, and the “slugs” are lost so all the URLs will not be the same. If this is not a problem for you then great, just amend the htaccess file in the labels directory to reflect this change.

    In the end I pulled in this converted export and used a plugin to move all the comments manually. It took a while, but I wanted the labels as categories.

  4. Jim says:

    By the way, now I have two of every posting imported.

    Another bit of information that I found out is, you can actually make the posting exactly as it was prior to the import by using the manual mode at the top of the WP editor page. Simply copy what the original article naming convention was, and if you have custom permalinks configured, you can edit the field: Permalink: at the top of the editor page. You can only change the file name, not the entire location or ending file naming convention which is set and assigned from the WordPress settings, Permalink page information.

    I think I will simply go through and edit my postings that have lots of comments, and revert these manually to the proper file names, and manually assign the categories. I’ll simply compare notes between one posting and the other. I have about 70 postings to configure, though some of them are 4000 + words long.

    Also note that Flash embedded in a posting is not properly imported using the online script application. It comes in as a long link only. The online script does do a good job on the comments though.

    What I plan to do in this case is copy and paste from one posting to the other, so the comments and the Flash are properly embedded.

    Once I get these configured properly, I will then attempt the final switch to make it live.

    Additionally, because I loaded WordPress in a subdirectory, which I had not used before, I found out that it is simple to make the WP blog appear as though it is at the root (public_html) level of the blog. I need to do this because my largest blog was at the root directory of the website. In fact, I found this posting at WordPress about keeping all the files for WP in its own directory while making it appear that the blog is at the root. Since I already had the blog at its own directory, I tried following this procedure: and it works great. I then did some tweaking of the .htaccess files (that you had come up with) and was able to remove the subdirectory from the WP blog postings to make them exactly the same as they were with Blogger. I’ll share the details for the archives and the labels/categories once I get through the import comments mess.


Leave a Reply