The electric word.
You've stumbled across my blog: the home of my most private, innermost thoughts and reflections. And random cat videos.
$ blog engine ii: the basics24/05/2016

After another considerable hiatus (maybe I'm just not cut out for blogging), I thought I'd try and resuscitate this series of posts reflecting on my self-written blog engine. This post will cover the underlying tech, with some reasoning as to why it was chosen.

Language: JS/Node
Database: NONE
Styling: LESS
Templating: Handlebars
Blog posts: Markdown

First things first: I opted for Javascript and Node for the simple reason that this project was intended to be a bit of an experimentation into the possibilities of Node.js, especially in a desktop environment.

I originally intended to set up a MongoDB database to handle the storage of all my blog data, but after (not much) deliberation, I decided against this. My main driver for this project was simplicity, and I couldn't justify the need for a database here; the only real data I'm throwing around is a list of blog posts (with accompanying metadata) and some configuration data, so a database here seemed like overkill. The only 'problem' with this solution was that I wouldn't be able to send dynamic data to users, so all pages would have to be static. Although this adds some complexity to the engine itself, removing the middle-man meant that the end-user experience is much snappier.

Next up, structure. I chose Handlebars for the templating of my site, as it's a library I've used satisfactorily many times now, and had no reason for greener pastures. I created a very basic structure hierarchy for my site which consists of:

  • A top-level html page: contains the global elements such as the nav bar, footer, and all of the file includes.
  • Handlebars templates for individual pages: these would be loaded into the top-level page, and contain page-specific content.
  • Markdown files for the actual page content: this applies to the truly static pages (such as the homepage), and things like blog posts. Using markdown allows me to easily apply styles to the site text without the need for any complex CSS.

For the styling of my site, I originally used plain old CSS, but later added support for LESS, as it allowed me more flexibility and more importantly cut out a lot of clutter in my CSS files.