Redirecting *.tumblr.com Pages to your Blog

by Cosmo Catalano

I’ve talked before about my much-diminished stoke for Tumblr as a platform.

Fortunately, I’m not the only one who sees things this way, and a lot of great tools exist to help you migrate your setup to WordPress. There’s a built-in tool that pulls in your Tumblr blog into a WP install more-or-less intact, and if you are using a custom domain, you can point it to your WordPress install and use this plugin to redirect your old URLs in a line of code.

But what to do about all those [your-account].tumblr.com URLs? Granted, they probably have terrible search rank, since Tumblr’s not great at that, but they’re still there, they still have your same content, and some people might still be using links to them. Tumblr has 301 redirect support for Pages, but alas—they’ve cleverly disabled it for Posts:

Tumblr's pop-up blocking your attempt to redirect

However, Tumblr is cool in that they let you have compete access to the page source, which opens the door for all sorts of fun tricks. With a touch of JavaScript, we can quickly and simply redirect our old pages to their corresponding new locations on your new blog. Note that this specific code snippet will work only if you’ve used the WordPress importer and set up the redirect plugin as described in the second paragraph.

//Inside of <head>
<meta name="description" content="this is a legacy blog page, and will redirect to the same post on my new blog">
<script type='text/javascript'>
   var new_slug = window.location.pathname;
   var new_root = "http://your-new-url.com";
   var new_url = new_root + new_slug;
   document.write("<link rel=\"canonical\" href=\"" + new_url + "\">");
</script>

//Inside of <body>
 <script type='text/javascript'>
    window.location = new_url;
</script>

You’ll notice that I’ve split the code into two sections—one for <head> and one for <body>. That’s because this sort of JavaScript redirection is regarded as something of a Google no-no. It’s not that big a deal—the brunt of the SEO penalty would be borne by your Tumblr site, which you’re redirecting people away from anyway—but since Penguin took a critical eye toward incoming links, I decided I’d attempt to try and indicate, with a rel="canonical" and a helpful meta description, why this redirect was happening.

I know what you’re about to say: search crawlers don’t read JavaScript, and at any rate, the header is parsed before the JS executes. Well, kinda—spiders don’t execute the code like your browser would, but there’s mounting evidence they can tell what’s going on, and are getting better at it.

While it’s a bit optimistic to assume this oddball code is readable, I prefer to be specific about what’s going on and risk being misunderstood. But if you’re nervous about SEO impact, a noindex meta and redirect script in the body only might be a better solution:

//Inside of <head>
<meta name="robots" content="noindex">

//Inside of <body>
 <script type='text/javascript'>
   var new_slug = window.location.pathname;
   var new_root = "http://your-new-url.com";
   var new_url = new_root + new_slug;
   window.location = new_url;
</script>