Welcome back, my dear blog!

First rule of the blogger: describe the setup of your blog (c) @quarckster

I used to have blog.zhukoff.net in the past. It was in Russian and wordpress-powered. Maintaining of the wordpress, backups and posting using web browser was not good experience overall so it happened and the blog died… Few days ago I’ve decided that I need some space to put my thoughts, logs and random stuff and I don’t want to use any WYSIWYG editors. Confluence at work is driving me mad, having something similar for out of work activities was not an option. So the requirement was: static web pages generator which is able to convert some kind of markup language into nice but simple blog. As I spent most of the time in Emacs editor (or Emacs OS because vim is the only text editor) the solution which has been chosen is quite obvious: emacs org-mode + hugo.

Setup is quite simple. Blog directory with simple config:

baseURL = 'https://blog.zhukoff.net'
canonifyurls = true
relativeURLS = false
contentdir = "content"
publishdir = "public"
languageCode = 'en-us'
title = "Landgraf's notes"
[[params.links]]
[[params.links.link]]
name = "Github"
href = "https://github.com/landgraf/"
[[params.links.link]]
name = "Tags"
href = "/tags"
[[params.links.link]]
name = "Categories"
href = "/categories"
[[params.links.link]]
name = "Archive"
href = "/posts"
[markup.goldmark.renderer]
  unsafe = true

[module]
  [[module.imports]]
    path = "github.com/adityatelange/hugo-PaperMod"

If you’re going to use this PLEASE pay attention to baseURL parameter. It’s really important, like REAL important and MUST point to the real, DNS-resolvable URL of the blog, otherwise the result of the rendering will look nice locally but once synced to web server it will be screwed up! You’re warned, I’ve spent few hours debugging this.

And ‘ox-hugo’ package for emacs installed as simple as:

M-x package-install ox-hugo
(require 'ox-hugo) ;; add to .emacs.el

And… org-mode subtree can be exported in hugo with

C-c C-e H H

The only thing I had to add is properties to the top-level heading of the pos

:PROPERTIES:
:EXPORT_FILE_NAME: my-post
:EXPORT_DATE: <2023-02-09 Thu> ;; We're in org-mode, right? This can be added as simple as C-. :)
:END:

and point org-mode to the top dir of the hugo with:

#+hugo_base_dir: /home/pzhukov/repos/blog/blog.zhukoff.net
#+HUGO_AUTO_SET_LASTMOD: t

the only step left is to compile public pages and copy them over to the root directory of your favorite web server. hugo itself can serve as a web server, however it is not recommended

## NOTE: 991:990 is uid and gid of the user webserver is running with
hugo && rsync -a --delete -v --chown=991:990 public/ user@mywebserver.com:/usr/share/nginx/html/

Benefits of such setup are more than obvious:

  • No more heavy full-blown WYSIWYG editors for simple blog
  • (almost) all features of org-mode formatting/gtd/timestamps/refilling/capturing can be used
  • Blog can be exported not only into hugo but plain html, pdf, jira :) etc with org-mode’s export engine
  • backups can be done in simple git repo with version control

So far, so good! Stay tuned!