What is a Static Site Generator?
Static Site Generators are a new, hybrid approach to web development that allow you to build a powerful, server-based website locally on your computer but pre-builds the site into static files for deployment.
Static site generators are growing in popularity among developers and there are now popular options in every major programming language as well as an emerging ecosystem of static website services to provide static websites with dynamic-like functionality.
How Static Sites Work
The first website in history, by Tim Berners-Lee in 1990, was a static site containing simple HTML. It represented just text and links.
How Dynamic Sites Work
In 1993, three years after the first website, the Common Gateway Interface (CGI) was introduced and allowed websites to communicate with a database. As a result, dynamic websites were born which could display dynamic (get it?), database-driven content to users.
For example, when you log into Facebook, the company checks its database and displays a homepage with content just for you. Ditto when you log into Gmail, Amazon, or other prominent dynamic websites.
Dynamic websites are more powerful than static sites but are correspondingly more complex. This has advantages and disadvantages.
Advantages of Static Sites
Static sites are fast! Since there are no database queries, no templates to render, and no client-server requests to process, a static site will always load faster.
Dynamic websites are constantly at risk of attack. Drupal, which powers 5% of all websites (12+ million users) was recently hacked and Wordpress, which powers 26% of all websites, is notorious for frequent security vulnerabilities.
Static sites (like this one) costs pennies per month to run on services like Amazon S3. Dynamic sites require the setup, hosting, and maintenance of a server which is much, much more expensive.
Unexpected traffic surges can crash a dynamic site. A static site is much better prepared as delivering static pages consumes very little server resources.
Disadvantages of static sites (and potential solutions)
1) No CMS for non-developers
Traditional static site generators cannot be updated via a content management system (CMS) by non-technical users. However several startups now offer web-based CMSs for static site generators including Contentful, CloudCannon, Forestry, and Pulse. Lektor, a new Python-powered SSG, provides a Mac app CMS.
2) No real-time content
3) No user input
4) No user login
A static site, by definition, can’t handle user logins directly in a secure fashion. This is another, seemingly intractable, problem.
There are, however, some new approaches that offer a peek at what the future might offer. For example Jekyll, the most popular static site generator, offers jekyll-auth to provide OAuth against Github.
Static site generators have emerged in recent years as a popular bridge between static and dynamic websites. While there are still some existing tradeoffs, the list of dynamic-only features is shrinking. Once static CMS interfaces truly emerge to allow non-developers to update SSG content, expect the growth of static site generators to take off exponentially.