My boring Blog

Mauro Frigerio blog

Back to the Future? Or to the past?

05-06-2020 4 min read Article

I’m not much of a site developer and I have no problem admitting that. I just like having a space where I can “crawl” and share what I do.

A website doesn’t create itself and when you get down to it, the problems increase exponentially. You can create it based on freely available platforms (where of course you are the product because they have to make money) like WordPress, Blogger and many others.

My first site I programmed with Microsoft’s Front Page (around 2001), I was young and didn’t understand anything about computer science yet. Site design at the time was very monolithic and static. When you wanted to do something more dynamic then it was Flash.

A few years later in 2008 I decided to buy the current domain and create my own site. The choice was between WordPress, Drupal or Joomla. After several attempts I decided to go with Joomla because it integrated better what I needed: a blog, a photo gallery and video hosting. It’s been 12 years now and many updates and some template changes have been necessary. During this time I have understood more and more what it means to manage a site and everything that goes around it (space, database, versions, …).

At the beginning of the crisis due to the corona virus I promised myself to update with content but also graphically and under the hood of my site, which had stopped for quite a while. A bit by chance I came across a tweet from Infomaniak (my hosting) that talked about Hugo. They talk about an automated system for uploading a website via GitHub.

Since I’m a closet lover I decided to dig a little deeper, but what is Hugo really? In simple terms it’s a static site generator. It all makes sense, doesn’t it? A lot of sites these days are dynamically generated, but that doesn’t help you understand the difference. So let’s try an example. A computer requests a page of a site (example https://frigi.ch/example) from a server. The server asks the database for all information related to the requested page. After receiving the information a page in html is created containing the information, to which the graphic style of the site is added. When all this is ready it will be sent to the computer that made the request. A static site instead doesn’t have a database and doesn’t have to create pages at every request. All pages are generated beforehand according to the configuration.

It doesn’t take a computer scientist to understand that static sites are significantly faster than others. But not only that, they are also safer because they have a smaller attack surface because you only need an html server and that’s it. This kind of framework is useful for simple sites (like mine) that present data that doesn’t change. It is not suitable for a site that deals with trading or live data.

It’s also not suitable for everyone because some minor computer science knowledge helps with configuration and management. Even if the examples and notions required are not from a master in computer science. The system of static pages makes me think of the early days of the internet and my first site. It seems like a step backwards, but it’s not. Because today’s systems have more power because of the flexibility in creating content and for a static site this may seem like nonsense.

Quickly install hugo on your computer with the command snap install hugo. In the development folder of your site type the command to create the site: hugo new site name. You can add a theme from among the many available and immediately you can test your new site on your computer. Running the command hugo server -D will compile your site and make it available locally at http://localhost:1313. The power of this system lies in instant compilation. Edit a document and save it, in a few milliseconds the changes are ready and you can test them with your browser. No more wasting hours setting up a test system locally or remotely and all the time spent moving files from where you develop to the test system.

In no time I was able to set up my site with Hugo and migrated old posts from Joomla. It took me a little longer to properly configure GitHub. Especially the aspect for compiling and automatically loading changes when saving new posts. If you want to create something simple and your hosting doesn’t offer as much, this is a great alternative. Give it a try!