Static website generators (SSGs) are programs that create HTML pages of a website from text-based template files or already prepared HTML sources. A SSG represent an alternative to a database-based system (CMS) such as WordPress. In content management systems, the content of a website is not managed in simple text files but stored in (relational) databases such as MySQL.
A typical CMS-driven website works by building each and every page dynamically. That means fetching the content from a database to pass them over to a template system (engine) to load the page content, adding the required structure information (e.g., CSS styles) and Javascript components if needed. This means every page is assembled on demand.
Accessing scheme for a CMS (dynamic web)
Rendering Engine (e.g. PHP-based)
Database (e.g. MySQL, Postgres)
Static content (Images, Videos, JS- and CSS files) and Caches
A Static Site Generator takes a different approach and generates all the pages of the website upfront. That does not necessarily mean that a static website is always built from scratch. Modern generators support a so-called incremental build, as does. When there are changes detected to the content, only selected pages will rebuild.
Accessing scheme for a static web
Server-side rendered (prepared) static content
In the case of blogs, documentation sites, or company websites, CMS and website builders are used for this, but static site generators have distinct advantages over a typically much more complex content management solution:
- Speed
-
Websites created with a static website generator are characterized by excellent user speed. Files are processed when the page is created and not when the user views the page.
- Version Control
-
Although the content of dynamic web projects is stored separately from the code in databases, a static website usually resides in simple text files that are fairly easy to maintain. Structurally, the content elements do not differ from other parts of the code base, so version management is set up without any problems.
- Security
-
The advantage of websites built with static website builders is that they offer little potential for attack, unlike, for example, content management systems like WordPress, which are vulnerable to security vulnerabilities and need to be updated regularly. The risk potential is limited to the one-off access by the customer when accessing the site. Since this is usually not about more than the delivery of structured HTML pages, the probability of unwanted access is minimal.
- Easy Maintenance
-
The number of components required for SSGs is comparatively small, but these are only relevant during development. While other solutions for live operation require various modules, databases, libraries, frameworks, and packages and have to be updated regularly, static pages are only tied to a functioning web server.