01 – What is a static site generator?

Last Updated: Mar 31, 2022

Hugo is a static site generator for building websites, and can be a suitable replacement for content management systems such as WordPress, Joomla, and Drupal.

Traditional content management systems (CMS) are server applications that store content in a database and are written in a programming language such as PHP, Perl, or JavaScript. When a visitor arrives at a website powered a CMS such as WordPress, the web server routes the request to the CMS application, which decides the content the user is requesting by the URL of the request. The application makes a database request to retrieve the content, injects that content into the appropriate template, and delivers the constructed HTML page to the web server which then sends the response back to the user.

All of this processing takes time by the server. This might not be a problem for a low volume website, but as traffic increases, the resources (memory and CPU) required to service those requests will increase too. With a high enough volume of requests, the server will take longer to respond and may eventually be unable to continue serving requests or even crash.

As a website operator using a CMS like WordPress, you can solve this problem with a number of solutions such as implementing caching, buying a bigger server, or using load balancing to share the traffic among multiple servers. These solutions come with tradeoffs, and some of them cost money.

Static site generators get around this problem by eliminating the main bottleneck, which is the CMS application itself. With no database or CMS scripts taking up processing time, a web server that is delivering only static files will be much faster and can handle a much larger volume of requests. For example, even a tiny Raspberry Pi server running Nginx can handle at least 80 requests per second.

When you use a static site generator, all of the pages of your website are built ahead of time as a collection of HTML files. The only thing you deploy to your production web server is a bundle of static HTML files, along with supporting assets such as images, CSS, and JavaScript files. When a user makes a request to your website, the web server simply serves up the static file they requested. There’s no database or backend server scripts to wait for.

This also makes deploying your website much easier. You can even host your statically-generated website on a cloud-based object storage service like Amazon S3, eliminating the need to manage a traditional web server at all.

However, using a static site generator doesn’t mean that your website content needs to be static too. By using Javascript to make requests to other web services, your website built with Hugo can still be dynamic and interactive.