Up to the point where I discovered “Static Site Generators”: I was more willing to develop a website using code and a self made simple content management system than I was to return to the days of hand coding HTML pages with duplicated markup. Its simply too cumbersome to approach all that duplicated HTML code.
After Saying Goodbye to Pylons and approaching Ruby on Rails, I decided it would be a good exercise to revisit my existing websites and look at converting them over to Rails 3, I started looking at what needed to be done and realised that in many cases, it simply wasn’t worth it to code content management and store content in a database. What I needed was something that would generate static websites for me without all that duplication. Leaving me to code Rails websites where code, a database and content management were required.
What is a Static Site Generator?
A Static Site Generator is a program, that generates an HTML website as an output. ThisHTML website is then served through your web server, just like the old’n’days. This is usually achieved using template languages and code that separates out the layout of the website from its content and styles.
Advantages of a Static Site Generator?
- Security – There’s no database layer, or rails/pylons layer of code so security excellent.
- Performance – Under load, less memory / cpu usage to serve your website, so your website stays up longer
- Have a copy of your content separate from your server
- Easily move your website to another host – Copy and paste the HTML and re-route the domain name should you have one.
- Easily choose website hosting – You don’t have to worry about which technology they use, because you only need to serve HTML.-
- Website Hosting is cheaper.
Disadvantages of a Static Site Generator
- You can’t update your website unless you’re at your computer where the static site generator software is installed
- You can’t have local comments, pingbacks, non-google site wide search, contact us forms (without some dynamic code etc)
Which Static Site Generator?
There are many static site generators out there to choose from. Here’s a selected (ruby) list:
My Selection Criteria
While creating this blog, I tried out quite a few before I settled on Jekyll. Having no previous Ruby on Rails or Sinatra web framework experience, I found some of them to be a bit difficult to comprehend, while other were too restrictive. My main criteria for selecting a Static Site Generator were the following:
- Don’t force me learn too many languages (read haml/scss/sass/less)
- Have easy to understand layouts
- Have example websites and code that can be copied and used to learn from
- Have an auto updating server that provides me a development environment
- Has comprehensive documentation.
My Choice: Jekyll
I felt that Jekyll met these criteria and so set about creating the blog you see here today. Jeykyll is the engine behind the GitHub Pages feature. Jekyll is very blog aware, this means that you can use:
- Supports migrating from other platforms like Movable Type, Drupal, Wordpress, Marley, and Typo
It’s also quite easy to do rss feeds and has a plugin system with some third party plugins available.
To process templates, Jekyll uses the liquid templating engine but it also has it some of its own extensions to liquid which provide some filters and tags to achieve certain things such as line numbering, including small page fragments and textilizing page excerpts.
Content is typically written in Markdown or Textile. This allows you to concentrate on your writing and not on the styling of your content. And being a statically generated website, you’ll have you content in a readable format on your computer available to you should you wish to re-use it or re-publish it. No database extracts, SQL or tricky php wordpress extracting addons required.
I’ve found that it can also be used for a bit more than just blogs. I’m currently rebuilding another simple website using it and I’ve found the liquid templating and markdown/textile content creating to be very easy to pick up and quick to get me productive. It just takes a little lateral thinking to get your layout files setup correctly.
I’ve found the main advantage of using a static site generator to be the ease of getting things up and running. You can use it for serious production websites or just to provide your client with a usable / workable prototype of a design prior to getting into the nitty gritty of detailed code and database design. Jekyll is highly recommended and has suited my needs and skills perfectly. I encourage you to look around and try a number of the existing static site generators out to find the one that best suits your needs.