Ruben Laguna's blog

Aug 5, 2010 - 2 minute read

Migrating from Wordpress 3.0 to jekyll

I finally migrated from Wordpress to Jekyll. It wasn’t difficult but not easy either so I decided to write my experience in this blog.

I’m assuming that you setup a basic Jekyll site: _config.yml, _layouts, _posts, etc. A good start is to clone mojombo jekyll site and remove the _posts and images.

Although the Jekyll wiki describes how to use converters to migrate from Wordpress I didn’t follow that path because it requires direct access to the Mysql database.

So I found a migration script posted to Issue #20 that uses the Wordpress XML export as input. The script had a couple of problems, it didn’t handle international characters in the title, and it didn’t honor the original permalinks in WordPress.

So I modified it to fix those thing

To use it you need to have a wordpress.xml file in the same directory where you run the script and you need to modify the ORIGINAL_DOMAIN in the script to reflect your own. It will dump the published WordPress posts and comment as jekyll textile files in export/_posts.

The comments will be translate to a YAML file: export/_posts/comments.yml. If you want to import the comments to Disqus you can use the yamlcomments2disqus.rb script to import it.

The only thing that you need is to create a file called API-KEY in the same directory as yamlcomments2disqus.rb and write there your Disqus API key. The script will automatically post all non-spam comments to Disqus using Disqus API. The comments thread for each post is identified by the original Wordpress <wp:post_id> so then you have to add the following <script> along with the disqus regular javascript code (you can find it in<your site>/) in your layout.

I include here my _layouts/default.html, _layouts/post.html, atom.xml and sitemap.xml for reference