How I Beat Blogger and Redirected to WordPress

closeThis post was published 8 years 10 months 26 days ago. A number of changes have been made to the site since then, so please contact me if anything is broken or seems wrong.

Yes, I really and truly have migrated to WordPress from Blogger. I know there are a lot of guides out there, but I think the method I used was different enough to warrant a new post. (I won’t duplicate the steps of setting up the new WordPress site and importing the content from Blogger; that’s pretty obvious, and it’s well covered elsewhere. Redirecting is the art form that’s been changing every few months.)

Obligatory Rant

Getting away from Blogger is really much harder than it should be. There should be a process to verify with Google that one is not a spammer trying to get free link juice etc. and have the 301 redirects with the Custom Domain feature specifically enabled for the blog one wishes to move. Hackery like what I came across, and what I used, shouldn’t be necessary. Blogger should natively support moving away from its platform, even if it might require a little human intervention on Google’s end.

It’s really too bad that Google is so horrible with customer support. Their products are, generally, really great, but if you run into a problem it had better be something common that others have run into. Your only option, in most cases, is to post in a public support forum and cross your fingers. Fortunately the problems I’ve encountered have been few, though I am getting increasingly irritated with every issue.

The Premise

Way back in the day, Blogger used to offer 301 Moved Permanently redirects via its Custom Domain feature, even for domains not set to CNAME to ghs.google.com, but I guess spammers were abusing the feature because that ability went away. For a while now, it’s been showing an interstitial page to visitors instead of redirecting, warning visitors and crawlers that the site is now redirecting to an untrusted domain. This passes no link juice, and is incredibly inconvenient and unsightly for everyone.

I did a lot of research beginning when I returned from my long summer. In between college applications, family trips, and so on, I performed search after search for methods of migrating away from Blogger to a self-hosted WordPress site. I found a plugin to restore the old Blogger post slugs (to make redirection easier), but every redirect method I came across was in some way outdated and/or broken—until I happened to find Digital Inspiration’s method: A Classic Blogger template specially configured to issue canonical links tags, JavaScript redirects, and a big <h1> anchor link to the new site.

Digital Inspiration redirected all traffic to the old site to a special page on the new server, built to handle redirections. A PHP script was offered, but I didn’t take that bit. I found a nifty WordPress plugin instead: Redirection by urbangiraffe.com. With two plugins (Redirection and Maintain Blogger Permalinks, mentioned below) and the Digital Inspiration template generator, I was ready to develop my method.

Introduction

Before you do this kind of thing, make sure you run a plugin like the one mentioned here to convert the slugs for posts imported from Blogger to the Blogger format, so they’ll match up with the redirects. If you don’t, any posts with “small words” (“and”, “the”, etc.) in the title and posts with lengthy titles will have issues once you switch to the new site.

Also note that you may need to set the number of posts to display on the home page to 1 on Blogger’s end. I had a last-minute bug when I implemented this for real that I didn’t catch on the test site because I only created one nonsense post. Imagine how frustrating it was to suddenly have seven copies of each <Blogger> section on the page. (Now that I think about it, that’s probably why the DI generator kept the homepage stuff out of those sections. But you should change the setting anyway just to be safe.)

Finally, note that, contrary to what a lot of migration guides say, you don’t have to set your permalink structure in WordPress to match Blogger’s. If you don’t want your post URLs to end in .html, they don’t have to. Apache .htaccess rewrites and/or the Redirection plugin will be your friend(s). I chose to simply convert the .html into a / but you can pretty much do whatever you want. I’ve also found that WordPress is capable of redirecting links of the format http://domain.tld/post-slug-here/ to the fully-qualified permalink all by itself, so use that as the target if you want to use a permalink format that doesn’t match up with Blogger’s. Note: I haven’t personally tested this, but given what I know of how WordPress handles things, it should work fine. Use at your own risk, etc. etc., don’t blame me if it won’t work, etc. etc. But you’re welcome to ask for help, of course. 😉

Development

I started with a redirect template generated using Digital Inspiration’s generator and set up a Blogger handler in Redirection on the new WordPress site, modifying the newly generated Blogger template accordingly. (DI‘s generator defaults to /blogger/ which I didn’t want; it might eventually conflict with something. I used a more action-oriented /handle-blogger, removing the trailing slash.) The redirect I used was: /handle-blogger\?q\=http\:\/\/voyagerfan5761\.blogspot\.com(\/.+) -> $1

I began developing this solution well before discovering the magic bullet at Digital Inspiration. One of my first steps after installing WordPress was to add mod_rewrite redirects in my .htaccess file so I’d be prepared for redirections from Blogger. Once the handler was in place, I transferred my Apache redirection rules to the Redirection plugin in WordPress:

  • Posts: /([0-9]{4})/([0-9]{1,2})/([^/]+)\.html(\?.+)?$ -> /$1/$2/$3/$4
  • Categories (labels): /search/label/(.+)(\?.+)?$ -> /category/$1/$2+
  • Monthly archives: /(\d{4})_(\d{2})_\d{2}_archive\.html(\?.+)?$ -> /$1/$2/$3

+ – Still need to figure out how to transform this to lowercase and change %20s to hyphens.

Update (02/14): I discovered that query strings killed the redirects and led to 404s. I changed $ to (\?.+)?$ at the end of each regex as well as added extra corresponding backreferences ($4 for posts, $2 for categories/labels, and $3 for monthly archives) to fix it. All query strings are kept, even if they’re meaningless on the new site, but otherwise it would be a pain to whitelist only the useful ones. I’ll update again with blacklisted query parameters if I discover a Blogger query parameter that breaks something in WordPress.

Once I had all the handling pieces in place on the new site, I tested the Blogger template on a test blog. During my testing, I found room for improvement. For instance, I read in my research that a meta refresh tag, used with a delay of 0, is often treated as a 301 redirect by search engines. I added refresh tags to the template.

I also found that Blogger tries to thwart JavaScript calls to window.location.href by placing script tags on the line following the call and invalidating the entire block. I defeated that by placing a multi-line comment starter after the semicolon, wrapping the block in <![CDATA[...]]>, and creatively faking out Blogger. It still inserts the extra tags, but they don’t harm anything because I used trickery to force Blogger to place them inside a comment block (where they’re just ignored).

In case future changes to Blogger break the template—and I’m sure that Google will do something to break my setup eventually—I added a link to my new contact page for users to tell me if it’s not redirecting.

The template does everything I need it to do. With the Redirection plugin, I didn’t need to use the PHP script provided in the Digital Inspiration post. I should also get better results from the migration because of the extra work I put into my template; feel free to get a copy for yourself. If you use it, please leave the existing comment block at the top intact. Both the original authors at Digital Inspiration and myself will appreciate it. I also plan to share my improvements back to DI.

Conclusion

Satisfied with my testing and confident of the results, I implemented the template on my real old Blogger site a couple days ago, where it seems to have been chugging along nicely ever since. If it breaks, and I don’t notice, I’m sure someone will take the time to use the contact link I added and let me know. The link might cause a few issues with search crawlers, but I think I’m OK with it. Misdirected link juice is better than broken functionality.

Of course, this is the technique that worked for me. Like all the others I found, I’m sure this one too will become oudated and/or broken with time. But for now, it seems to be the best method for escaping the clutches of Blogger.

Update (01/23): A reader pointed out in the comments that IE6 might not follow the redirect. If your site has a significant fraction of readers using IE6, keep that in mind. I won’t worry about it for my site just because most of you use something more recent.

dgw

I am an avid technology and software user, in addition to being reasonably well-versed in CSS, JavaScript, HTML, PHP, Python, and (though it still scares me) Perl. Aside from my technological tendencies, I am also a theatre technician, sound designer, violinist, singer, and actor.

3 Comments:

  1. I tried using ie6, the site is not redirecting. It is keeping on pinging the redirection.
    I tried chrome it is getting redirected.

    • Thanks for letting me know, ramkumar. Somehow it doesn’t surprise me that IE6 is mishandling the redirect, but since few of my visitors use that browser I won’t worry about it too much.

  2. beating blogger and redirecteding to wordpress is very had work

Leave a Reply

Your email address will not be published. Required fields are marked *

Notify me of followup comments via e-mail (or subscribe without commenting)

Comments are subject to moderation, and are licensed for display in perpetuity once posted. Learn more.