build-system-change.org 3.3 KB

Why I Changed the Site's Build System

<p>
I started off this website in <a href="https://common-lisp.net/" title="Common Lisp">Common Lisp</a> then to org-mode and now finally to a
</p>
<p>
mixture of the two?! Well, okay, not really a mixture - more like a semi-similar
</p>
<p>
adaptation. Okay, that's not really true either... Lemme just explain it simply:
</p>
<p>
the new build system using <a href="https://gnu.org/software/emacs" title="Emacs">Emacs</a> <a href="https://orgmode" title="org-mode">org-mode</a>, <a href="https://www.gnu.org/software/make/" title="make">make</a>, and a small <a href="https://fennel-lang" title="Fennel">Fennel</a> script. Why
</p>
<p>
is this better than using plain old org? Let me explain...
</p>

I started off writing the site with Common Lisp because I love Common Lisp! It's the language that got me into software and one of my favorite languages! After writing the site and sitting back to look at it, I realized that maybe it was overkill to use Common Lisp to do this... I mean, the site is 100% static...

So, I looked elsewhere and found out how to use org-mode to make a site. I used Dennis Ogbe's guide to do this. Surely this was the answer! - Not so fast... Very shortly after I finished the site again, I sat back and looked at it and realized that org-mode updated and :sitemap-function changed... Dennis never updated his blog so I was left with a broken build system. I spent a lot of time trying to get it working and came to the conclusion that this is _waaay_ too complicated just for the ease of org-mode's HTML exporting. I wonder, how could I get the best of both worlds?

Around this time I was falling in love with Fennel due to me working on qire. I had an idea! What if I wrote a little Fennel program that took some HTML for the header and footer then mashed it together with some body HTML. That's where the concept of my PG (Page Generator) program can from. That was great but I didn't want to have to write a bunch of HTML when I wanted to upload a new blog - and I didn't want to have to compile each page one-by-one. That's when I came up with the idea of using Emacs and make.

Turns out you can write emacs scripts... Who knew?! So I did that and it takes the org file, dumps it into a temp buffer, then exports it to HTML. Works like a charm! Then we just put the emacs script and PG into a makefile and we're done! Just run make and it will export the org files to HTML, parse the body, smash it together, and put it into an output directory. Then you just server it! :)

How is this easier than just using org? Well, it's not necessarily easier, it's simpler. What this mean is that you can clearly understand each step in the process. With almost zero experience with emacs or org. Plus, I know that it'll always work! Unless emacs no longer allows scripts or org's =org-export-to-file= function stops working, it'll work. Yes, yes, it's "more work" to add in a new blog - but c'mon, it's not that bad! Create the org file, type in it, copy the information to properly link to it in the blog page, and run make. That's not too difficult, is it?