Hugo on a recent project and absolutely loved the ease of use and the option to create pages and articles using Markdown instead of HTML. It keeps gaining in popularity, and it is extremely efficient.
It took me 2 hours to migrate my small website to Hugo. Here are the steps I followed on my OVH server:
hugo new site dev
in my webroot to generate the proper folders needed for my new websiteA couple hugo
commands later, my website was running perfectly! After checking that all my links were working fine, I decided to delete my WordPress install and copy the Hugo folders to the root of the website. Because there are no databases, redirections, or URL rewriting rules, this process took two minutes and was extremely easy.
Here are the results!
Switching to a static website was the perfect opportunity to try Cloud Workers. Instead of having my own server, I would publish my website to a service able to replicate my tiny website to multiple servers around the world and serve this website when needed.
Not having a dedicated or virtual server comes with a lot of advantages.
After hours of research, I settled on Cloudflare. I was already familiar with the functionalities offered (for free!) when you subscribe to the service (A free SSL certificate, relatively good SSL configuration options, HTTP/2, HTTP/3, etc). The main reason that made me choose their service is that they have a team of passionate people dedicated to making new technologies available as soon as they are available. They were one of the first companies to offer TLS1.3 back in 2016. They were also one of the first companies to make HTTP/3 available to all their customers in September 2019. It is really important to me because I know that even if I don’t have a VPS to compile a new version of Nginx/OpenSSL to play with new tech on my website, their service will still allow me to enjoy it.
The whole process of creating a worker and publishing a website took me one hour:
wrangler login
to create the API key and link Wrangler to my Cloudflare worker.wrangler generate my-worker
generated the files necessary for my websitewrangler publish
This process took 10 minutes, but I spent much more time trying to figure out why my website wasn’t accessible after publishing (SSL protocol error). As it turns out, creating a route from the domain name to the Cloudflare Worker does not automatically adjust the DNS zone. I ended up finding a forum post indicating that users are supposed to create a DNS entry with an IP in a certain range. The recommended address was 192.2.0.1.
I also had to create a Page Rule to redirect the non-www traffic to florianschmitt.tech
After these adjustments, my website was accessible and ready to benchmark… Hold on to your hats!
Wow, that is fast! I knew I would gain a little by switching to a static website on a Worker, but I never imagined it would be 50%! When analyzing the connection steps via GTMetrix, I realized that the SSL connection times were much smaller than on my VPS. This is logical because of the use of both edge computing, and because the DNS zone and the Worker are both managed by Cloudflare, at the same location, with probably a lot of optimization! The SSL connection that took 130ms in the past now takes only 17.7ms!
The switch to serverless brought a long list of improvements:
Before | After | Difference | |
---|---|---|---|
Homepage size | 3.03KB | 2.24KB | -26.1% |
Homepage fully loaded time (GTMetrix) | 351ms | 160ms | -54.4% |
Homepage network load time (GTMetrix) | 273ms | 59ms | -78.4% |
Number of files used by the website | 6244 | 79 | -98.7% |
Disk space used by the website | 190MB | 380KB | -99.8% |
Total disk space dedicated to run the website* (Includes OS and software) | 3.1GB | 380KB | -99.9% |
* “After” not taking into account the disk space used by the Worker’s software, shared between all users.
While the whole process was extremely fast and easy, it is far from being accessible to junior devs and enthusiasts who’d like to easily set up a static website. I would love to see Cloudflare offering a “mini-websites” service similar to workers, but easier to use. I think way more people would be inclined to develop small static websites if they could upload their files directly in their Cloudflare dashboard without the use of an API or command-line functions.
In the meantime, Hugo + Workers seem to be the perfect solution for devs wishing to reduce their static website’s environmental footprint and drastically improve page load times. It was a pleasure to write this article entirely in Markdown, and I cannot wait to keep improving my website with the tools Hugo offers.
This article is not sponsored by anyone. Used in this article: GTMetrix, Hugo, Cloudflare Workers, Qualys SSL Labs
← Back to the list of blog posts