Welcome back to the old world

4 minute read

I have recently blogged about moving to emacs and the reasons behind it.

Since then, I have used Orgmode a lot more. And I have begun to like it even more. I had a plan to move the blog to Hugo. After giving it a try, I had inconsistent results. I must’ve been doing something wrong. I’ve spend a lot more time than I anticipated on it. At some point, it becomes an endeavor with diminishing returns. So I ditched that idea.

But why did I want to move to Hugo in the first place ?

Why Hugo you may ask

Well, the answer to that question is very simple; Orgmode.

The long answer is that the default Nikola markup language and the most worked on is reStructuredText. It can support other formats. Orgmode also seems widely supported and can be easily manipulated. So I want to move to Orgmode instead of rst.

But what are the odds ?

Damn… It has plugins and you can find an orgmode page where you find

 $ nikola plugin -i orgmode

Where the heck did that come from ? Okay that was easy.

Turns out Nikola supports Orgmode.

Nikola Orgmode plugin installation

The page suggests running.

 $ nikola plugin -i orgmode

Followed by

# NOTE: Needs additional configuration in init.el file.

# Add the orgmode compiler to your COMPILERS dict.
COMPILERS["orgmode"] = ['.org']

# Add org files to your POSTS, PAGES
POSTS = POSTS + (("posts/*.org", "posts", "post.tmpl"),)
PAGES = PAGES + (("pages/*.org", "pages", "page.tmpl"),)

Okay, that’s not too bad. Next step.

Alright, let’s run our first org post

The installation was easy, running it should be just as easy.

$ nikola auto
[2020-08-31 23:16:17] INFO: auto: Rebuilding the site...
Scanning posts..........done!
.  render_taxonomies:output/archive.html
.  render_taxonomies:output/categories/index.html


.  copy_assets:output/assets/css/index.css
.  copy_assets:output/assets/css/index.css.map
.  copy_assets:output/assets/js/index.js.map
.  copy_assets:output/assets/js/index.js
.  copy_assets:output/assets/css/rst_base.css
.  copy_assets:output/assets/css/ipython.min.css
.  copy_assets:output/assets/css/html4css1.css
.  copy_assets:output/assets/css/nikola_rst.css
.  copy_assets:output/assets/css/baguetteBox.min.css
.  copy_assets:output/assets/css/nikola_ipython.css
.  copy_assets:output/assets/css/rst.css
.  copy_assets:output/assets/css/theme.css
.  copy_assets:output/assets/js/justified-layout.min.js
.  copy_assets:output/assets/js/html5.js
.  copy_assets:output/assets/js/gallery.min.js
.  copy_assets:output/assets/js/fancydates.js
.  copy_assets:output/assets/js/baguetteBox.min.js
.  copy_assets:output/assets/js/gallery.js
.  copy_assets:output/assets/js/html5shiv-printshiv.min.js
.  copy_assets:output/assets/js/luxon.min.js
.  copy_assets:output/assets/js/fancydates.min.js
.  copy_assets:output/assets/xml/rss.xsl
.  copy_assets:output/assets/xml/atom.xsl
.  copy_assets:output/assets/css/code.css
.  render_posts:cache/posts/text-editors/emacs-and-org-mode.html
Loading /etc/emacs/site-start.d/00debian.el (source)...
Loading /etc/emacs/site-start.d/50dictionaries-common.el (source)...
Loading debian-ispell...
Loading /var/cache/dictionaries-common/emacsen-ispell-default.el (source)...
Loading /var/cache/dictionaries-common/emacsen-ispell-dicts.el (source)...
Created img-url link.
Created file link.
Please install htmlize from https://github.com/hniksic/emacs-htmlize
TaskError - taskid:render_posts:cache/posts/text-editors/emacs-and-org-mode.html
PythonAction Error
Traceback (most recent call last):
  File "/home/user/blog.lazkani.io/plugins/orgmode/orgmode.py", line 75, in compile
  File "/home/user/anaconda3/envs/nikola/lib/python3.8/subprocess.py", line 364, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['emacs', '--batch', '-l', '/home/user/blog.lazkani.io/plugins/orgmode/init.el', '--eval', '(nikola-html-export "/home/user/blog.lazkani.io/posts/text-editors/emacs-and-org-mode.org" "/home/user/blog.lazkani.io/cache/posts/text-editors/emacs-and-org-mode.html")']' returned non-zero exit status 255.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/user/anaconda3/envs/nikola/lib/python3.8/site-packages/doit/action.py", line 437, in execute
    returned_value = self.py_callable(*self.args, **kwargs)
  File "/home/user/anaconda3/envs/nikola/lib/python3.8/site-packages/nikola/post.py", line 711, in compile
  File "/home/user/blog.lazkani.io/plugins/orgmode/orgmode.py", line 94, in compile
    raise Exception('''Cannot compile {0} -- bad org-mode configuration (return code {1})
Exception: Cannot compile posts/text-editors/emacs-and-org-mode.org -- bad org-mode configuration (return code 255)
The command is emacs --batch -l /home/user/blog.lazkani.io/plugins/orgmode/init.el --eval '(nikola-html-export "/home/user/blog.lazkani.io/posts/text-editors/emacs-and-org-mode.org" "/home/user/blog.lazkani.io/cache/posts/text-editors/emacs-and-org-mode.html")'

render_posts:cache/posts/text-editors/emacs-and-org-mode.html <stdout>:

[2020-08-31 23:16:29] INFO: auto: Serving on ...
[2020-08-31 23:16:36] INFO: auto: Server is shutting down.

I knew there was a catch !

You might be looking for the error message and it might take you a while. It took me a bit to find out what was wrong. The error is actually the following.

Please install htmlize from https://github.com/hniksic/emacs-htmlize

It turns out that the plugin is a python script that calls emacs with a configuration init.el. I know I have htmlize installed on my doom system but Nikola does not see it.

After looking around the internet, I found the init.el file I’m looking for. It’s in plugins/orgmode/init.el and it has the following few lines at the top.

(require 'package)
(setq package-load-list '((htmlize t)))

Okay, that’s what’s trying to load htmlize. Let’s try to add it to the load-path as follows.

(require 'package)
(add-to-list 'load-path "~/.emacs.d/.local/straight/build/htmlize")
(setq package-load-list '((htmlize t)))


In my case, the path to htmlize is ~/.emacs.d/.local/straight/build/htmlize.

If you don’t have it installed, simply git clone the repository in a directory and load-path that path.

Now, let’s try Nikola.

$ nikola auto
[2020-08-31 23:30:32] INFO: auto: Rebuilding the site...
Scanning posts..........done!
[2020-08-31 23:30:36] INFO: auto: Serving on ...

Woohoo ! It works. Now let’s move to the next steps. Writing our first blog post.

First Org post

Let’s create this blog post.


It is very important to use the nikola command line interface to create the post. I spent too much time trying to figure out the header settings.

$ nikola new_post -1 -f orgmode -t orgmode posts/misc/welcome-back-to-the-old-world.org

Now edit the org file and save it. Nikola should pick it up and render it.

Yes, I have made more changes


I have moved the blog to the willy-theme which offers light and dark modes and good code highlighting.

Blog post format

You might have also noticed that there were big changes to the repository. All the blog posts have been converted to Orgmode now, both pages and posts.

I used pandoc to do the initial conversion from rst to Orgmode as follows.

$ pandoc --from rst --to org /path/to/file.rst > /path/to/file.org

I know, I know. It does a pretty good initial job but you will need to touch up the posts. Fortunately, I did not have a lot of blog posts yet. Unfortunately, I had enough for the task to take a few days. For me, it was worth it.


This was a long overdue project, I am happy to finally put it behind me and move foward with something simple that works with my current flow.