summaryrefslogtreecommitdiff
path: root/posts/Transition to Haunt/transition-to-haunt.org
blob: 7d347c592816281f2c46cfb3f6ad5f73d844a659 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#+TITLE: Transitioning to Haunt
#+DATE: <2019-05-04 Sat>
#+TAGS: writeup, programming, lisp, scheme, emacs, emacs-lisp

Rather than study for finals this week, I spent my time moving this blog over to
[[https://dthompson.us/projects/haunt.html][Haunt]]. Previously, I was using Hugo, and while [[https://ox-hugo.scripter.co/][ox-hugo]] made the authoring
workflow tolerable, doing anything on the rendering side of things was unsavory
at best. I eventually had enough and decided to look for another solution, of
which Haunt was the most enticing.

I should probably begin by thanking [[https://dthompson.us/][David Thompson]], not only for his work on
Haunt, but also because he made the [[https://git.dthompson.us/blog.git][source code for his Haunt blog]] available.
I'm sure our similar stylesheets is enough of a hint that I used his blog as a
starting point. In hopes that it may be useful to someone else, I have also
chosen to make my Haunt configuration and Org sources available [[https://git.sr.ht/~jakob/Blog][here]].

On the topic of Org sources, my chief concern with transitioning away from Hugo
was the possibility of losing my ability to author posts in =org-mode=. After all,
"Org" is not among the available readers in the upstream Haunt repository. I
handled this by taking the same approach as =ox-hugo=: writing an Org Export
backend. I call it [[https://git.sr.ht/~jakob/ox-haunt][ox-haunt]], and it really doesn't do much. It piggybacks on
=ox-html= and Haunt's =html-reader=, filling in the metadata section according to
whatever Org keywords it finds. I've also tried to keep it relatively
unopinionated, leaving the output of =ox-html= generally unaltered -- if you don't
like the gross old-school XHTML, set =org-html-doctype=. Do note, though, that
=xml->sxml= can't read implicitly self-closing tags like =img=. So make sure you set
it to ="xhtml5"= and not ="html5"=.

If you do end up using =ox-haunt=, you'll need to use a slightly modified
=html-reader= for versions <= 0.2.4:

#+BEGIN_SRC scheme
(define (read-html-post port)
  (values (read-metadata-headers port)
          (let loop ((ret '()))
            (catch 'parser-error
              (lambda ()
                (match (xml->sxml port)
                  (('*TOP* sxml) (loop (cons sxml ret)))))
              (lambda (key . parameters)
                (reverse ret))))))

(define html-reader
  (make-reader (make-file-extension-matcher "html")
               (cut call-with-input-file <> read-html-post)))
#+END_SRC

The =html-reader= included in those versions can't read more than one top-level
element. I've submitted a patch, but as of the time of writing this, it hasn't
made its way into the upstream repository.

Also, see that beautiful syntax highlighting? One of the benefits of using
=ox-html= as a base was =htmlize=. I've even been able to tailor the colors to my
Emacs theme.

Oh, one last point. I've dropped the header images for my posts. I was using
them in hopes of emulating the look of [[https://dolphin-emu.org/blog/][Dolphin Emulator's blog]] and [[https://aixxe.net/][aixxe]], but I
really don't think I was able to do the technique justice.

#+BEGIN_EXPORT html
<div class="mastodon">
    <iframe height="200" src="https://mastodon.social/@rocx/100964480434249864/embed"></iframe>
</div>
#+END_EXPORT

Overall, I'm happy with that choice of static site generator. Compared with
Hugo, Haunt is far simpler and easier to hack on. Honestly, who cares if I'm
using the "world's fastest framework for building websites"? =haunt build= still
finishes in under a second. And despite describing myself as a Common Lisp-er,
I've been having a blast using Guile Scheme for this.