A blogfriend of mine, Damien, announced it a while ago. He too would switch to
WordPress, following other bloggers like
Vinch,
Soph & Ced and
Denis. The only difference between Damien and them is that Damien is switching from
TypePad, while the others were switching from
DotClear.
When you change your blog from one system (TypePad) to another (WordPress), you want to keep your URL’s that are linked by other blogs but also Google. WordPress supports URL rewriting quite well, but the only problem is that Typepad does not export post slugs, so building up the same URL’s might seem like an impossible thing to do. Not true.
In case you are wondering what the post slug is, check this URL:
http://lor.em.ips.um/2007/03/hello_world.html
The post slug here is hello_world. TypePad limits the post slug to 15 characters and replaces spaces by underscores. WordPress does not really have a limit on post slugs and uses dashes to separate words, which, from an SEO point of view, is much better.
You could first think of a script that would regenerate the TypePad-like post slug, but sometimes, for some reason, the post slug totally differs from post title. Not really an option for Damien who wants to keep his URL’s using WordPress, especially when I told him that it would be possible to keep his links. For retrieving his TypePad post slugs I used a somehow amateur yet fun method: JavaScript (through GreaseMonkey)!
Manually, I opened up each month, starting from the most recent, in his archives and extracted all post slugs from his permalinks that I thereafter pasted in a text file, respecting the chronology using this GreaseMonkey script:
var titles = document.getElementsByTagName("h3");
var txt = "" ;
for(i = 0 ; i < titles.length ; i++){
txt+=titles[i].firstChild.href.split("/")[6].split(".")[0]+"<br/>";
}
var resultDiv = document.createElement("div");
resultDiv.innerHTML=txt;
document.documentElement.ownerDocument.body.appendChild(resultDiv);
If you want to use this script, you might have to change it in order to be able to use it on your own site. Your permalink structure might also be a bit different, so keep that in mind.
Click here to download the GreaseMonkey base for this.
Once I had all the post slugs in my text file, I removed all the posts from the freshly installed WordPress installation to remove all ‘default’ posts. After that, I imported in WordPress all posts using the TypePad export file. Once this was done, I ran a query to select all the ID’s in descending order from the blog articles that had the status ‘published’ and exported this to a csv-file:
select ID
from wp_posts
where post_status='publish'
order by ID desc
If all went well, we now have 2 lists of the same length. One list looks like this, containing all post slugs:
belgique_les_pa
la_couleur_de_v_1
la_rumeur_du_jo
…
The other list contains all post ID’s:
1034
1033
1032
…
1034 is the ID of the post that has the post slug ‘belgique_les_pa’ and so on. Somehow, I now from these two lists had to do a database update. For this, I first turned the lists into JavaScript arrays. An easy thing to do with an editor such as EditPlus.
The post slug array:
var slug = new Array() ;
slug[slug.length]='belgique_les_pa';
slug[slug.length]='la_couleur_de_v_1';
slug[slug.length]='la_rumeur_du_jo' ;
The id array:
Var ids = new Array() ;
ids[ids.length]=1034;
ids[ids.length]=1033;
ids[ids.length]=1032;
And finally, a script that generates an SQL query from those lists:
for(i = 0 ; i < ids.length ; i++){
document.writeln("update wp_posts set post_name='"+slug[i]+"' where id='"+id+"';<br/><br/>");
}
That script generates queries such as:
update wp_posts set post_name='belgique_les_pa' where ID='1034';
…
Once all those queries are generated, I run them, and post slugs under WordPress should be ok. You just have to check the way that WordPress rewrites your URL’s in order to match with your old TypePad installation. In Damien’s case:
/bloggingthenews/%year%/%monthnum%/%postname%.html
I know this method is kind of complicated, but it’s a fun thing to do. It would be a lot more easier if TypePad would actually export the post slugs as well. Luckily for Belgian blogs, there aren’t too many TypePad blogs around.