<- back to homepage

A Simple Static Site Generator in Emacs

Ocean

In these days, it is no longer needed to have a knowledge of web development to craft a website yourself. There are thousands of website generator tools that does the job for you, but when your site is hosted graciously on a tilde, it is unfair to burden the admins with your JS bloated “modern” website. That’s when I decided to write a static site generator myself. The heart of the program lies in Org Mode, which saved most of my time.

Deciding on a theme

Not being an expert in colour theory, and not wanting to use pre-existing website templates, I was thinking of ways to select a theme for the website. At last, I chose to use the same colours I’ve been using elsewhere.

The color choices were heavily inspired by the Modus Operandi theme. I intent to change these at a later™ point, but the current ones suffice for now. The modus-themes-list-colors-current and describe-faces commands did most of the work in describing the available faces and their respective colors.

Ocean

Adding a new entry

Adding a blog entry was as simple as typing C-c n b, which would prompt for the title of the blog and would add a new entry to the archive, and would create a new copy of the boiler plate titled YYYY-MM-DD-{TITLE}.org. Then you would go on writing it as if it were a normal org file, no messing around with HTML required. Saving the file would automatically run the export function ox-slimhtml-export-to-html, which converts the org specific markdown notations to their HTML notations and saves it to a html file. On killing the buffer, the homepage is updated, with the first N entries from the archive (sorted in reverse chronological order).

The default html exporter had too many features that I did not require, hence I resorted to the use of a third-party org exporter. The difference in the file size shouldn’t matter much, although using the latter on a simple page like this reduced the file size by 50%.

Finally, when I’m satisfied with all my changes, C-c n f runs a shell command which updates the contents of the public_html of remote server with the local copy.

Conclusions

Not wanting to spend much time on the initial entry, I decided to describe the workflow of maintaining a simple website like this.

Looking forward, it becomes a necessity to have a deep understanding web development when you plan to blog on the longer term.