.NET to WordPress: Migrating BlogEngine.NET

This post in the .NET to WordPress Series is the last in the series and covers the migration of BlogEngine.NET data to WordPress.

We used BlogEngine.NET’s Export function to output all posts to a BlogML.xml file.  We’re going to make some changes to it before importing it into WordPress.  We’ll cover those BlogML.xml changes in a second, but first let’s talk about the WordPress import plugin we’ll need.

There are several WordPress BlogML Import plugins out there, with forks of forks.  I used Maciej Aniserowicz’s BlogML WordPress Import Script on GitHub which worked flawlessly. Importing into WordPress with the right BlogML importer is the easy part after we make a few changes to our BlogEngine.NET BlogML file.

Categories

Let’s start with Categories. BlogEngine.NET uses Guids as IDs. We want to change them to the Category Name, as well as all REF elements using the Category Guid. One global search-replace per category guid will do the job.

Tags

As for migrating tags, the Aniserowicz BlogML WordPress import script supports tags as well. We didn’t migrate tags, but according to Aniserowicz’s Readme, tags are handled the same as categories so the same GUID-to-name search/replace will get us tag-ready.

Comments

We took the opportunity to remove all comments, since 90% of them were spam.  If you have 1000s of spam comments for removal you might either want to create a script to trim the BlogML.xml or import the comments into WordPress for deletion in the Dashboard. One consideration is that you want to manage the size of your import file.  There are ways to increase the BlogML.xml import size limit, so a fat BlogML.xml will require a bit of R&D. I recommend removing the comments before they get into WordPress.

Image Links

BlogEngine.NET uses an image handler to display images. We’ll need to take everything in the BlogEngine.NET /app_data/files folder and place it in a new folder. I used /images/archives.  WordPress will save images to new posts in the appropriate wp-content folders.

Links

This change is applicable to both the blog BlogML.xml and to any CMS pages you are migrating.  Links in BlogEngine.NET and most .NET-based blog engines link to the page with an .aspx filename extension.  An example is /my-blog-post.aspx.  In WordPress the same page would be /my-blog-post/ so another search/replace is required.  We need to replace all .aspx page links in the BlogML.xml and CMS pages which link to other pages on the site.

This could be problematic if your BlogEngine.NET blog contains a lot of links to pages both on the site and to .NET pages external to the site. Keep that in mind when pricing the job. Fortunately our .NET site contained only internal links on blog posts and CMS pages, so our search/replace was simple.

Links and Filename Considerations

It’s important to plan filenames on the new site to duplicate old site links as much as possible to avoid a ton of problems with bad links. If your CMS pages link to other CMS pages you’ll want to take care to duplicate the filename when creating the WordPress page. If the original CMS page is holiday-ladies.aspx make sure the name of your WordPress page is holiday-ladies.  the-holiday-ladies will throw a 404, so will Holiday-Ladies.  Depending on your host environment, most Linux-hosted WordPress sites require case-sensitivity of links.  This goes for image links, too, so if an image isn’t displaying on a CMS page, check the case.  These are also issues to consider when pricing the job.

Url Redirection and Syndication Links

You may wish to add Url Redirection for all of your old site content, which might include blog posts, CMS pages and RSS Syndication links. If you wanted to do that the old url –> new url changes would need to be listed in the .htaccess file and the format would be

Redirect 301 /post/blog-post.aspx http://example.com/blog-post/

.NET to WordPress: It’s a Wrap!

Thank you for reading my .NET to WordPress series. Nothing insightful or philosophical to add, other than it’s great to know another website is running in an Open Systems Environment and not on a Microsoft server. There is also big fun to be had working with WordPress on another client site, so expect more posts on WordPress in the future here on NixMash.