The process in this article is valid for BlogEngine version 1.6 or higher, including 2.0 and the latest 2.5 which is multi-blog. If you are going to host several migrated blogs, you should pay special attention to the last section about redirects.
I’ve been posting in my blog since June 2004, this is almost 8 years now. I started it using a project named GolemProject which was sponsored by a university so it was promptly closed and I had to host it in one of our servers. In that year (2005) I thought the most interesting blogging system written in .NET was dasBlog. The downside is that this system is not supported anymore. Its last version was released three years ago – March 2009- and in that time it didn’t even have half of the features we expect from a modern blogging system. So sooner or later I supposed I was going to have to migrate to another system.
Since the summer of 2010 my other blog is working on BlogEngine.NET. This is a more powerful system, with many features. It’s easy to extend or adapt to my needs. It’s very similar to WordPress but using the .NET platform. It needs many improvements to catch up with Wordpress, but it’s enough for almost everything, specially if you can customize it by coding, besides I feel more comfortable working with .NET instead of PHP.
Since the migration from dasBlog to BlogEngine cannot be done directly and it has a lot of important details, I have decided to put together in this post all the steps to be followed. It’s a little bit long but everything it’s explained in detail. Everything here arises from my own experience and after testing several applications, so I hope this can help you and can save you a lot of time.
I think it helps too if you need to migrate from other blogging system, even WordPress. Good luck!
Migration and SEO
Nowadays, a very important thing we have to take into account is search engine optimization (SEO).
For SEO purposes it’s very important to keep the same URLs when migrating from one system to another, or at least to have a permanent redirect (HTTP 301) indicating that the address has changed. This way the blog will keep its SEO positioning.
Furthermore, there are many external links pointing to the blog and pages, so if the address changes there will be many broken links all over.
For these reasons, one of the basic premises for migration is that the new system should be able to redirect to the same articles/posts when coming from a browser or external link.
Since the URL systems of dasBlog and BlogEngine are totally different, this task is not as simple. However, itt can be done with some work, I’ll explain how later.
Ok, let’s see the process step by step.
1. Exporting from dasBlog to BlogML
The first thing to do is to migrate our contents, comments, categories, etc… from dasBlog to a format compatible with the new system.
There is a standard named BlogML used to describe contents and elements. It’s very popular nowadays and it can be used by BlogEngine to export and import information. We can also use an application named dasBlogML for the export process from dasBlog. This has been built by Paul van Brenk and it’s hosted in MSDN code.
To use it we need direct access to the folder where our blog is located in dasBlog. For this we can either execute the application on the server or copy all the contents to our machine via FTP (dasBlog stores the contents in XML files, so there is no a database to move)
It’s as easy as launching the application and locating the folder where our contents are and the name of the target file:
In this case I’m exporting a blog and copying the content to a file name C:ThEmEx.xml using BlogML.
2. Setting up BlogEngine.NET
Let’s download the latest version of BlogEngine.NET from CodePlex. The installation is very simple. Just extract the files in BlogEngine.NET 2.0 (web), assign to it an IIS virtual server and grant write permissions to the user “Network Service” in the folder App_Data. With this, it’s ready to work with default settings. The administrator user and password is “Admin/admin”.
For migration process, I suggest to set it up in a local machine because once the contents are migrated (faster locally) there are some other things to do to adjust our blog, and later is very simple to simply upload the blog contents to the production server.
3. Import BlogML information
Let’s open the BlogEngine.NET administration panel and click on the tab “Import and Export” in the Settings section:
We find two options for importing the contents: upload the xml file generated by BlogML directly or use a little application to import the contents, which is executed with Click-Once by clicking on the button that can be seen in the previous image. The first option does not work very well so it’s better to choose the second one.
After clicking on the button an application is executed to help us with the migration. Basically it reads the BlogML file and then starts calling the Web service methods to import by BlogEngine. The application is not as good looking as it could be but we have access to the source code in Codeplex. In fact I could find and fix some issues in the image transformation paths.
That’s why one of the premises is that the new blog, once migrated, is going to be hosted in the same domain than the previous one. This way we don’t have to migrate image paths. Otherwise you would need to teak the source code a little bit to fix the image path’s related code
To execute it we have to set the following parameters:
- “BlogML” in Source Type.
- The path to the .xml file generated by BlogML.
- Select the option “Ignore Blog Files & Images” in Files & Image (due to the aforementioned path’s issue)
- Ignore the field “File Path” used only for images migration.
- In the “Destination Information” section enter the BlogEngine.NET root URL which we just set up (for the example I set it up in an IIS Express using the port 8080) and finally the blog’s administrator name and password (admin/admin by default).
- Select all the advanced options, to avoid duplicating posts, to add the source author and to publish only the comments explicitly approved by us.
No. If it’s executed right now, we’ll process some posts and immediately we’ll get an error. Besides, the error will indicate that the blog credentials are not valid, but that’s not the real reason.
There’s a bug in the web service method in charge of importing comments.
4. Fixing the import service
The code of the import service lies in the file BlogImporter.cs in the App_Code folder of your BlogEngine installation.
The first thing to fix is the bug in the comment import method. The problem is that the name of the parameter “postID” in the method AddComment is wrong:
We have to change the name of this parameter to “postID” (capital “ID” letters):
With this, the comments will be migrated successfully and we’ll get rid of the previous misleading error.
However, there are still several things to fix before trying again.
Next we have to fix character encoding issues. All non ASCII chars in the posts titles are not decoded in the new blog, thus we’ll see some “weird” chars once the import is finished if we’re using other language than English. To fix this we only have to decode the HTML in the titles just before adding them to the new post, which can be done with HtmlDecode.
The next thing is about the SEO issue mentioned at the beginning of this article. Posts in the blog have a property named Slug that is the text used to generate the public URL. In the default import, post Slugs are generated automatically by BlogEngine, meanwhile dasBlog uses long texts with numbers and letters (GUID values). A common URL in dasBlog looks like this:
We need to use the same GUID of the original post as the Slug so that we can redirect easily. For this we just have to add a simple code to define the Slug/GUID from the original URL and then assign it to the new post. We are going to use a substring starting in the very last slash “/” char before the file name extension .aspx, so the code is very simple. Here is the method AddPost fixed entirely (changes are outlined in red):
Ensure the proper URL redirection
We still have a problem, even after assign the same Slug to each imported post, there are certain chars removed by BlogEngine, and it is also shortening the original Slug length.
If the original Slug was “PermaLink,guid,da59f4ca-76eb-4622-949e-b4fd5fa”, it will be changed after the import to something like this: “PermaLinkaspxguid=da59f4ca-76eb-4622-949e-b4″.
This is, the section “PermaLink,guid,” is changed for “PermaLinkaspxguid=” and the last 5 chars are removed.
In addition, BlogEngine uses a virtual subfolder named “post” to show the posts, so if the original URL was:
the resulting new one is:
which is not equual at all.
So to avoid broken links we have to make sure that when a request for an old URL is received we’ll redirect it using a permanent redirect (301 status code) to the new imported post.
It’s the same for categories which change from:
To make this transformations we just have to add a handler for the BeginRequest event in Global.asax to intercept requests and check if the requested page is pointing to an old one and perform the redirect if it’s the case. It’s a simple code and this is the result (click to enlarge):
Done! From now on, when an old URL is requested, the system will redirect it to the new one and we are not going to loose SEO positioning.
6. What about RSS?
We have to think about the people that, instead of visiting the blog, use any RSS reader such as Google Reader or Outlook. dasBlog RSS URLs are like this:
here “/GetRss” indicates the format.
The equivalent BlogEngine URL is simply:
and the format is set from the configuration.
To avoid broken feeds or errors we can add a few code lines in Global.asax as in the previous image (the last three lines).
From now on, the old feed will be updated.
7. Finishing touches
In order to finish the migration it’s necessary to keep old images and files. DasBlog stores images and files in a folder named “content”. Thus we just have to copy it to our new blog. Actually we only have to copy the subfolder “Binary” that is inside “content”.
In addition, BlogEngine creates two new post categories named “BlogEngine.NET” and “Blog”. So you can delete them from the “Categories” tab in the page administration section.
Now you just have to work on the look&fell things and the basic BlogEngine configuration. When everything is fine locally, just upload the whole BlogEngine folder to your production server, set-up the virtual server, grant write permissions to the “Network service” user on the “App_Data” folder and voilà! your new blog has been migrated and it’s ready!
I hope this helps!