Main contents

I think my mom is my only constant reader, but if you used to read when I was writing it more frequently than the last year and a half, you’ll notice a few changes in appearance that only scratch the surface of the changes that I’ve made.

I moved hosts; I moved OSes; and I moved blog engines. I decided to move to WordPress on LAMP from Subtext on IIS. And I’m really happy with the move, too, which is rare, if Google is any indication; everyone else is moving the other way. There was only one, Aaron Lerch, who went in my direction and he wrote an import plug in, which I didn’t use because it required all these extra downloads. [Um, re-reading Aaron's post, I see now that his BlogML Import plugin is probably the way to go if you're in this situation. There's only one extra download.]

To make matters worse, I had a version of Subtext that must’ve been a development version because the BlogML export didn’t work at all. So I had to use all my hacking skills to read directly from the database with the current Subtext source (Thank goodness it was open source!). I’ll spare you the details of that export; it wasn’t perfect or pretty but I got my posts, comments, and categories, which was close enough for what I wanted. So I had a BlogML XML file and I needed to convert to a WordPress export file, which is just some gussied up RSS. In the intervening years since I stopped blogging and now, .NET 3.5 was released, so I thought this was the perfect time to play with LINQ and the new XML APIs.

LINQ is seriously cool. Working with XML is seriously not, no matter what API you have. Those were the two conclusions I came up with. The new XML APIs are pretty sweet, though. They’re the closest I can come to writing code that handles XML the way I think about XML. But that’s not what I’m writing this post about.

The conversion got me about 90% there, but there were a couple things that I needed to fix: mapping old urls to the new ones because your urls are probably the most important thing about people reaching your website and handling image paths; both of which are handled with mod_rewrite and the htaccess file. Until IIS 7, I don’t think Windows had anything as cool as that and even with IIS 7, it may not, certainly not as simple as a text file.

Using this helpful article, I generated all the rewrite rules from the BlogML export file, since it had all the old post urls. I only had roughly one hundred articles so I just hard-coded everyone of them. They all take the form of

RewriteRule ^rss.aspx [r=301,nc]

I didn’t want to mess with mod_rewrite too much, because regular expressions require a quiet room and lots of testing, so I kept it pretty simple. What the above says is if my web server receives a request for rss.aspx, then permanently redirect to, that’s what the r=301 means. The ‘nc’ means case doesn’t matter. Spaces matter here! Notice there are no spaces in the the square brackets. It won’t work otherwise.

The last thing I had to do to convert was images. My images were in two spots: the root folder and in an ‘images’ folder. So my posts have those paths in them. Rather than go through all my posts and changing the paths, I added another rewrite rule:

RewriteRule ^(images/)?(.+)\.(gif|jpg)$ blog/img/$2.$3 [nc]

That’s about as fancy as I get in mod_rewrite. What this says is any jpg or gif file either in the root or in the path images/, then redirect to blog/img/ with the same name and extension. So if I had an image in a post with the path images/1.jpg, then mod_rewrite will convert that to blog/img/1.jpg.

Converting this took a few weeks of off and on development. Changing blog engines is anything but trivial right now. If anyone is curious about the code, just ask.

Technorati Tags: ,,,

This entry is filed under Software. You can follow any responses to this entry through the RSS 2.0 feed. Responses are currently closed, but you can trackback from your own site.

14 Comments to “Subtext to WordPress: Converting blog engines”

  1. gfox Says:

    28 February 2008 at 1202

    You have at least 2 regular readers ;) Nice work on the seemless upgrade. Why the big swtich though? You giving up on MS technology and becoming an open source guru?

  2. Jason Kemp Says:

    28 February 2008 at 1618

    Subtext was too clunky, at least when I used it; and it was clunky because .Text was clunky.

    Customizing the look of the site looks easier in WordPress. And there are tons of plugins so I can focus on writing, not hacking on code.

    I think because I know .NET well, I judged Subtext as a developer and not a user, hence I saw all the flaws. I have no idea what’s going on in WordPress, so I’m dazzled by how few details I have to know about :)

  3. Yaz Okulu Says:

    23 March 2008 at 1810

    does anyone knows if there is any other information about this subject in other languages?

  4. John Says:

    14 July 2008 at 1900

    Great to know someone pulled this off. We have a rather large Subtext site that I want to port to WP. I can’t get blogML export to work either, so it’s good to know that it’s Subtext, not us. Can you detail how you were able to export the database tables and keep them intact? Specifically I’m curious about the order, structure integrity, and how you ported it to MySQL.

    Any help would be greatly appreciated.

  5. Jason Kemp Says:

    14 July 2008 at 2114

    @John: You’re the second person to ask within a week. That’s enough inquiry around these parts to warrant a post. :) I’ll follow up with one shortly.

    Incidentally, what version of Subtext are you using?

  6. John Says:

    8 August 2008 at 1322

    Sorry for not getting back sooner. Now we have a commitment to make this move, so I need to finally take this on. the version of subtext is 1.94. It could be 1.95? The blogML export does not work either. The database has hundreds (maybe thousands) of records.

    Your post is very helpful, but the part you left out about the dirty details of how you were able to get the data out of the database and set up the table parameters for import is key to this. Any info would be very helpful.

  7. Shiva Says:

    29 August 2008 at 1151


    You are being “too kind” to SubText. I am currently on Subtext too and migrating to WordPress because of several reasons, some of which you have already stated.

    SubText was a very poor port from Scott Water’s .Text. The source code also seems poorly managed and the main “evangelist” and owner for Subtext, Phil, seems to have moved on to Microsoft and the Project is facing neglect.

    I have evaluated WordPress quite extensively before making the switch. One of the best things about WordPress is that since it has such a large user base, the platform is tested and the code base is quite stable. Also, running on Apache makes the pages render in factions of seconds on shared hosting, compared to SubText or other .Net engines that have a longer cold startup time.

    Could you please give me more details on your URL rewriting / redirects ? Did you do a 301 redirect for all requests in old blog and then handle the actual forwarding in new WordPress blog ?

  8. How to export Subtext to Wordpress | Small Business Website Marketing Says:

    24 September 2008 at 0853

    [...] was nothing short of a nightmare, and not an unusual experience as far as I can tell.  This blog: discusses one approach on how to fix [...]

  9. edla Says:

    10 January 2009 at 1047


    Do you have the code to export from Subtext to blogMl format? I tried your console application. It throws error. Need to tweak it hard.. Let me know what was ur approach. My email: prashant_sp at Live .com

  10. RaiulBaztepo Says:

    28 March 2009 at 1832

    Very Interesting post! Thank you for such interesting resource!
    PS: Sorry for my bad english, I’v just started to learn this language ;)
    See you!
    Your, Raiul Baztepo

  11. » Blog Archive » Moved from SubText to Wordpress Says:

    9 March 2010 at 1202

    [...] I exported my subtext blog to blogml then used this very nice blog article to import it into wordpress.  I did what the chap says but didnt really have any problems at all.  [...]

  12. Andrew Kemp Says:

    26 April 2010 at 0335

    Hi, great post, I have been trying to get my blog from subtext to wp for a long time but keep getting errors xporting, something within my DB I think. I have now managed to export the posts but not the comments or catagories, how did you exactly get all yours out? any hots, pointerswould be greatly appreciated!

  13. Jason Kemp Says:

    26 April 2010 at 0724

    I have another post on converting from Subtext to WordPress here:

    For whatever reason, the Goog doesn’t pick that one up.

    Hope that helps.

  14. » Blog Archive » Moved from SubText to Wordpress Says:

    14 February 2012 at 1056

    [...] I exported my subtext blog to blogml then used this very nice blog article to import it into wordpress.  I did what the chap says but didnt really have any problems at [...]