There’s a recent trend in blogging that consists of dropping PHP platforms such as WordPress and Drupal in factor of static HTML pages generated when needed.
Static blogs have many advantages over PHP engines:
- They’re much faster since there’s no computation overhead at runtime for composing the rendered page
- There’s no security issues regarding SQL injection
- Finally, generating the site removes the need for a staging area with possibly mismatched configurations
morevaadin.com is one of my site, designed with the Open Publish distribution on top of Drupal 7. It’s designed only to display articles about the Vaadin framework: there’s no comment management, no interaction, no fancy stuff involved whatsoever. In essence, there’s no need for a Drupal platform and a bunch of HTML files with some JavaScript would be more than enough. Here’s about my journey into porting the existing site, with the different steps I went through to reach my goal (spoiler: at the time of this writing, it’s not a success).
First step
Having no prior experience, I choosed Jekyll as my target platform for it’s supported by Github.
Before doing anything, I went through the motion of creating a Ubuntu VM, with the Ruby and RubyGems packages.
sudo apt-get install ruby
sudo apt-get install rubygems
Blog migration explained
My first strategy was to follow instructions from this blog post, which seemed to exactly match my target. In essence, I was to get the SQL dump from my Drupal site, execute it on a local MySQL base and execute some Ruby script wrapping a SQL one.
The problem is that the propsed SQL script was not adapted to the structure of my base: I fixed the prefixes and the node types, but I had still no success running the script.
Other scripts
I found other scripts on the Internet, but none was adapted to the structure of my database and I couldn’t get any running despite my best efforts.
Eureka!
Back to the basics: given that no hand-crafted script was able to run on my database, I decided to look further into Jekyll documentation and found there was a gem associated with a Drupal 6.1 migrator.
So, I installed Jekyll - a Ruby gem - and I could finally run the script.
sudo gem install jekyll
ruby -rubygems -e 'require "jekyll/migrators/drupal"; Jekyll::Drupal.process($MYSQL_INSTANCE, $LOGIN, $PASSWORD)
At this point, I got no errors running the Ruby script but no output whatsoever.
However, I tweaked the /var/lib/gems/1.8/gems/jekyll-0.11.2/lib/jekyll/migrators/drupal.rb
script a bit, where I commented out the lines concerning the node and entity types (30-31), as well as the whole tag things (lines 53-60 and 69) and I finally obtained some results:
a _drafts
and a _posts
folder, with the latter full of .md
files!
Running Jekyll with jekyll --server
finally generated a _site
folder, with a load of pages.
Problems
There are some problems with what I got:
- Some pages have unparseable sections (
REXML could not parse this HTML/XML
) - Pages have no extensions, despite being HTML, so the browser doesn’t recognize the MIME type when they’re run under Jekyll. The normal way would be to have index.html under folders named as the post
- There’s no index
Cloning Octopress and Jekyll
Given my very limited knowledge (read none) of what happens under the cover and my unwillingness to further change the script, I tried the same on a ready-to-use template named Octopress, with the possible intention to migrate the few pages I had (not very satisfying from a software developer point-of-view but pragmatic enough for my needs).
sudo apt-get install git
git clone https://github.com/imathis/octopress
Unfortunately, there was an error in the script :-( So, in a desperate attempt, I wanted to give a try to Jekyll Bootstrap.
git clone https://github.com/plusjade/jekyll-bootstrap.git
And lo, I finally got no error, an output and something to view in the browser at http://0.0.0.0/index.html!
Present situation
I’ve been tweaking and updating included files (those in the _included folder) and I’m beginning to get something bearing some similarity to the original layout.
To obtain that, I had to install Pygments, the code prettifier:
sudo apt-get install python-pygments
At this point, there are basically 2 options: either manually port other posts and finalize the layout (as well as work toward the original theme), or invest in the configuration process to make it work.
At present, I’m leaning toward the first option. Feedback welcome!