I’ve been noticing a lot of chatter about static site generators over the last couple of months and they sounded like an intriguing topic so I decided to dive straight in and have a go for myself.
What is a Static Site Generator and Why Would You Want to Use One?
A static site generator is a tool that will allow you to create websites locally using some techniques which are normally done server side such as includes and templating. It will then take your files and compile them into pure HTML.
So why would you want to do that?
- Well for a start pure HTML is always going to be faster to load than any client side or server side HTML generator.
- Many static site generators can also generate blog templates for you in pure HTML which means no reliance on a database or CMS.
- Many also include handy local servers with live reload functionality so you can magically see the changes you make in your code appear in your browser.
- And if you were planning on making a static site to start with then the templating and other handy features will help you speed up the development process and keep your code DRY.
Which Static Site Generator Should I Choose?
There are currently a few options available for static site generation. I haven’t tried all of them but the idea behind them is generally the same.
As you could probably guess from the name Hammer is an app for macs. It includes all the good stuff you’d expect from a static site generator; templating, CoffeeScript and SASS support (no Compass yet). And it’s all wrapped up in a nice interface. A good choice if you’re a mac user looking for a straightforward option.
Mixture is currently in a private alpha but will be available for both mac and windows. Mixture is a GUI based tool similar to Hammer but includes a few more features that may make it the preferable option. It supports SASS and Compass as well as Less and Stylus if those are your CSS preprocessors of choice. Mixture will also optimise and compress your files for you. So far Mixture is the only option I have found with a GUI for Windows but if you want to download it now you’ll need to sign up for the preview and hope you get in.
Now we’re getting into the scary world of Ruby gems (If you don’t know what those are then the following static site generators are probably not for you). Jekyll is mainly designed for text based sites such as blogs, first you set up what makes the structure of your site (pages, posts etc.) then you write your blog post in markdown or another supported language and Jekyll will spit out an HTML site with pagination and categories and all that good stuff you expect from a blog. Whenever you add a new blog post you simply write it locally, have Jekyll recompile your site and upload.
I have also included Octopress as an option here as it is a spin off of Jekyll that is already set up for a standard blog format, removing some of the learning curve of Jekyll.
Middleman is certainly the most feature filled static site generator on this list (and my tool of choice). It is another Ruby gem based option:
Providing dozens of templating languages (Haml, Sass, Compass, Slim, CoffeeScript, and more). Makes minification, compression, cache busting, Yaml data (and more) an easy part of your development cycle.
For me the main attraction of Middleman is it’s versatility. It can compile any supported language into another one, an example of this would be that you can write pages in Markdown that compiles to ERB (Ruby Templating Language) which then compiled to HTML. And it’s not just HTML that Middleman can generate, it could be anything you want – you could use it to generate PHP code if you wanted (I’m not sure why you would want to but it’s nice to have the option). Middleman also has a blog extension to make it similar to Jekyll and many advanced compression tools.
And Many More
There are a whole load of other options out there (mainly Ruby gem based, but there are also a number of PHP based tools and many more), I have just included the ones that I have heard most about. There is a nice list of static site generators available here but is in no way comprehensive so do your own research and find one that you like and you won’t look back.
Static site generators seem to be picking up steam, and rightfully so. They now make a viable alternative to simple server side based sites and can even be an improvement on full fledged content management systems in the right scenario. And with new tools with nice GUIs coming out I’m sure there will be a whole lot more people interested in using them.
Have you tried any yet? If so which one and how did you find it?