Advantages & Disadvantages of Static Site Generators
Could it be possible that static sites are making a comeback? Even though the popularity of content management systems has skyrocketed in recent years, some projects are still better served by static sites. It seems that, at least in some cases, static sites are a more advantageous choice compared to content management systems.
To get a better grasp of when you should choose a static site over a CMS, and when you should go with a CMS instead, we’re going to introduce you to static site generators, highlighting their advantages and disadvantages.
What are Static Site Generators? How Do They Compare to a CMS?
But as sites grew larger and more complex, difficulties arose in updating files, keeping tabs of folder structures, and basically handling dynamic content. To overcome these issues and to better handle the intricacies of complex websites in-came content management systems (CMS).
A CMS comes with an administrative panel allowing users to write content, which is then stored in the back-end database.
Creating a website and maintaining it with a CMS can be done without interacting with the code, and CMS work with concepts such as themes or templates, which control the way pages are displayed in a visitor’s browser (the front-end of the website). CMS opened the way to non-programmers to try their hand at building websites, and also made it possible to handle of dynamic content (e.g. blogs) without issues.
Static site generators, on the other hand, are a one-up from hand-coded static sites, yet not as complex as a CMS, still, it’s often described as a compromise between the two. A static site generator will also use templates to generate static HTML-only websites, whose content is either extracted from a database or, most commonly, by being read from flat-type files like Markdown.
Static site generators are often overlooked due to their often-unfriendly installation process and lack of a user interface, yet, despite these issues, in some instances an SSG (static site generator) can be better suited for your project than a CMS, or when a CMS may be an overkill.
What are the Advantages and Disadvantages of Static Site Generators?
Now that you know a bit more about the place of static site generators on the map of website building, let’s see what are its advantages and disadvantages compared to a CMS?
Advantages of SSG:
The speed advantage of static sites is one of their biggest advantages. Since there are no database queries to run, no processing on every request, web servers have no issues serving static files almost instantly to visitors.
The plugin-powered caching systems or built-in caching systems used for a CMS can be effective in reducing the overhead of database queries, however, a static site will always guarantee the smallest load on a web server.
Version control is another interesting advantage that static sites have over CMS. Changes to your static site can be tracked through source control management programs like Git, which allows more people to collaboratively work on a project, and undo changes when something goes wrong.
A CMS does have some version control element, but some changes might be permanent, and you need to rely on backups — if you’ve taken the precaution to make them! — to restore previous versions.
CMS platforms are a common target for hackers and malicious users. While the WordPress Core is considered secure, installed plugins and themes might have security vulnerabilities in them that can be exploited from simple reflected XSS (Cross Site Scripting) through SQL Injection, all the way to Remote Code Execution. While experienced users may be on top of their game and implement security measures to prevent or ward off such issues, less experienced users may overlook these aspects.
Static sites, however, are a tougher nut to crack since they have little to no server-side functionality. There’s not much code/application where something can go wrong and allow unauthorized access to the website content. Since static sites typically are generated on one machine and then usually served from a different one, so there is not much an attacker can do to the web server serving the static files.
Even if someone did manage to get SSH or FTP access, the damage can be easily remediated to the site itself.
Fewer Server-Related Requirements
By definition, a CMS involves a lot of server-side dependencies. E.g. a typical WordPress installation requires an OS like Ubuntu or CentOS, an Apache or NGINX web server, PHP with necessary extensions and web server configs, MySQL, the WordPress software, and theme codes and plugins. All this need installing, updating and managing.
A static website is less fussy – any web server capable of returning HTML files will do just fine. Plus, you don’t have to bother with installing plugins or taking care of updates.
Better Handling of Traffic Surges
Very little server resources are required to serve static HTML files, which is why sudden traffic surges are not an issue when it comes to static sites. A CMS is more vulnerable in the face of a sudden increase in web traffic, which can lead to a number of issues including database crashes or a restriction of active connections.
With static sites, the whole process is much less intensive, which makes static sites more reliable and better prepared in handling traffic surges.
These were the most important benefits of static site generators, but of course, no system is perfect, so there are a few shortcomings that you should not dismiss.
Disadvantages of SSG:
Real-Time Data is Unavailable
By definition, static sites are unable to have dynamically changing data such as “Trending stories” or “Buyer from X country bought Y product”. If you’re hell bent on having real-time data on your site, static is not for you.
No User Interface
Content management systems like WordPress make it very easy for users to create and publish content from a user-friendly admin UI that can be accessed from any device. The lack of an admin UI is a great disadvantage, but there are a few solutions to get around this issue.
Some platforms like prose.io or CloudCanon feature a WYSIWYG editor for Markdown and a web interface integrated with GitHub, allowing you to create, edit or delete files on a GitHub repository.
In the same vein, there are apps both for Android and iOS that are connected with GitHub and they’re designed to allow the writing and publishing of content on the go, all the while instantly pushing changes to the repository.
A third solution is posting to a static blog by email. The static site generator Jekyll uses this method through its JekyllMail service, which works by logging into the a POP3 account, then extracting messages with a pre-defined “secret”subject line, and saving them in specific directories (e.g. _posts or images directory). There is also the option to add them to your blog’s git repo.
No User-Generated Content
WordPress sites or blogs have user generated sections like comments or reviews. Having a comment system implemented on a static site is a whole different kind of adventure.
As you can see, many of the things you take for granted with a CMS or that can be implemented to a CMS by simply installing a plugin, are not readily possible with a static site, and you’re forced to resort to various workarounds to achieve the same. All these need you to have some developer expertise, otherwise you might struggle with static site generators more than with a CMS.
So, Is a Static Site Generator Good for You?
Static sites are reliable in the face of traffic surges, they don’t present as many security issues as CMSs do, and because they are not resource-intensive, they are speedy.
However, static sites are definitely not for everyone nor do they suit every project. In some cases, they can reduce development times and costs, in other cases, they can be a hassle, especially for someone who doesn’t have the necessary development skills.
Featured Image: Designed by Freepik