1 Motivation

Eventually, I want to be able to host all of my notes on an low-power ARM computer with limited resources. This so far was not efficient with fully blown-up dynamic pages. Therefore, note here describe a way to combine Org-mode and Jekyll to conviniently generate pretty HTML blog type of website.

2 Installing Jekyll on GNU/Linux Debian

To begin with, install all dependencies

apt-get install ruby ruby-dev nodejs
gem install jekyll

3 Setting up basic website

Create website with Jekyll

jekyll new ${GITHUB_USER}.github.io

where GITHUB_USER variable is set

export GITHUB_USER=my_user

Navigate to the directory created with the above command and edit _config.yml and about.md files accordingly.

In order to test the website, which in fact you should always do before commiting it to git use

jekyll serve

4 Setting up org-mode

Add the following snippet to your init.el emacs file, and edit it accordingly, replacing GITHUB_USER with username as variable won't be expanded in emacs file.

;; Blogging with Jekyll and Org
(setq org-publish-project-alist
     ;; Location of org files
     :base-directory "~/GITHUB_USER.github.io/org/"
     :base-extension "org"

     ;; Location of Jekyll files
     :publishing-directory "~/GITHUB_USER.github.io/_posts/"
     :recursive t
     :publishing-function org-html-publish-to-html
     :headline-levels 4
     :html-extension "html"

     ;; Only export section between <body></body>
     :body-only t)

     :base-directory "~/GITHUB_USER.github.io/org/"
     :base-extension "css\\|js\\|png\\|jpg\\|gif\\|pdf\\|mp3\\|ogg"
     :publishing-directory "~/GITHUB_USER.github.io/assets"
     :recursive t
     :publishing-function org-publish-attachment)

    ("GITHUB_USER.github.io" :components ("org-GITHUB_USER.github.io" "org-static-GITHUB_USER.github.io"))

Posts must be named with restriction, as files in format YYYY-MM-DD-Title-of-the-post.org and placed in base-directory. Furthermore, posts must not include anything in front of HTML escaped YAML header, for example

layout: post
title: Using Org-mode to blog with Jekyll
published: true
#+TITLE: 2015-07-19-Debian-Jekyll-Org
#+DATE: <2015-07-20 Mon>
#+AUTHOR: Mashu
#+EMAIL: mashu@mail.com
#+OPTIONS: toc:nil
#+SELECT_TAGS: export

Disabling table of contest (toc) is important here, to prevent org-mode from inserting it before the escaped HTML, which will be processed by Jekyll.

To publish just export with standard C-c C-e P x and verify the rendering before commiting with jekyll serve command.

5 Commiting to Github

First, create a new github public repository with the name GITHUB_USER.github.io Then from the bash command line within the base-directory push the whole website

git init
git add *
git commit -m "Initial commit"
git remote add origin https://github.com/${GITHUB_USER}/${GITHUB_USER}.github.io.git
git push -u origin master