divillysausages.com

Drupal2Jekyll

When I first released the new update of my site, I mentioned the tool that I built to help convert my Drupal site to a Jekyll format. Well, after getting sidetracked by all the other posts I had to write about the stuff we're doing in TripleFun, I finally got around to cleaning the tool up a bit for public release. Presenting Drupal2Jekyll!

A little caveat

This post probably isn't going to be super relevant for a lot of people. For one, you need to have a Drupal site. Next, it needs to be a Drupal 6 site. I've no idea if it works in Drupal 7, I haven't tested it (generally it should only be a case of writing/modifying the parsers). After that, you need to have phpMyAdmin access, as you need to download the different tables in XML format, as that's the easiest way I could do it (I could probably just connect directly to the DB, but I had other concerns, so I never really looked into it). Lastly, you need to want to move to Jekyll, which if you don't know it, is a static-site generator.

If you tick all those boxes, or despite everything, are still curious, then read on!

What it does

Drupal2Jekyll is an AIR tool that parses Drupal XML files to extract the content, clean it up, modify it, then save it in Jekyll format. Nearly all the different Controllers are optional, so you can toggle what you wish to get the desired effect.

I'm also assuming that you want to embrace the Jekyll URL format, so you'll ditch your old URLs (the tool can generate 301/302 redirects for you, so you won't be trailing dead links behind you - Don't Break the Web™).

All Controllers affect both post content and comments, so in no particular order, the tool:

Obviously, you'll need to give the final result a quick once over, but it does a lot of the grunt work and will generally make it a lot less painful that it needs to be.

How to use the tool

First download and build the code, or run the AIR file included at the end of the post. Once it's installed, when you run it, it'll ask you for a few things before you get started.

A preview of the settings screen

Once you've all that set up, we'll need the actual content.

First, log into your phpMyAdmin. You'll be able to get into this through the cPanel on your hosting site:

Going to phpMyAdmin

Next, select the database that you use for your drupal site. You'll probably only have one:

Selecting your Drupal database

Once here, we need to download the right tables to XML format. The tables to download are:

The only absolute necessary ones are node and node_revisions. The rest are bonus.

To export a table, click on the one in question, for example, node, and along the top, click on the Export tab:

Exporting a table in phpMyAdmin

You can leave the Quick option selected, then just select XML as the file format, and hit Go to download the XML:

Downloading a table as XML in phpMyAdmin

Do this for all the necessary tables, and save them to your Drupal XML folder. You're now ready to rock.

Getting the tool

The code lives online at https://bitbucket.org/divillysausages/drupal2jekyll, but if you just want the AIR file, and JS files, they're included at the end of the post.

Comments and questions are appreciated. Enjoy!

Files

Comments

Submit a comment

* indicates required