Static Site Generator
A static site generator provides the ability to generate a completely static HTML-based site that doesn’t require a database or server-side processes. Static sites have grown greatly in popularity due to their ability to quickly serve content, their simplicity, security benefits, etc. Based on the project and your preferred coding language, there may be a static site generator that is suited to your needs. Although not applicable to every web project, static sites do offer various benefits over using a dynamic site.
Advantages of Using a Static Site Generator
Using a static site generator to produce a completely static website no doubt has its advantages. The following outlines a few of these benefits.
Speed plays a major role in improving various aspects of a website - from usability to SEO. Since static sites are made up of completely static files, there is no need to query the database or run any resource-intensive server-side scripts.
For instance, if you are using a dynamic site and have a PHP variable within your HTML file such as
<title><? echo $title;?></title>
every time that file is requested, a PHP script must run in order to fill in the variable
with information. This not only consumes server resources but also takes more time. With an HTML-based site, all the information is already in the file and there is no need to run any scripts to gather the information from other places.
Easy CDN Acceleration
Being that the site is completely static, this allows for an easy and straightforward integration with a CDN. Caching dynamic content via a CDN is often times not recommended, however with a completely static site, everything can be delivered by the CDN. There are no special or complex rules that need to be configured and static site hosting with a CDN can be accomplished in just a few steps.
Static sites are more simplistic in structure than their dynamic alternatives. There is no database, packages, libraries, etc. instead, once the site is generated you are simply left with HTML files. This means you can easily migrate your static site to be served from anywhere without any compatibility issues. You also are required to configure as many aspects of your server in order to get a website up and running.
Since static websites are comprised of solely static files there is much less concern for security issues. Since they have no database, attackers cannot perform SQL database injections, or take advantage of server-side security holes.
Completely HTML-based sites consume very small amounts of server resources since, as mentioned above, they do not require scripts to run in order to retrieve information. This allows for a static website to scale very quickly without easily overloading the server.
There are of course disadvantages that come with static sites mainly due to their simplicity. For instance, there is no user interface, thus posts are written in a text editor and must be re-uploaded to the server each time there is a change. There is also no ability to process data, no real-time content, and no ability for user input such as comments (although there are work arounds).
How Does a Static Site Generator Work?
Depending on the type of static site generator used, there may be some additional steps to rendering an HTML site. However, for the majority of static site generators they function in the following manner.
- Content is written in a simple markup language (commonly markdown).
- A pre-made template is selected or a custom template is configured to pair with the content.
- The template and content are processed through the static site generator which creates the HTML files.
- Once the HTML files are generated, you can simply upload them to your configured web server or CDN and the static pages become accessible.
Popular Static Site Generators
The following is a list of 10 popular static site generators. Each generator is built differently and although many may have the same overall purpose, there are differentiation points such as language used, and capabilities for each.
|Static Site Generator||Language||Description|
|Jekyll||Ruby||A blog-aware static site generator with permalinks, categories, pages, etc.|
|Octopress||Ruby||A static blogging framework based on Jekyll.|
|Hugo||Go||A static site generator ideal for blogs, docs, portfolios, and more.|
|Pelican||Python||A static site generator with the ability to customize themes via Jinja templates, publish content in multiple languages, and import from WP.|
|Sculpin||PHP||A static site generator written in PHP that allows the use of Twig templates, Symfony Bundles, and embeds composer.|
|Middleman||Ruby||Uses all of the modern web development tools and shortcuts.|
|MkDocs||Python||Geared towards generating a static site for project documentation.|
Static Site CMS Solution
For those who still want to take advantage of some of the functionality of a CMS while using a static site, there is static site CMS solution. Lektor, provides users with the ability to generate completely static websites that are 100% file-based freeing you from the need of a database or any server-side code.
What separates Lektor from other solutions is that this static site CMS comes with a customizable admin interface allowing you to edit content without touching the raw source. This feature may appeal to users who aren’t comfortable with modifying content directly in HTML but still want to take advantage of the benefits that exist in using a static site.
Static site generators certainly provide some enticing benefits to users who do not require the functionality of a dynamic website. As they continue to grow in popularity, different variations are created for different purposes. However, the main benefit of a static site for most will likely continue to be it’s ability to quickly serve content to users. Although static sites alone can deliver content quickly, static site hosting with a CDN can help even further improve their ability to deliver content in a speedy manner.