Static vs Dynamic Websites

- static, django, blogs
- 25-Dez-2021
During this year I spent a lot of time in testing static websites / blogs vs dynamic ones. In this small blog and other hobby projects I even switched back and forth from static (Svelte, Next.js, Hugo, Gatsby, Saga and even Jekyll) to dynamic (Django). Since the end of the year is approaching I thought it would be nice to write down some thoughts about my experience.
Choosing the right static site generator is the first challenge🧐 Not all static website generators are equal. In the case of the most sophisticated ones like Next.js and Gatsby there are a lot of dynamics options so the line between static and dynamic gets more and more blurry (even more so with Next.js if you use server side). The learning curve isn't uniform. If you use a very simple and basic static site generator you will be severely limited by its functionality. If you use something too complex you end up having to write a lot of custom functions to make it work as you want.
I thought I had found the perfect static generator when I noticed breaking changes in the new release. Another learning curve to manage just to write some posts in my blog...no thanks.
Sometimes the benefits of a static website are overstated🤥 I have been there, seeing the various benefits of a static website like security, portability, speed as making the dynamic ones almost obsolete. But like with many things in IT the devil is in the details. Speed gains are not that obviously, especially if you already using Cloudflare (even the free plan) to cache party of your dynamic website.
Static websites are limited😣 There are a lot of limitations with static websites. For starters, writing an article is a pain unless you use an external CMS which means another subscription + more moving pieces. You want comments in your blog? Forget it unless you use an external service. Ditto for search.
In Django both search and comments are very easy to implement. I don't have any statistic to quote (beside some blog posts that seems to confirm my theory) but I suspect many blogs that migrate from dynamic to static receive the final kiss of death: being harder to update them creates a perfect storm to having another zombie blog or website around.
Frontend should be HTML and CSS: say no to fancy frameworks and DSL🤔 The first time I encountered a DSL (Domain specific language) was in Ruby and let me tell you, it is always a bad idea. Writing code in a language that will then create HTML is always a bad idea. I have found it recently on a Swift static site generator: just to add something in the <HEAD> of your html page you had to write a lot of non-sensical code.
So here is the final test: if you have to write HTML in react, swift, ruby or anything else than plain HTML run. Exception for simple templating languages like Django templates, Mustache and Handlebars (why? this is just HTML with some tags so you don't use the simplicity of power of writing HTML directly).
As a developer you should be able to develop your own site/blog 🥳 There is nothing wrong in having some static websites around e.g. for micro websites that rarely gets any update but a blog, that is dynamic by definition, is an excellent platform to learn and showcase your development skills. Even if is not perfect (think about my claps👏functionality that reloads the whole page in this blog😅) it has some sort of artisanal feel that is very rewarding when you did it yourself.
Monolithic Apps are great😎 One of the latest trend in development is to split everything into microservices, front end/back end etc. but now many developer finally realise that they are not going to run the next instagram or google so all these splits just create a lot of confusion for nothing. Django templates are great for the frontend. The ORM works very well and is fast (yes, also faster than a static website) and the django admin is amazing to keep your website or blog updated.
In conclusion, I am not saying that static websites are not useful. I am still using Next.js in some productions projects with good results but, frankly, the simplicity promised is just a promise. There are a lot of moving pieces and you always need a CRM because working solely on markdown files will kill your productivity.
What I am saying is that in most cases a static blog or website is a pain to update. Another example is a hobby project I run where every article has a lot of images. With a static generator using markdown it is is a mess to maintain. With Django and a few packages I can just drag and drop a bunch of images in the article itself and bang you have them resized, saved and live.
Similarly, I didn't have to fire up my editor + push on git and wait for a build to write this article. In the moment I will click Save it will be live. Just WOW🎉. As the web used to be a few years ago and how it should and can be today.