jekyll/site/docs/migrations.md

9.3 KiB
Raw Blame History

layout title prev_section next_section permalink
docs Blog migrations datafiles templates /docs/migrations/

If youre switching to Jekyll from another blogging system, Jekylls importers can help you with the move. Most methods listed on this page require read access to the database from your old system to generate posts for Jekyll. Each method generates .markdown posts in the _posts directory based on the entries in the foreign system.

Preparing for migrations

Because the importers have many of their own dependencies, they are made available via a separate gem called jekyll-import. To use them, all you need to do is install the gem, and they will become available as part of Jekyll's standard command line interface.

{% highlight bash %} $ gem install jekyll-import --pre {% endhighlight %}

You should now be all set to run the importers below. If you ever get stuck, you can see help for each importer:

{% highlight bash %} $ jekyll help import # => See list of importers $ jekyll help import IMPORTER # => See importer specific help {% endhighlight %}

Where IMPORTER is the name of the specific importer.

Note: Always double-check migrated content

Importers may not distinguish between published or private posts, so
you should always check that the content Jekyll generates for you appears as
you intended.

WordPress

WordPress export files

If hpricot is not already installed, you will need to run gem install hpricot. Next, export your blog using the WordPress export utility. Assuming that the exported file is saved as wordpress.xml, here is the command you need to run:

{% highlight bash %} $ ruby -rubygems -e 'require "jekyll/jekyll-import/wordpressdotcom"; JekyllImport::WordpressDotCom.process({ :source => "wordpress.xml" })' {% endhighlight %}

ProTip™: WordPress.com Export Tool

If you are migrating from a WordPress.com account, you can access the export tool at the following URL: `https://YOUR-USER-NAME.wordpress.com/wp-admin/export.php`.

Using WordPress MySQL server connection

If you want to import using a direct connection to the WordPress MySQL server, here's how:

{% highlight bash %} $ ruby -rubygems -e 'require "jekyll/jekyll-import/wordpress"; JekyllImport::WordPress.process({:dbname => "database", :user => "user", :pass => "pass"})' {% endhighlight %}

If you are using Webfaction and have to set up an SSH tunnel, be sure to make the hostname (127.0.0.1) explicit, otherwise MySQL may block your access based on localhost and 127.0.0.1 not being equivalent in its authentication system:

{% highlight bash %} $ ruby -rubygems -e 'require "jekyll/jekyll-import/wordpress"; JekyllImport::WordPress.process({:host => "127.0.0.1", :dbname => "database", :user => "user", :pass => "pass"})' {% endhighlight %}

Further WordPress migration alternatives

While the above methods work, they do not import much of the metadata that is usually stored in WordPress posts and pages. If you need to export things like pages, tags, custom fields, image attachments and so on, the following resources might be useful to you:

  • Exitwp is a configurable tool written in Python for migrating one or more WordPress blogs into Jekyll (Markdown) format while keeping as much metadata as possible. Exitwp also downloads attachments and pages.
  • A great article with a step-by-step guide for migrating a WordPress blog to Jekyll while keeping most of the structure and metadata.
  • wpXml2Jekyll is an executable windows application for creating Markdown posts from your WordPress XML file.

Drupal

If youre migrating from Drupal, there are two migrators for you, depending upon your Drupal version:

{% highlight bash %} $ ruby -rubygems -e 'require "jekyll/jekyll-import/drupal6"; JekyllImport::Drupal6.process("dbname", "user", "pass")'

... or ...

$ ruby -rubygems -e 'require "jekyll/jekyll-import/drupal7"; JekyllImport::Drupal7.process("dbname", "user", "pass")' {% endhighlight %}

If you are connecting to a different host or need to specify a table prefix for your database, you may optionally add those two parameters to the end of either Drupal migrator execution:

{% highlight bash %} $ ruby -rubygems -e 'require "jekyll/jekyll-import/drupal6"; JekyllImport::Drupal6.process("dbname", "user", "pass", "host", "table_prefix")'

... or ...

$ ruby -rubygems -e 'require "jekyll/jekyll-import/drupal7"; JekyllImport::Drupal7.process("dbname", "user", "pass", "host", "table_prefix")' {% endhighlight %}

Movable Type

To import posts from Movable Type:

{% highlight bash %} $ ruby -rubygems -e 'require "jekyll/jekyll-import/mt"; JekyllImport::MT.process("database", "user", "pass")' {% endhighlight %}

Typo

To import posts from Typo:

{% highlight bash %} $ ruby -rubygems -e 'require "jekyll/jekyll-import/typo"; JekyllImport::Typo.process("database", "user", "pass")' {% endhighlight %}

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

TextPattern

To import posts from TextPattern:

{% highlight bash %} $ ruby -rubygems -e 'require "jekyll/jekyll-import/textpattern"; JekyllImport::TextPattern.process("database_name", "username", "password", "hostname")' {% endhighlight %}

You will need to run the above from the parent directory of your _import folder. For example, if _import is located in /path/source/_import, you will need to run this code from /path/source. The hostname defaults to localhost, all other variables are required. 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

To import posts from Mephisto:

{% highlight bash %} $ ruby -rubygems -e 'require "jekyll/jekyll-import/mephisto"; JekyllImport::Mephisto.process("database", "user", "password")' {% endhighlight %}

If your data is in Postgres, you should do this instead:

{% highlight bash %} $ ruby -rubygems -e 'require "jekyll/jekyll-import/mephisto"; JekyllImport::Mephisto.postgres({:database => "database", :username=>"username", :password =>"password"})' {% endhighlight %}

Blogger (Blogspot)

To import posts from Blogger, see this post about migrating from Blogger to Jekyll. If that doesnt work for you, you might want to try some of the following alternatives:

Posterous

To import posts from your primary Posterous blog:

{% highlight bash %} $ ruby -rubygems -e 'require "jekyll/jekyll-import/posterous"; JekyllImport::Posterous.process("my_email", "my_pass")' {% endhighlight %}

For any other Posterous blog on your account, you will need to specify the blog_id for the blog:

{% highlight bash %} $ ruby -rubygems -e 'require "jekyll/jekyll-import/posterous"; JekyllImport::Posterous.process("my_email", "my_pass", "blog_id")' {% endhighlight %}

There is also an alternative Posterous migrator that maintains permalinks and attempts to import images too.

Tumblr

To import posts from Tumblr:

{% highlight bash %} $ ruby -rubygems -e 'require "jekyll/jekyll-import/tumblr"; JekyllImport::Tumblr.process(url, format, grab_images, add_highlights, rewrite_urls)'

url - String: your blog's URL

format - String: the output file extension. Use "md" to have your content

converted from HTML to Markdown. Defaults to "html".

grab_images - Boolean: whether to download images as well. Defaults to false.

add_highlights - Boolean: whether to wrap code blocks (indented 4 spaces) in a Liquid

               "highlight" tag. Defaults to false.

rewrite_urls - Boolean: whether to write pages that redirect from the old Tumblr paths

               to the new Jekyll paths. Defaults to false.

{% endhighlight %}

Other Systems

If you have a system for which there is currently no migrator, consider writing one and sending us a pull request.