Blog by Daniel Hauck. Sysadmin, Developer, Blogger.

You wanted to start a blog and researched how to do it? Then you probably came across some content management systems like WordPress, Drupal or typo3. But I bet you also saw something called static site generators with titles like Pelican, Jekyll or octopus. In this article, I want to help you decide, what could be right for you and take a look at advantages and disadvantages.

 

What’s the Difference?

Let’s begin with the classical CMS. I will ignore advanced topics like cache proxies, CDNs and so on, to make understandable for everyone. Plus I won’t write “in most cases” at every point, of course, there can be differences according to the system.

A CMS (content management system) is used to manage content as the name says. You probably have a web interface or a desktop application where you create articles, pages and media files. The key point is the neutral saving of content. You start writing your story, put in photos, videos, whatever and hit save. Everything is stored in some Database Management System like MySQL or PostgreSQL. Except for media files, they are usually stored in the filesystem and a reference to the file is saved to the database. Nothing is generated until a browser requests your article, your photo, or whatever. It’s rendered on request. Additionally, a setup like this needs some kind of runtime, like PHP, Python or Ruby plus a webserver like nginx or apache to handle the request and deliver the content.

A Static Site Generator does most of the things in a different way. They have no database, no web interface, and no media library. You write some kind of Markup Language like RST or Markdown, sometimes even plain HTML. To publish your content you usually fire up some command line tool, that generates HTML files + style information in a directory structure. This directory you would upload to your web hosting or to something like GitHub pages.

I will compare the following points:

  1. Setup
  2. Configuration
  3. Content Management
  4. Security
  5. Performance

Setup

To install a CMS you need a webserver with a runtime, a database, and some storage space. You can get this either by setting it up you own on a VPS with some Linux distribution or just getting a hosting package. If you are choosing the second option, you probably have a one click installer, where you just choose WordPress, fill out some parameters like blog title and email address and you are ready to go. So very easy. If you choose the first option it’s a little bit harder. You need to install for example the typical LAMP stack (Linux, Apache, PHP, MySQL), download the CMS and configure it yourself. Doing so, please consider you are also responsible for securing the system against attacks. If this seems to hard for you or you just have no idea about tech stuff, get a hosting package. They are really cheap today.

To set up a static site generator, you need some technical knowledge to even start. Most static site generators are command line tools. In most cases you can install them with a package manager from the language it’s written in. For example, pelican is written in python, so you would use pip. After installing the command line tool, you usually type in some create or start command and answer a few questions like blog title, permalink structure and so on. Afterward, you would write your articles with your editor of choice and render them to static HTML and get a directory called for example output/. If you open up this directory in your Browser, you can already see your blog as it would appear online. When you decide it’s good and wants to publish it, you need some storage space for your blog, but without any runtime only an HTTP server, which is able to deliver static content. Popular choices would be GitHub Pages or Amazon S3. You can also host the content on an own VPS.

Configuration

Remember the backend from above? Yes, here you can also manage almost every setting of your CMS. Some stuff is still hidden in configuration files, but as an average user, you don’t have to deal with them. You can change the look and feel of your site, change the content structure install plugins and a lot more. All via mouse clicks.

Somewhere in the directory, we are talking about all the time, you can locate a settings file. It could be a .yml or a .ini file for example. Here you can change the blogs name, the content structure, register extensions or change the theme. In some cases, you can also use the command line tool to change settings, and it will write the settings file for you.

Content Management

Using a CMS you typically have a quite user-friendly backend where you log in with username and password. In the so-called backend, you can create or edit content and just hit publish when it’s ready. In these days you can simply add images or other media files via drag and drop, control the position, adjust the size and more. You can easily give tags, categories and change the URL. If you are ready to publish an article, hit publish, if not hit save draft. The same applies for pages.

Like mentioned in setup and configuration everything is organized in a directory. For managing your content, you should find one called content, or for example just pages and posts. It’s different in every static site generator ;). So, let’s assume you want to create a new article. The first thing you would do is create a file and give it a meaningful name like 20170411_awesome_post.md, where .md is the file extension and tells your editor it’s markdown. Another popular choice is .rst which stands for reStructuredText. After creating the file, you need to create a header that holds all necessary information. Here is an example:

As you can see, now fields to choose from, no ticking for the category. You have to provide all the meta information in the header. You have to take care yourself about not messing up with misspelled tags or categories.

Adding media like images or audio depends on your text editor. If you use something like Byword or Ulysses on Mac, you can drop your files in there, and they will handle it automatically and create the necessary markup. When using something like Vim, Atom or Emacs you have to write out the image tags on your own or create shortcuts for this. When you are done writing, render your content, check if it looks nice and publish it to your webspace.

Security

The world isn’t all sunshine and rainbows. That is why we need to talk about security. You are responsible for the content of your website.

A CMS has a lot of moving parts compared to a static HTML page. Like mentioned earlier, if you run it yourself, you need to take care about securing all these parts. You need to secure SSH, the database, and the backend. You need to be prepared attacks like (d)dos or brute force attacks. You can give away some part of the responsibility to a hosting service. But you still have to check your backend login is secure and you don’t use easy to guess passwords.

Fewer parts mean fewer security concerns? In general, yes. It’s static HTML content, so you have no database, no backend to manipulate content. But you also need to make sure; nobody has access to your content repository on your machine or at GitHub for example. So don’t use simple passwords. And of course, you have to be prepared for attacks like DDoS which could harm your server.

Performance

The average web user is willing to wait about 4 seconds for a web page to load. Otherwise, the chance is high he is gone forever. So performance is crucial.

The CMS waits for a user requesting the website, gathers all the information from the database and builds the site and displays it in a browser. I will totally ignore caching here, let’s keep it simple ;). The more plugins and fancy things you put into your CMS, longer it will take to display the content.

In reverse, the static site generator has done all the work in advance. After writing the article, you have rendered it to static HTML. The webserver gets the request and just needs to deliver the file. Simple as that.

Conclusion

Both have advantages and disadvantages.

Without caching techniques nothing beats static HTML pages, but you pay the price of a user-friendly web interface. In reverse when you type a category wrong in a markdown file, a static site generator would treat it as a new category, WordPress just offers you existing categories to choose from.

They both have their use cases. But to use a static site generator without freaking out, you need some technical knowledge. For techies it’s pretty straight forward since we know markdown, we are aware how to version our content and we know stuff like GitHub anyway.

But if you don’t belong to this group and don’t want to learn a lot of new things just to write a blog, I would suggest you do research for a good hosting provider and get yourself a WordPress blog for a few dollars a month. You can spend your time better by producing content instead of tinkering with tools, that won’t be useful to you in your daily job.

What do you think? Or better, what do you prefer? Editing in a web interface, or side by side in a code editor? For writing tutorials, it’s great to use a tmux session and have the code side by side with the article.


Comments
Harvey Specter
Posted at 3:00 pm July 28, 2017
Lukas Christensen
Reply
Author

I would like to have a static site generator with CMS that gives the user a friendly interface – with media library capabilities.
Does it exist?

Harvey Specter
Posted at 7:38 am July 31, 2017
Daniel
Reply
Author

There are crappy solutions for this, which you shouldn’t use.

Instead use a classical CMS and obey a cache service like varnish.

Leave a Reply