Redirecting from Blogger to WordPress

I’ve just moved my blog from Blogger (blogspot) to a self hosted WordPress installation. I’ve imported all posts with the Blogger importer available in WordPress.

The only problem left was that my “old” Blogger blog was still getting more traffic and the new one none. So I needed to:

  • redirect from the old one to the new one.
  • make sure Google doesn’t penalize me for non-unique content
  • make the redirect clever enough to redirect to the right post

There are plugins for this and also many web sites showing how to it, unfortunately none worked for me (some problems on the Blogger side…). So here’s how I finally got it working:

First you have to cope with the different permalink structures between Blogger and my WordPress install:
/YYYY/MM/POST_TITLE.html in Blogger
/POST_TITLE.html in WordPress

And also with the fact, that posts don’t always have the same name in Blogger and WordPress (e.g. if you had no title first when the post was created in Blogger and added one later, the post in Blogger would have the first words in the post content as path and the imported one would have the title as path).

The easiest way to cope with all this is to use the wordpress plugin SEO Blogger to WordPress using 301 Redirection. The UI for this plugin can be found in “Tools” but the code generated by this tool for Blogger wasn’t working (at least with the new Blogger interface). So I had to take care of the rest myself…

Then you need to configure a redirect with JavaScript:

Log into your Blogger account and click your way to the “Template/Edit HTML” page.

Search for a line with <script type=’text/javascript’> and add the following lines before the first line found:

<script type=’text/javascript’>
location.href=document.location.toString().replace(document.domain,’NEW_DOMAIN_NAME’);
</script>

(Replace NEW_DOMAIN_NAME by your new domain name)

This basically says to change the URL by replacing the current domain (e.g. benohead.blogspot.de) by the new domain name (e.g. benohead.com).

In case, the user has disabled JavaScript, we’ll implement a less clever redirect, which will just redirect to the home page of the new blog:

In Blogger, “Template/Edit HTML”: Add the following line just after <head>:

<meta content=’5;url=http://NEW_DOMAIN_NAME/’ http-equiv=’refresh’/>

(Replace NEW_DOMAIN_NAME by your new domain name)

Now, we do not want Google to penalize our new blog for duplicate content, so we’ll instruct Google to remove our old blog from their cache by adding the following line just after <head>:

<meta name=”ROBOTS” content=”NOINDEX, NOFOLLOW”/>

Since we’re basically only loading the old site/posts to redirect to the new blog, it’s a good idea to make it as fast as possible e.g. by removing all gadgets from the layout.

Update:

In order to have your new “old” posts (I mean the old post on the new domain) seen by search engines like Google as the same page as the post in Blogger, you need to add a canonical URL tag (since it’s not possible to setup a 301 redirect in Blogger).

Google, Bing and Yahoo! are all supporting the canonical URL tag since 2009 (and cross domain canonicals are now also accepted). Using this tag, you basically tell the search engine which is the preferred page in a set of pages with the same content i.e. “please only index the specified page”. This canonical URL tag needs to be added to all non-canonical versions of this page.

In order to add this tag in our Blogger blog, the following piece of code should be added between <head> and </head> in the Blogger template:

<b:if cond=’data:blog.pageType == &quot;item&quot;’>
<link rel=”canonical” expr:href=’&quot;http://NEW_DOMAIN_NAME/?blogger=&quot;+data:post.url’ />
<b:else/>
<link rel=”canonical” href=”http://NEW_DOMAIN_NAME/” />
</b:if>

This basically checks whether we’re displaying a single post. In this case we reference the appropriate post in WordPress. Otherwise we reference the main page.

5 thoughts on “Redirecting from Blogger to WordPress

  1. two questions that may seem really silly but I am not sure.

    When adding the line to keep Google from penalizing you say add after <head> does that mean it goes between and the line we just added as

    Also for your update you say to add it between and There is a ton of content in between. Do I literally just add it anywhere I want? Is there a place that is best to add to?

    1. The meta tags can be added anywhere between <head> and </head>. It doesn’t really matter in which order or where exactly between these two tags.
      This is also true for the part. All these lines should be together but it doesn’t really matter where in the <head> it is.

      And there are no silly questions. Hope this helps.

  2. Well done! Many thanks! But why not have this job done automatedly? Recently came across an online tool (CMS2CMS, if I’m not mistaken) and managed to convert to WordPress by myself, not hiring any programmer. Good solution – cheap and fast. Followed this video tutorial
    http://www.youtube.com/watch?v=Elf02SGc02E
    Hope, it will help you…

Leave a Reply

Your email address will not be published.