Thursday, 29 March 2012

How to import a Tumblr blog into WordPress

How to import a Tumblr blog into WordPress

Tumblr to WordPress
I feel like standing in front of a rail crossing, when the red lights just won’t go off. Is it worth driving to the next rail crossing, just a minute further down the road? Are the lights defective, or is the crossing closed for a true reason? The longer I wait, the less it will be worth driving off.
As a metaphor, that is how I feel waiting for . I have a dozen blogs on Tumblr, many of them are aggregators, creating blogposts from imported RSS feeds. I know (the self-hosted version) has a cute aggregation plug-in that does the same job, so should I move to WordPress, or wait for Tumblr to solve its problems?
Each of my Tumblr blogs has thousands of posts, so migrating them won’t be a small feat. Plus I will have to install a new blog on my server, redo the theme-ing, install the plug-ins etc.. before the blog goes live. Maybe Tumblr will solve its problems tomorrow? Or the day after, or the next? Or maybe I will discover new problems with the WordPress aggregator tool that will keep me busy for days too…?
Well, ladies and gentlemen, after standing in front of the rail crossing for weeks, I decided to move one blog as a trial. The original blog (I left its remains on Tumblr) contained 20,000 blogposts ( ! ), and I did not want to lose those. So one of the main challenges to move my Tumblr blog to WordPress was to migrate all blogposts. All 20,000 of them…
Here is how I did it:

There are three steps in migrating your Tumblr blogposts to WordPress:

Step 1: Export your Tumblr posts
Step 2: Process your exported Tumblr posts (optional)
Step 3: Import the export file into WordPress

Step one. How to export your Tumblr blogposts?

Tumblr does not feature an “export function”. I found a list of possibilities, but none really suited me, until I stumbled upon Tumblr2WordPress (by Ben Ward). And Ben saved my day.
Just run Tumblr2WordPress, enter your blog’s Tumblr subdomain (don’t use your custom domain), select if you want to export to (the WordPress hosted blogs) or (for selfhosted blogs) and … click export. The exported posts will be downloaded onto your PC, as an .XML file…
That should do it for most Tumblr blogs.
(Update March 1, 2010: Ben’s source code is still available, but the executable program is no longer available on this link. You can still run similar code from Tumblr2WP or Tumble2WordPress – With thanks to Aaron and Parneix for the updates)
If you get an error “Tumblr API Request Failed”, this means -once again- Tumblr is failing (as it does frequently in the past months), and the API request to export the posts gives an error. Try it out manually with a command like: – If you get an error, the only thing you can is “try again later”.
At the time of writing, it seems Tumblr is blocking API-calls during the US-day time (afternoon and evenings mostly)…
If you are a freak, like me, and have 20,000 posts in your blog, Ben’s routine might give a time-out. I had to download the PHP source code and install it on one of my servers, so I could dramatically increase the system resources. For the nerds amongst you, I put the PHP code in a subdirectory, and added a php.ini file to it, with the following parameters:
upload_max_filesize = 20M
post_max_size = 30M
memory_limit = 400M
max_execution_time = 600
… but again, 99% of you might not have 20,000 blogposts, so Ben’s hosted routine will do just fine.

Step 2: Processing your exported Tumblr posts

In normal circumstances, you can skip this step, but if you are a purist, like me, you might want to clean up the .XML file a bit to avoid some issues when importing the file in step 3.
You can edit the .XML file with a normal ASCII editor (WordPad does just fine for me, the simple Windows XP user). Each post is stored between <item>... </item> tags.
For each post, you will need to clean up two things with a simple search and replace:
One: Clean up the category tags
In some cases, the WordPress importer will create a single category for each imported post. Import 100 posts, and you will get 100 junk categories. While those are easy to clean up after importing the posts, it is better to avoid the problem than curing it.
The only thing you need to do, is to delete the two category tag lines, for each post:
<category domain="category" nicename="link"><![CDATA[link]]></category>
Two: clean up the date warnings.
Under some circumstances, you will get a date warning in the .XML file:
<wp:post_date><br />
<b>Warning</b>: date() [<a href=''></a>]: It is not safe (blabla)
2010-12-24 12:00:58</wp:post_date>
Just search for that string, and replace it with the date you find for each post, for example:
<wp:post_date>2010-12-24 12:00:58</wp:post_date>
Three: Split up the file in smaller chunks
Oh, and yes, there is a third thing, before I forget: WordPress can not import file larger than 8 Mb. So if your .XML export file is larger than 8 Mb, split it into individual small files.
Beware: Each file should contain the header section, which starts with
<?xml version="1.0" encoding="UTF-8" ?>
and ends with:
and each file should end with:
In other words: create a series of small files, which contain all posts (between <item>... </item> ) and paste the file header and end tags.
Hey, and forget all of this, if your .XML file is smaller than 8 Mb !

Step 3: Import your .XML file into WordPress

Now for the fun (and easy part): Import your .XML file with the WordPress Importer utility ( Dashboard > Tools > Import ).
The importer gives you a series of input formats. Select “WordPress”. And if you don’t have that plugin, you will have to install it first, with one click (don’t you just love WordPress? In Drupal, that would cost you four hours of work.. :) )…
Now you are ready to import your .XML file:
WordPress importer
Ready for the WordPress magic?
WordPress will give you the option to define the “blog user” name you want as the author for the imported posts, chew on things for a while, and in the end, list you the names for all the posts it has imported.

No comments:

Post a Comment