Why I chose a static site generator to serve content for this blog
Contents
In this first post I’m explaining why I chose a static site generator instead of a Content Management System (CMS) like the well known Wordpress which has a marketshare of 65% at the at time of writing.
There are many advantages of using a static site generator. The most significant of them are:
- Security
- Performance
- Maintenance
- Manageability
- Scale
Security
The web pages are rendered in advance instead of on the spot when a visitor is browsing a website. Since they are rendered in advance there are very few vectors for a malicious attack. There is no data
Performance
Because the site is fully generated is each page ready to serve without compiling a response for each request on demand. Webpages will load slightly faster in the users browsers.
The times to build the static assets is milliseconds.
Maintenance
There is no need for security updates, so you don’t have to deal with pop-ups reminding you to update your CMS and plugins. You don’t manage a database or backend which you have to worry about for security and reliability.
Manageability
With a static site generator you manage your content as code. The content it written in markdown (.md files) and are being generated to static pages.
I don’t like the idea of imprisoning work in the walled garden of tech giants. Markdown is a universal format and works with hundreds to thousands of different tools to make anything you want. You can convert it to .pdf or easily migrate your content to another static site generator.
Scale
Because the site is fully generated is each page ready to serve without compiling a response for each request on demand.
Challenges
One of the first challenges that I faced was how interact with visitors let them interact with eachother without a build in comment function like a traditional CMS. Comments are dynamic by nature. By using a third party integration on this static website I’m kind of switching to a hybrid approach.
Integrating a privacy friendly analytics
I use a privacy-focused web analytics service that respects your privacy to gather statistics on how populair various pages are and how people get to the site. I looked into Plausible but found articles how they use tricks to bypass ad-blockers. I had a few criteria listed below. I opted for a SaaS solution instead of self-hosted but looked for a service that also offers their product as a self-hosted option. I don’t trust a company’s service if you can’t even host it yourself.
- Less than 10Є/month
- Ignores localhost browser visists for when I’m working on the Hugo code
- Respects the Do Not Track header and can be blocked with ad-blockers
- Easy to integrate with Hugo
- Multiple ways of tracking
GoatCounter is a easy to integrate and open-source web analytics platform. It aims to be a privacy-friendly web analytics as an alternative to Google Analytics or Matomo. Till my surpise they offer multiple integration option including parsing log files.
Components :)
- hugo - A popular open-source static site generator written in the Go programming language. Hugo is distributed as a single cross-platform binary. The sites can be hosted anywhere - self hosted or at a global content delivery network (CDN)
- Disqus - A third party commenting system which is built-in feature of the static site generator and theme that I used to build this site.
- CDN - A Content Delivery Network (CDN), for faster image delivery. The purpose of using the CDN is to optimise loading times for international visitors and reduce load on the webserver. plausible-hugo https://github.com/divinerites/plausible-hugo
Author Thomas Brinkman
LastMod 2021-11-28