Why a static site generator in python?

Posted by Flavius Cojocariu on 22.06.2020

Hello, there!

I will like to share some of my thoughts in why I decided to create a static site generator as my foundation for my new website.

As a side note, I am not so good in writing text and it could be that I will over do it, but please bear with me.

What is a static website?

First of all what is a static website? A static website contains pages with fixed content.

A static site is a webpage that is delivered exactly how it is stored, with nothing changing dynamically by a web application. Static webpages do not require any use of a database for getting the content inside them.

Some advantages of using static webpages:

  • more secure than a dynamic webpage, which communicates with a web server language;
  • more performant for the end user than a dynamic generated webpage;
  • fewer or no dependencies on systems such as databases or other application servers;

Why a static website as a personal website?

For several years I had a simple html page as my online presence, with barely no functionality at all. By functionality I mean, nothing else then a v-card.

For some time I was looking for a way to keep my self easy focused and interested while having an ongoing project, which is simple in the beginning, but can become complex in the end.

Myself I was not such a fan of a traditional CMS, but also hatted to have to do everything manually. With seeing the growth in the dev community around static site generators, I was thinking that this could actually be a good idea for me start learning something new and in the same time to be challenging enough.

In the end having a static website as a personal website is not a bad idea, even though you don't create your own generator. It can help you deliver much faster the content to you audience and help you keep everything clean and easy to maintain.

What is actually behind a static generator?

A static website generator take your content, puts into the layout/template and generates a HTML file. For example for my website I am using a python script which takes the content from a markdown file, puts it in the correct template and then generates a file HTML file with the content inside it. Actually you don't really need a fancy generator, or a generator at all, if all you need is just having a small page with a fix content which might not change at all. But using a generator makes it a lot easier to change the content of the page, without messing around with all the HTML tags and trying to search and find the correct place where you need to change the text.

This is all a static generator does in the end, fetching the right content for the right template and generate a complete HTML page. Of course fancy generator do much more behind the scene, but the purpose of this post and the ones that are following is not this. This articles and the ones that will follow on this subject is just to train your mind and skills in coding something which is fun, yet not simply, but also not so complex in the beginning.

Why everything in python?

For me learning python for real, was always a big challenge. I have heard and learned it a bit in the University, where I study it a bit for some labs, but nothing serious.

In the town where I studied there were not so many jobs advertising python development in the web development world, and also that was a period where most of the companies there were looking for php/java/c/c++ developers. Actually in my career I never had to do anything serious in python, beside automating some tasks I was doing manually or just for fun.

I have some tryouts to learn python, but I never stuck to much into the topic. I don't know why. Suddenly at work, a colleague of mine introduced for the marketing department HUGO, for building smooth, fast landing pages. When I heard about this I was thinking what it will take to actually build a small, simple static site generator by my own. As I primarily work as a nodejs dev, this was my first choice of weapon: Nodejs and EJS as template engine.

By doing some research on the topic, with the help of o'l friend George, I stumble upon the idea of doing it in python as it could be really the opportunity I was looking for to finally learn the language syntax and concepts. So yeah this was my motivation of doing it in python.

Until next time I wish you:
Enjoy life and always be curios.