What are Static Site Generators?
I thought everything was supposed to be “dynamic” to get with the times? Never Fear! Static Site Generators are here!
Dynamic. Dynamic Duo. Dynamics. Weren’t we taught that dynamic is the way to go? That static things are no longer as progressive and robust to keep up with the changing technologies? Well. Yes, you are correct. In most cases, dynamically driven content and technologies are typically the better bet and pathway to go, but that doesn’t mean that “static” has been made obsolete. Static Site Generators have become more and more popular recently, and it’s an option that I am considering for this site as well! Of course, I’ll have to look into Bluehost (which this is hosted from) and see how it will work and whether or not it would be well optimized. As someone in IT, it’s a little embarrassing for me to be writing this blog through a WordPress template and builder, especially when I have designed and currently host custom pages of my work. It’s a bad excuse, but the reason is time, I simply don’t have the time to design and write a page and worry about the formatting every single time, sure I could easily use a Bootstrap template, or just build my own template, but I am a coder, not necessarily a designer. I can be a web programmer and developer, but not the best web designer. Give me your code, and I can find troubleshoot it easily for you as well as provide some design element tips, but ask me to design one myself, and I’ll go with the typically two column and sidebar, always.
Just like any full stack scripting language, it’s important to pick a language to work with as well. Since I have been and plan to continue working in data science and analysis, I decided why not just continue working with python? For those of you, who are unfamiliar with python, here is a terrific article by Hoyt Koepke from UW about Python.
Inspired by: Static Site Generators Source
For the scenario, let’s imagine a news kiosk. So think of these kiosks around where the user can just walk up to it and request to read the latest news. Now there is a difference behind the mechanism in retrieving the news between a dynamic and static site. In a dynamic kiosk, when the user requests for the latest it will then query a database of news sites that it has uploaded into the system and pulls all of the newest stories since it last did it. By pulling and “select starring” (assuming you have setup the function to allow new posts to be automatically pulled and stored as an entry), you are then able to quickly compile together a report into the template/format of the kiosk and present the information. As such, every time someone arrives at the kiosk and updates for the newest information it will continue to perform that process. So the kiosk will query for the latest content through a service side script against the news databases to get the content. The queried content is then passed to the templating/reporting engine to generate the new HTML file for the user to read through.
On the other hand, with a static site generator, it shifts the heavy processing load from the moment the site is visited and requested content in the background, it will request content the moment the content actually changes! So returning back to the news content kiosk, the situation is flipped essentially. Instead of the kiosk querying the news agencies’ database for the latest content, the news agencies will simply send the newest content to the kiosk whenever something happens, though the kiosk will still have to run though a templating/reporting engine to compile, format, and style the stories, even if it hasn’t been requested yet. As a result, it will be waiting to be requested until another event happens that pushes up to the kiosk and then a slight change is made.
Another example would requesting of minutes, say if someone missed an important meeting and wanted to read the minutes. A dynamic minutes would require him to meet with the secretary and have the secretary find the minutes and print it up for the employee. A static minutes would essentially have it all printed out after the meeting had concluded, ready to hand out to those that want it.
Why Use It?
I feel like I was pretty explicit and clear in explaining why static site generators can be so useful. Of course, it can’t be used in every case, but for the situations that they do work in, by heck do they work in it well!
However, there are some things that I do want to point out if you are also trying to decide as well!
- Version Control. Similar to what GitHub does, it provides superior version control because there is a middle man repository/generator that can help catch errors and rollback changes, without it affecting production because it never even made it there first off! Depending on the framework and generator that you use, your HTML/plaintext content could actually just be sitting in a github repository, so there is capability for users to submit an issue or add a correction with pull requests!
- Speed. As I mentioned, instead of a huge processing load at the time of request. It continues to update whenever new content is published, so essentially the workload is on the server. Although database queries are fast, nothing beats no queries! Perhaps saying templating earlier when I described static pages wasn’t the best way since static pages are basically pulling through text files and throwing it through a static page generator to be hosted on the web server.
- Security. Currently I am hosting through Bluehost and use WordPress. Even if you just typed into google “WordPress Vulnerability” you’ll probably find new vulnerabilities every few weeks, which is how so many exploit kits, botnets, and malware are spread around. Being so prevalent, it’s a common target for comment sections and anywhere else there can be input or authentication requests. As a result, administrators constantly need to patch with security updates. With static pages, unless you specifically set up a comment mechanism, there are no places to be attacked since it’s serving a plain HTML page.
- Simplicity. At first, when I was doing my own blog I wanted to find a cheap and simple option for myself, (since it was my own money hehe) so installing and maintaining and infrastructure to maintain a site, was a daunting task. Especially since I didn’t, nor do I really understand much on how to connect and relate databases for content like WordPress does so beautifully. Sure, I wouldn’t even need a database, and could just host with normal .html files on basic content, but for blog posts that would have been difficult, always having to change the HTML to link another post and what not. Because it uses a site generator, I don’t think you even need to run it through a web server, just push it through straight from a personal computer.
Disadvantages (Not to me though)