Swaroop C H

blog books about contact subscribe

Migrated to Jekyll

11 Apr 2014

You may have already noticed the blog is active again because of me accidentally leaving the "Welcome to Jekyll!" entry on the website.

That entry was added when I created a new Jekyll repository and wrote a long Ruby script with lots of regexes and invocations of curl and Nokogiri to convert from the Wordpress-exported XML to the Jekyll structure.

I’m happy to say that the website is now fully converted to Jekyll and it will help me avoid the whole problem of Wordpress security updates.

So why did I want to migrate to Jekyll in the first place? Because ever since I have been assimilated by Orgmode and immersed in Emacs, I wanted to write in Emacs and no longer wanted to do the long "edit-publish-refresh" cycle of using the Wordpress admin, especially because I would write in Markdown or Org and then convert to HTML and upload the generated HTML to Wordpress. Every time I had to edit the post after publishing, I would have to then edit HTML.

So Jekyll seemed like the best option because it allows me to choose the format that I write in. So I wrote a small plugin to render AsciiDoc, my new syntax of choice which I used to rewrite A Byte of Python:

#encoding: utf-8
# http://jekyllrb.com/docs/plugins/#converters
module Jekyll

  class AsciidocConverter < Converter
    safe true

    def setup
      # http://asciidoctor.org/rdoc/Asciidoctor.html
      require 'asciidoctor'
    rescue LoadError
      STDERR.puts "Cannot load asciidoctor gem"
      raise FatalException.new("Missing dependency: asciidoctor")
    end

    def matches(ext)
      ext =~ /^\.asciidoc$/i
    end

    def output_ext(ext)
      ".html"
    end

    def convert(content)
      setup
      Asciidoctor::Document.new(content,
        {:attributes => {"source-highlighter" => "pygments"}}).render
    end
  end
end

So, voila, I wrote this blog post in AsciiDoc and Jekyll.

Now, all I need for hosting this website is just nginx http server and some rewrite rules (for backwards compatibility of URLs), and I’m done. No other software required.

With this setup, hopefully, I should be able to write often again. Hope.

Feedback

There's no comment box, but please do email me or tweet me your thoughts and criticisms, and I will publish the relevant ones here.