As my “hello world” for this site I thought I’d talk a little bit about the technology running the site and my reasons for choosing it.
This website is a collection of static files served by Nginx. There is no database, and no php, python or any other programming language performing any kind of content creation or request routing.
Choosing to run a static site in this age of wordpress, tumblr and Google+ may seem like an odd decision. But static sites have certain advantages and there are some new techniques and technologies which make working with them much easier.
I will first answer the question “why a static site?” and then move onto explaining my choice of site generator (Hakyll).
Static websites have a couple of advantages over dynamic, database driven applications:
All these are good reasons, but they were not enough to convince me. At the kind of scale I operate at worrying about thousands of users is premature optimisation and I am already running databases and dynamic applications elsewhere.
Two things turned me on to the idea of a static website. Then when I found out that a static website could still look good and be easy to update I was sold. The two things were:
I had found my desired work flow: I want to blog using org mode.
At the time, I was using Zotonic partly to learn a bit of Erlang and partly because I really quite liked it as a CMS. I tried to figure out a way to use org-publish (an org mode utility to convert org mode files to HTML and other formats) and the Zotonic API to publish text files straight to Zotonic. This turned out to be beyond me.
Next I looked for another CMS which would allow me to publish from org mode. Googling turned up two main candidates:
Both of these solutions were static site generators.
In the end I chose neither of these and went with a third option: Hakyll, a Haskell library for generating static sites.
The main reason is that customising Hakyll uses Haskell which is the programming language I know best. This meant that I felt confident that I would (eventually) be able to get the site to do what I wanted.
I have a folder called “eanalytica” within which are several subfolders:
The main folder also contains a Haskell program called “site” that is written using the Hakyll library.
When I run the “site” program it uses the contents of the posts folder and the templates to generate the static HTML files which it places in a folder called "site". Then all I have to do is upload the _site folder to my web server. You can read the source code to my Hakyll site generator if you want to find out a bit more about how this works. The official Hakyll site also has some documentation.
So now my blogging workflow looks like this:
In fact, it is even simpler than that because three of the above four steps can be automated.
I’m only one post in, but already I like my new workflow.