The Game Developer's Guidepost

The Game Developer's Guidepost

Your guide to learning game development

Why I Love Using a Static Site Generator

February 8, 2016 by tspike

A couple of months ago I decided to make a small change to the footer of this website. I only wanted to change the validators from image links to plain text links. Since the footer is visible no matter what page you're viewing, this meant making changes to HTML code on every page of the website. Even with the small number of pages at the time (around twelve) this was still pretty inconvenient. Since I was planning on adding more pages, I was worried how difficult maintaining this site would become.

As an amateur programmer I couldn't help but think about how inefficient it is to implement site-wide changes on a page-by-page basis. In programming circles, many people adhere to and encourage the use of the "DRY" design principle. DRY stand for "Don't Repeat Yourself", and simply asserts that you should limit duplication of code. Duplicate code can be difficult to maintain since updating the same code located in multiple places can be tedious and is error prone. I was hoping there was a feature for reducing code duplication somewhere in the HTML standard. It turns out, this is not the case.

I decided to look around and see if anyone had managed to address this weakness in HTML. Apparently people have through the use of software referred to as static site generators. Basically, a static site generator takes files containing small sections of a web page (such as the footer or header) and compiles them into a complete web page. This means that if I wanted to change the footer for my site I would only have to update a single file. The downside to static site generators is they are all (as far as I know) run through the command line. This isn't much of an issue for me because I'm pretty comfortable working through a terminal, though it might be a deal-breaker for some.

There are numerous static site generators out there. So many in fact, that there's even a website devoted to listing them. The first static site generator that I learned about was Jekyll. However, I thought the documentation looked daunting, so I decided to look elsewhere. I gave Hugo a try, but found its documentation to be a bit unfriendly for a newbie like me and there are virtually no tutorials on the web at this point. I tried out WebGen because it had a great introductory tutorial, but learning where to go from there was difficult due to lack of helpful information beyond that point. I then decided to give Jekyll a try after all. The installment base for Jekyll is quite large, and consequently there's a lot of discussion online regarding numerous aspects of the software.

Though discussion on the Internet about Jekyll mostly revolves around managing a blog, Jekyll can also make building pretty much any static website a lot cleaner. I find developing and maintaining this website is much easier now that I'm using Jekyll. Now if I need to edit a section of my site I only need to make changes to a single file and then Jekyll will recompile all the web pages on the site for me. This allows me to adhere to the DRY principle while developing my website, and that's why I love using a static site generator.