Important: Before you start the migration, it may be a good idea to backup your Blogger blog including the XML template, blog posts and comments just to be on the safe side.
- Register a new web domain, buy hosting and install WordPress on your new domain.
- Open your WordPress Admin Dashboard and under Tools -> Import, select the Blogger option. Authorize WordPress to access your Blogger Account, select your blogspot.com blog and within minutes, all your Blogger blog posts and comments will be available on the new WordPress site.
- Open the WordPress themes editor under Appearance -> Editor and open the functions.php file for editing. Most WordPress themes include a functions.php file or you can upload it manually into your WordPress themes folder through cPanel or FTP. Copy-paste the following snippet of code inside your functions.php file (at the beginning of the file) and click the “Update File” button to save your changes.
- <?php
- function labnol_blogger_query_vars_filter( $vars ) {
- $vars[] = "blogger";
- return $vars;
- }
- add_filter('query_vars', 'labnol_blogger_query_vars_filter');
- function labnol_blogger_template_redirect() {
- global $wp_query;
- $blogger = $wp_query->query_vars['blogger'];
- if ( isset ( $blogger ) ) {
- wp_redirect( labnol_get_wordpress_url ( $blogger ) , 301 );
- exit;
- }
- }
- add_action( 'template_redirect', 'labnol_blogger_template_redirect' );
- function labnol_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();
- }
- ?>
- Open your Blogger Dashboard and choose Templates. Scroll down the templates page and choose the “Revert to Classic Templates” option to switch from the XML-based Blogger templates to Tag based templates.
- Copy-paste the following snippet into your Blogger template editor but before you do that, replace all occurrences of labnol.org with your WordPress site URL. For instance, if your WordPress site is located at example.com, replace labnol.org with example.com and paste the modified snippet in the template editor. Save the changes.
- <html>
- <head>
- <title><$BlogPageTitle$></title>
- <script>
- <MainOrArchivePage>
- window.location.href='http://labnol.org/'
- </MainOrArchivePage>
- <Blogger> <ItemPage>
- window.location.href='http://labnol.org/?q=<$BlogItemPermalinkURL$>'
- </ItemPage> </Blogger>
- </script>
- <MainPage>
- <link rel="canonical" href="http://labnol.org/" />
- </MainPage>
- <Blogger><ItemPage>
- <link rel="canonical" href="http://labnol.org/?blogger=<$BlogItemPermalinkURL$>" />
- </ItemPage></Blogger>
- </head>
- <body>
- <MainOrArchivePage>
- <h1><a href="http://labnol.org"><$BlogTitle$></a></h1>
- </MainOrArchivePage>
- <Blogger><ItemPage>
- <h1>
- <a href="http://labnol.org/?blogger=<$BlogItemPermalinkURL$>">
- <$BlogItemTitle$>
- </a>
- </h1>
- <$BlogItemBody$>
- </ItemPage></Blogger>
- </body>
- </html>
We
are almost done. Open any page on your old Blogger blog and it should
redirect you to the corresponding WordPress page. We are using a
permanent 301 redirect on the WordPress side and therefore all the
Google Juice and PageRank should pass to your new WordPress pages with
time (video).
The above method works for regular blogspot.com URLs and also country-specific Blogger domains like blogspot.co.uk or blogspot.in that Google added about an year ago to better handle censorship related requests.
The
Blogger Import tool moves only posts and comments from Blogger to
WordPress but not images. And that should be fine because the image URLs
in your imported WordPress posts are still pointing to blogspot.com
(where the images were originally hosted) and therefore nothing would
break.
Switch RSS Feed from Blogger to WordPress
When
you move from Blogger to WordPress, the URL of your RSS feed will change
as well. Go to Blogger -> Settings -> Other and choose Post Feed Redirect URL
under Site Feed. Here you can type the web address of your new
WordPress RSS feed here and the existing RSS subscriber will
automatically move to your new feed.
If you are using FeedBurner, just replace the source from Blogger RSS feed to your new WordPress feed.
Post a Comment