In this post, I will explain how to migrate a blog running on Word Press (Self Hosted) to BlogEngine. But before I start let me say, that Word Press simply rocks. The reason why I plan to switch my blog is customization. Since I am a dotnet geek, I really have no great idea of what I can make out of Word Press using PHP and when it comes to Blogging in .net, I guess I made a very right decision to use BlogEngine. It is open source and included all the necessary blogging utilities.
The main thing which I want to migrate is as follows
The moment I start, I was thinking to get some export / import tool. Then I came to know about BlogML. A format that is created to interchange content between different bloging engines. Natively, Word Press don’t support BlogML but Robert McLaws did great job on wiring this tool. Unfortunately, that tool didn’t work for me, for some reason it is keep giving me error.
Finally, I tried it in my own way. Since that blog was self hosted, I have access to mysql database engine through phpMyAdmin. Hence, I decided to export SQL of my related tables and data in MSSQL (TSQL) format.
- After the login into phpMyAdmin, go to the table list by selecting the databases comes at left.
- From the tab at the top select export.
- In the export group, select SQL and tables in my case it is wp_comments, wp_posts, wp_term_relationships, wp_term_taxonomy, and wp_term
- Now from the SQL Compatibility Mode, Select MSSQL. Save the file and your are complete.
Your selection screen should like like below.
Now open the generated SQL in MSSQL and before you run you might need to fix some column names and some data type issues of the table. But believe that is pretty easy. To help you more, please see the table creation script below
Please note that it is just the schema script. All you data will be included in mysql generated SQL File which we have created before.
Now, we have all the required tables with data imported from Word Press to Blog Engine Db but we will fill Blog engine tables to show imported data. Lets first start with category.
There is no such table in wp_categories in word press instead it uses wp_term and wp_term_taxonomy to store categories where as in Blog engine we have a table called be_categories which hold categories information. So following query will dump the data from wp_terms , wp_taxonomy to be_categories.
Now lets deal with posts, a very easy query because we have the post table in both the blogging engines. In Word Press it is wp_posts where as in Blog Engine it is be_post.
Post Category Relation:
Now its time to set, which post have which categories. The table which is repsonsible for saving this information is called wp_term_relationship in Word Press and be_PostCategory in Blog Engine. See the following query.
I guess this query might need some explanation. See, in the top query I am getting the title of posts and name of categories and storing it to temp table.
Now come to the second part, here I insert new reords in be_postcategory based on the category names and post titles we filled before.
In Blog Engine we have a table called be_PostTag which manage all the tags related stuff but in wordpress again involve all the tables containing wp_term. So, I write the following query which get the data from those tables and store it in Tags.
This one is comparatively easy. We have table called wp_comments in Word Press and be_postcomment in Blog Engine to manage the comments. Here is the final query.
Note : You might see some /r/n between some post and comments. Don’t get afraid of this, just replace “/r/n” with “<br/>” on effected using Replace function of TSQL.
That’s how you can import all the data from Word Press to Blog Engine and this is fairly a huge issue why people don’t move their blogs. I have tried to explain the method by making it more simple, if you still face any issue please feel free to contact me.