Blogging

How to migrate or move your blog from Blogger to WordPress without losing Google search traffic.

Suppose your blog (abcxyz.blogspot.com) is hosted on Blogger but now you would like to move the blog from Blogger to WordPress (self-hosted) with your personal domain name like abcxyxz.com then don’t worry you can follow easy steps and easily make the changes.

But before proceeding take backup of your blog including the XML template,blog posts and comments.

Now:

1. Purchase a domain from any web registrar like GoDaddy and buy hosting space and install WordPress on your new domain.

2.Open your WordPress Admin Dashboard and under Tools-> Import, select the Blogger option. Authorize WordPress to access your Blogger Account and select your (blogspot.com) blog and within few minutes all your Blogger blog posts and comments will be available on the new WordPress site.

3.Now Open the WordPress themes editor under Appearance -> Editor and open the functions.php file for editing. Also you can upload it manually into your WordPress themes folder through cPanel or FTP. Copy-paste the following lines of code inside your functions.php file (at the beginning of the file) and click the “Update File” button to save your changes.

Code Snippet:

<?php
 
function myblogger_query_vars_filter( $vars ) {
 $vars[] = “blogger”;
 return $vars;
}
 
add_filter(‘query_vars’, ‘myblogger_query_vars_filter’);
 
function myblogger_template_redirect() {
 global $wp_query;
 $blogger = $wp_query->query_vars[‘blogger’];
 if ( isset ( $blogger ) ) {
   wp_redirect( myblog_get_wordpress_url ( $blogger ) , 301 );
   exit;
 }
}
 
add_action( ‘template_redirect’, ‘myblogger_template_redirect’ );
 
function myblog_get_wordpress_url($blogger_slug) {
 global $wpdb;
 if ( preg_match(‘@^(?:https?://)?([^/]+)(.*)@i’, $blogger_slug, $matches) ) {
   $q = “SELECT guid FROM $wpdb->posts LEFT JOIN $wpdb->postmeta
         ON ($wpdb->posts.ID = $wpdb->postmeta.post_id)
         WHERE $wpdb->postmeta.meta_key=’blogger_permalink’
         AND $wpdb->postmeta.meta_value=’$matches[2]'”;
   $wp_url = $wpdb->get_var($q);
 }
 return $wp_url ? $wp_url : home_url();
}
 
?>

4. Now Open your Blogger Dashboard and choose Templates. Move down the templates page and choose the “Revert to Classic Templates” option to switch from the XML-based Blogger templates to Tag based templates.

5. Copy-paste the following snippet of code into your Blogger template editor but before you do that, replace all occurrences of abcxyxz.com with your WordPress site URL. For example, if your WordPress site is located at example.com, replace abcxyxz.com with example.com and paste the modified code snippet in the template editor and  save the changes.

1. <html>
2. <head>
3.    <title><$BlogPageTitle$></title>
4.    <script>
5.      <MainOrArchivePage>
6.          window.location.href=’http://abcxyxz.com’
7.      </MainOrArchivePage>
8.      <Blogger> <ItemPage>
9.          window.location.href=’http://abcxyxz.com/?q=<$BlogItemPermalinkURL$>’
10.      </ItemPage> </Blogger>
11.    </script>
12.    <MainPage>
13.      <link rel=”canonical” href=”http://abcxyxz.com/” />
14.    </MainPage>
15.    <Blogger><ItemPage>
16.      <link rel=”canonical” href=”http://abcxyxz.com/?blogger=<$BlogItemPermalinkURL$>” />
17.    </ItemPage></Blogger>
18. </head>
19. <body>
20.    <MainOrArchivePage>
21.        <h1><a href=”http://abcxyxz.com”><$BlogTitle$></a></h1>
22.    </MainOrArchivePage>
23.    <Blogger><ItemPage>
24.        <h1>
25.          <a href=”http://abcxyxz.com/?blogger=<$BlogItemPermalinkURL$>”>
26.            <$BlogItemTitle$>
27.          </a>
28.        </h1>
29.        <$BlogItemBody$>
30.    </ItemPage></Blogger>
31. </body>
32. </html>

6. Now just check out and open your old blogger page and now it will redirect you to your new corresponding WordPress page.Here we have used 301 redirect and all your ranks and search criteria will be retained as it was in your old blogspot.com blog.

Hope this works fine ….Happy Blogging.

Feeling glad to receive your comment