Skip to content

Blog Migrations

juniorz edited this page · 31 revisions

Most methods listed on this page require read access to the database to generate posts from your old system. Each method generates .markdown posts in the _posts directory based on the entries in the DB. Please make sure you take a look at the generated posts to see that information has been transferred over properly. Also, the majority of the import scripts do not check for published or private posts, so please look over what Jekyll has created for you.

How to use

These migrators are part of the Jekyll gem. There's probably a better way to do this, but here's what I did.

  • Add an _import directory to your project
  • Open a terminal
  • Install open_gem (unless you already have it)
  • Type gem open jekyll
  • Open lib/jekyll/migrators/ (used to be lib/jekyll/converters/)
  • Copy csv.rb to _import
  • Copy your converter of choice (mephisto.rb, etc.) to _import
  • Navigate to the _import directory via terminal
  • gem install sequel mysqlplus
  • Run the respective commands below.

If you need to tweak something in the import process, just edit your local copies of the converter code.

WordPress

Using Jekyll + Mysql server connection

$ export DB=my_wpdb
$ export USER=dbuser 
$ export PASS=dbpass 
$ ruby -r './_import/wordpress.rb' -e 'Jekyll::WordPress.process("#{ENV["DB"]}", "#{ENV["USER"]}", "#{ENV["PASS"]}")'

Using Jekyll + Wordpress export file (works with wordpress.com)

First, export your blog: https://YOUR-USER-NAME.wordpress.com/wp-admin/export.php. Check if the migrator has

require 'time'

If not, add it. Assuming that file is called wordpress.xml:

$ ruby -r './_import/wordpressdotcom.rb' -e 'Jekyll::WordpressDotCom.process("wordpress.xml")'

Further wordpress + alternatives

While the above methods usually works they do not import very much of the meta data that usually is stored in wordpress posts and pages. If you need to keep more of pages, tags, custom fields, image attachments and so on the following resources might be of interest:

  • Exitwp is a configurable tool written in python for migrating one or more wordpress blogs into jekyll/markdown format while keeping as much meta data as possible. Also downloads attachments and pages.
  • A great article with a step by step guide on migrating an wordpress blog while keeping most of the structure and meta data.

Drupal

Note: This was written for Drupal 6.1. Please update it if necessary. Thanks!

$ export DB=my_dpdb
$ export USER=dbuser 
$ export PASS=dbpass 
$ ruby -r './_import/drupal' -e 'Jekyll::Drupal.process("#{ENV["DB"]}", "#{ENV["USER"]}", "#{ENV["PASS"]}")'

Movable Type

$ export DB=my_mtdb
$ export USER=dbuser 
$ export PASS=dbpass 
$ ruby -r './_import/mt' -e 'Jekyll::MT.process("#{ENV["DB"]}", "#{ENV["USER"]}", "#{ENV["PASS"]}")'

Typo 4+

$ export DB=my_typo_db 
$ export USER=dbuser 
$ export PASS=dbpass 
$ ruby -r './_import/typo' -e 'Jekyll::Typo.process("#{ENV["DB"]}", "#{ENV["USER"]}", "#{ENV["PASS"]}")'

This code also has only been tested with Typo version 4+.

TextPattern

$ ruby -r './_import/textpattern' -e 'Jekyll::TextPattern.process("database_name", "username", "password", "hostname")'

Run the above from the folder above _import in Terminal. i.e. If _import is located in /path/source/_import, run the code from /path/source. The hostname defaults to localhost, all other variables are needed. You may need to adjust the code used to filter entries. Left alone, it will attempt to pull all entries that are live or sticky.

Mephisto

$ export DB=my_wpdb
$ export USER=dbuser 
$ export PASS=dbpass 
$ ruby -r './_import/mephisto' -e 'Jekyll::Mephisto.process("#{ENV["DB"]}", "#{ENV["USER"]}", "#{ENV["PASS"]}")'

Blogger (Blogspot)

See Migrate from Blogger to Jekyll

kennym created a little migration script, because the solutions in the previous article didn't work out for him.

ngauthier created another importer that imports comments, and does so via blogger's archive instead of the rss feed.

juniorz created another importer that works for Octopress. It is like ngauthier's version but separates drafts from posts, imports tags and permalinks.

Posterous

For your primary blog:

$ ruby -r './lib/jekyll/migrators/posterous.rb' -e 'Jekyll::Posterous.process("my_email", "my_pass")'

For another blog:

$ ruby -r './lib/jekyll/migrators/posterous.rb' -e 'Jekyll::Posterous.process("my_email", "my_pass", "blog_id")'

An alternative Posterous migrator that maintains permalinks and attempts to import images lives here

Tumblr

$ ruby -r './_import/tumblr' -e 'Jekyll::Tumblr.process("http://www.your_blog_url.com", true)'

A modified Tumblr migrator that exports posts as Markdown and also exports post tags lives here

It requires the json gem and Python's html2text:

$ gem install json
$ pip install html2text

Once installed, simply use the format arg:

$ ruby -r './_import/tumblr' -e 'Jekyll::Tumblr.process("http://www.your_blog_url.com", format="md")'
Something went wrong with that request. Please try again.