Static vs Dynamic Websites in 2022 🚀
Sunntig,09 Januar, 2022

I have to admit that I have been stuggling a back and forth between static and dynamic blogging in the whole 2021😁. Just before Christmas I even moved this blog back to Django as I was charmed by the added flexibility of a dynamic site.

Search can be done directly in the database, you have a nice web interface to add articles. In my quest for finding comfort in my choice I also stumbled upon an article where the author of a static generator moved back to dynamic.

The arguments are pretty logical so I was persuaded by the logic. Are static blog really less likely to get updated than dynamic ones? Are the benefits of static websites really overstated?

Just today I wanted to make a simple change to another blog writted by myself in Django. It was a very simple change to the model: I added a field published but the migration failed with the strange error:

 django.db.utils.IntegrityError: (1062, Duplicate entry '0' for key 'PRIMARY')

Like why? I am not even touching the primary key. I altered the model with a new column..
After spending 1 hour or so googling + stackoverflowing I managed to remove some of the migrations but then I got another error:

 django.db.utils.OperationalError: (1091, "Can't DROP COLUMN ``; check that it exists")

like really 🧐? So, as I do believe everything happens for a reason I realised that it was time to switch back to my amazing static version, powered by Saga and Vercel. So my failures and trials are to your advantage. If you are thinking to launch a static website or blog in 2022 🚀 just do it. It will work faster, better, it will be more secure and it won’t stand between your enthusiasm to update it as often as you can.

A quick list of of disadvantages in dynamic websites:

  1. The time you would theoretically save in using a web based editor vs a coding editor will easily evaporate whenever you have a problem e.g. fixing a package or changing the database.
  2. Deployment will not be a straightforward. Once you settle and choose the static generator all you have to do is fire your editor and push to the git repository. Not so much if you manage your own dynamic solution as you will need to fetch code changes from git, sometimes restart the web server etc. If you use a hosted solution you will also be subject to the same issues, just sometimes will have to do it for you.
  3. Security and updates will consume a lot of your time. Once again, if you go for an hosting solution this is normally not an issue when everything works as planned. When it doesn’t….
  4. Your site will most likely be slower. Nothing beats static over a cloud deployment with access points around the world. Just nothing.

So with static you get:

  1. Higher security: all your pages are just in plain HTML so there is not much to find that is not public on your pages :)
  2. Higher Speed: There are a lot of free or cheap solutions around. See my previous comparison of the various services here
  3. Roll back to any previous version with just 1 click. You can’t do that in a dynamic site. Just you can’t just go to a previous version with a different design or content with a click. Sometimes is never possible to go back once the article is deleted from the db you would need to restore a backup, if you have one
  4. More modern way to develop. You understand how the “pieces” of your website, mostly HTML, CSS and JS are glued together. So in essence you learn more.

In conclusion, I recommend static solutions vs dynamic ones especially for blogs and unless your site requires dynamic functionality (clearly not every site can be static 😁).

Happy development in 2022 🚀!