226 lines
8.7 KiB
Markdown
226 lines
8.7 KiB
Markdown
+++
|
|
title = "Welcome back to the old world"
|
|
author = ["Elia el Lazkani"]
|
|
date = 2020-09-01T21:00:00+02:00
|
|
lastmod = 2021-06-28T00:01:23+02:00
|
|
tags = ["blog", "org-mode", "emacs", "rst"]
|
|
categories = ["nikola"]
|
|
draft = false
|
|
+++
|
|
|
|
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](https://gohugo.io/)_. 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 ?
|
|
|
|
<!--more-->
|
|
|
|
|
|
## Why _Hugo_ you may ask {#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](https://plugins.getnikola.com/v8/orgmode/) page where you find
|
|
|
|
```text
|
|
$ nikola plugin -i orgmode
|
|
```
|
|
|
|
Where the heck did that come from ? Okay that was easy.
|
|
|
|
Turns out _Nikola_ supports _Orgmode_.
|
|
|
|
|
|
## Nikola _Orgmode_ plugin installation {#nikola-orgmode-plugin-installation}
|
|
|
|
The page suggests running.
|
|
|
|
```text
|
|
$ nikola plugin -i orgmode
|
|
```
|
|
|
|
Followed by
|
|
|
|
```python
|
|
# 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 {#alright-let-s-run-our-first-org-post}
|
|
|
|
The installation was easy, running it should be just as easy.
|
|
|
|
```text
|
|
$ 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
|
|
subprocess.check_call(command)
|
|
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
|
|
self.compile_html(
|
|
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 http://127.0.0.1:8000/ ...
|
|
[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.
|
|
|
|
```text
|
|
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.
|
|
|
|
```emacs-lisp
|
|
(require 'package)
|
|
(setq package-load-list '((htmlize t)))
|
|
(package-initialize)
|
|
```
|
|
|
|
Okay, that's what's trying to load _htmlize_. Let's try to add it to the `load-path` as follows.
|
|
|
|
```emacs-lisp
|
|
(require 'package)
|
|
(add-to-list 'load-path "~/.emacs.d/.local/straight/build/htmlize")
|
|
(setq package-load-list '((htmlize t)))
|
|
(package-initialize)
|
|
```
|
|
|
|
<div class="admonition note">
|
|
<p class="admonition-title">Note</p>
|
|
|
|
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.
|
|
|
|
</div>
|
|
|
|
Now, let's try _Nikola_.
|
|
|
|
```text
|
|
$ 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 http://127.0.0.1:8000/ ...
|
|
```
|
|
|
|
Woohoo ! It works. Now let's move to the next steps. Writing our first blog post.
|
|
|
|
|
|
## First _Org_ post {#first-org-post}
|
|
|
|
Let's create this blog post.
|
|
|
|
<div class="admonition warning">
|
|
<p class="admonition-title">warning</p>
|
|
|
|
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.
|
|
|
|
</div>
|
|
|
|
```text
|
|
$ 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 {#yes-i-have-made-more-changes}
|
|
|
|
|
|
### Theme {#theme}
|
|
|
|
I have moved the blog to the _[willy-theme](https://themes.getnikola.com/v8/willy-theme/)_ which offers _light_ and **dark** modes and good code highlighting.
|
|
|
|
|
|
### Blog post format {#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](https://pandoc.org/) to do the initial conversion from _rst_ to _Orgmode_ as follows.
|
|
|
|
```text
|
|
$ 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.
|
|
|
|
|
|
## Conclusion {#conclusion}
|
|
|
|
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.
|