Hugo Site on Cloudflare Pages with Umami
Contents
Contents
TL;DR
- This guide walks you through setting up a fast static website with Hugo, written as the story of how I built mine, from choosing a Hugo template to deploying, explained step by step.
- You’ll register a domain on Namecheap, move DNS to Cloudflare, and deploy through Cloudflare Pages, which builds the site automatically every time you push to GitHub.
- Instead of Google Analytics, the site uses Umami: open-source, privacy-focused, cookie-free, and free, with a small script. I didn’t record Lighthouse scores before or after the switch.
- The only cost is the domain itself (~$10-15/year); everything else is on free tiers.
This post is a historical record of the tools I used to set up my webpage in the form of a story with instructions on how to set things up, so it’s written in a linear way, just as I would tell anyone how I made it!
Note: this describes the setup as of June 2024. Cloudflare Pages, Cloudflare DNS and Umami are still what the site runs on. The rest has changed: the site no longer uses a third-party Hugo theme (the layouts live in the site’s own repository, so the template section below is how I started, not how the site is set up today). The build command is now
hugo --gc --minify, pinned to Hugo 0.162.1. There is no GitHub Actions workflow any more; Cloudflare Pages is the only deploy path. Cloudflare’s dashboard changes often, so treat the click-by-click steps as a sketch and check their Hugo guide before following them.
Introduction
I have been asked by some colleagues and family how I made this webpage, how did I do to make it extremely fast, how am I hosting the page, or how am I tracking the analytics, among other questions. I decided to write a guide to help them and anyone else interested in setting up a static website using Hugo, Cloudflare, and Umami Analytics.
This guide is designed for beginners and intermediate users (you will need at least some coding knowledge) who are looking to create a fast, secure, and easy-to-maintain website without diving deep into complex coding. I will try to make the guide as simple as possible so that anyone can follow it.
By following it, you will learn how to:
- Choose and customize a Hugo template for your site.
- Purchase and manage a domain from Namecheap (or any other registrar).
- Set up Cloudflare DNS for reliable DNS management.
- Deploy your static site using Cloudflare Pages for continuous integration and deployment.
- Integrate Umami for privacy-focused website analytics.
The only cost involved is the domain registration, which is around $10-15 per year - depends on the domain, and renewal prices can be higher than the first-year price. All other tools and services mentioned in this guide have free tiers that were enough for my site; check their current limits.
It works for a personal blog, a portfolio, or a simple business site. If you have any questions, feel free to contact me directly!
Requirements and [why/why not] other tools
We are going to use the following tools to set up a static website:
- Hugo: A static site generator that allows you to create web pages from Markdown files.
- Namecheap: A domain registrar where you can purchase and manage your domain.
- Cloudflare: A cloud-based platform that provides DNS management, CDN services, and more.
- Cloudflare Pages: A platform for deploying static sites with continuous deployment.
- Umami: A simple, privacy-focused analytics tool for tracking website visits.
- GitHub: A version control platform where you can host your Hugo site.
Why Hugo?
When I started to make websites, I saw pages made with Wordpress, Google Sites, and other CMS. I was tempted to use WordPress, but I found it too heavy for my needs and would need to pay a hosting site (this is almost always the case unless you do an on-premise setup, aka. self-hosting the service).
I wanted a fast, secure, and easy-to-maintain website that required some sort of bond with coding. JavaScript, React (Gatsby, Astro, Next.JS, …) and etc. would imply me spending a lot of time learning them properly, which I’m not really interested in, since I come from a backend background.
That’s when I discovered static site generators. I saw Jekyll, but I found that Hugo was better at the time, and I fell in love with it. It is fast, easy to use, and has a lot of themes to choose from.
Hugo has several benefits:
- Ability to create pages from Markdown files. This is very useful because I can write my posts in Markdown and then Hugo will generate the HTML files for me. I can focus on writing and not on the HTML structure of the page (although I can customize it if I want).
- It’s based on Golang which makes it fast and provides some Golang scripting capabilities inside the HTML/CSS/JS files. This is very useful because it lets the developer use for loops, if statements, and other programming constructs inside the files.
- It’s open-source and has a great community. If you have any questions, you can ask in the Hugo forums, and you will usually get an answer.
Why Namecheap?
At first I bought my domain from GoDaddy which was nonuser.es since nonuser.com was already taken. Then I wanted to change my domain to this of now, and bought it with Google Domains. However, Google Domains was taken down not long ago, and I decided to move to Namecheap since the price was good, I had heard good things about it and it’s one of the biggest domain registrars in the world. I’m very happy with the service they provide as of now.
However, you can use any domain registrar you want. The steps will be similar.
Why Cloudflare?
I started using Cloudflare because it provides a free tier that includes DNS management, CDN services, SSL certificates and some analytics (we’ll talk about this in the Why Cloudflare). It also offers a great integration with Cloudflare Pages, which is the platform I use to deploy my static site (I moved in June 2024). It also offers a lot of other services like DDoS protection, firewall, and more. You should check them out!
Why Cloudflare Pages and why Umami?
Sorry to have mixed both products, but I think it’s better to explain them together as in my specific case, the history involves both.
I started using GitHub Pages to deploy my site. Then transitioned to Netlify but I had some problems and decided to go back at GitHub Pages.
GitHub Pages is great, it will provide HTTPS for free and domain support. It also comes with the ability to use GitHub Actions which you can use to deploy your site automatically and add some other features such as checking broken links, checking issues with Google Lighthouse, etc.
Not too long ago I was using GitHub Pages, and my webpage was using Google Analytics. Google Lighthouse flagged the page’s performance (I didn’t keep the scores), so I decided to get rid of Google Analytics. In this process, I found out that I still wanted to have some basic analytics to know how many people were visiting my page, from where, and what was the most looked at content.
I found out that Cloudflare provided some basic analytics in their free tier, and decided that it was a good idea to use them.
The same day, I found that Cloudflare Pages integrates better with other Cloudflare products, and that GitHub Pages didn’t allow to use the Cloudflare Proxy features as seen in this post and this other post. So it was a no brainer to change.
It also provides a free tier that allows you to deploy static sites with continuous deployment so I decided to make the change. It’s easy to set up and use, and it’s very fast. You don’t need to worry about the infrastructure nor creating any CI task, you just need to push your code to GitHub and Cloudflare will take care of the rest.
Going back to the analytics… after a while, I was seeing crazy numbers (like you can see in the image below) that weren’t real visitors but maybe bots, crawlers and what not.

So I decided to take a look back at JS scripted analytics that were privacy-focused, easy to use, fast, and that I could host myself or were free at least.
I researched a bit and saw many possibilities: Plausible, Fathom, Heap, HotJar, MixPanel, Woopra, Simple Analytics, Umami, Clicky, Open Web Analytics and Matomo. As you can see, there are lots of them. I thought of hosting Matomo in my Intel NUC server but a Reddit post changed my mind because some Matomo users changed to Umami and decided to go with the flock of sheep.
Umami is really good because it’s open-source, privacy-focused, easy to use, and most important… FREE.
The others are good tools too. What decided it for me was a short list: open source, privacy-focused (no cookies), a free tier that covers a personal site, and a small script. Umami ticked all four. If you need heatmaps or session recordings, it’s the wrong tool, and you should look at the heavier options above.
Any way, this is just my experience, in case you prefer to deploy the site in another page, you can check more about how to do it in the Hugo documentation.
Choosing and setting up your Hugo template
I initially built my website using the Cupper template and later transitioned to the Color Your World template from Hugo. Over the years, I’ve made various aesthetic changes to the site.
- Select a Hugo template. Start by choosing a Hugo template that suits your needs. You can find many free templates in the Hugo themes directory. There are a lot of them, it just depends on what you are trying to build.
- Install Hugo. Follow the official Hugo installation guide to set up Hugo on your local machine.
- Create a new site. Use Hugo commands to create a new site and apply your chosen template, or follow the instructions that will probably be in the template (most likely). Detailed instructions are available in the Hugo documentation.
- Customize your site. Modify the template files, content, and configuration to personalize your site. Hugo uses Markdown files to generate pages, making it easy to add and update content on the fly.
As a reference, when I want to see how my page looks as I’m editing it, and be able to see the changes in real-time from my PC or my phone, I use the following command:
hugo server --minify --bind 192.168.1.18 --baseURL http://192.168.1.18:1313
In Linux you could use this too, makes life easier:
IP=$(hostname -I | awk '{print $1}') # first non-loopback IPv4 address
hugo server --minify --bind $IP --baseURL http://$IP:1313
You could even make an alias in your .bashrc or .zshrc file to make it easier to run the command.
For more Hugo CLI commands, check the Hugo CLI documentation.
Registering your domain with Namecheap
Although I use Namecheap, you can choose any domain registrar that you prefer. The steps will be similar.
- Purchase a domain. Go to Namecheap and register your desired domain.
- Manage DNS settings. In your Namecheap account, navigate to the domain list and select the domain you want to manage. Set the DNS to point to Cloudflare’s nameservers. Go to the next section for more details on this step.

Setting up Cloudflare DNS
Cloudflare’s DNS management is solid, and it connects to Cloudflare Pages directly.
- Add the site to Cloudflare. Sign up for a Cloudflare account and add your domain.
- Update the nameservers. Follow the instructions to update your domain’s nameservers to those provided by Cloudflare. It’s very straightforward, you just need to copy the nameservers from Cloudflare and paste them in the Namecheap dashboard.
- Configure the DNS records. In the Cloudflare dashboard, configure your DNS records to point to your website’s hosting setup. It will probably take almost all DNS records from Namecheap, but be sure to check them because if one is missing, your site could not work properly. This is, because this migration deletes the DNS routes from Namecheap and creates them in Cloudflare. Look at the references for more information.
References:
- Cloudflare guide on how to change your nameservers
- Namecheap documentation on how to set the DNS records for Cloudflare.
Deploying with Cloudflare pages
- Create a Cloudflare Pages project. In the Cloudflare dashboard, navigate to the Workers & Pages section and create a new project. Connect it to your GitHub repository where your Hugo site is hosted.
- Build settings. Configure the build settings for Hugo.
- Typically, this involves setting the build command to
hugo --gc --minify -b YOUR_DOMAIN- If you were to use CloudFlare domain, it would be
hugo --gc --minify -b $CF_PAGES_URL - In my case it would be
hugo --gc --minify -b https://pablogonzalez.me/
- If you were to use CloudFlare domain, it would be
- And specifying the output directory as
public.
- Typically, this involves setting the build command to
- Set environment variables. As Hugo evolves, I like to set the
HUGO_VERSIONenvironment variable to the version I’m using. This ensures that the build process uses the correct Hugo version. Check the releases page on the Hugo GitHub repository to find the latest version. Be sure that your website works with the latest version before updating it.
Integrating Umami for analytics
Umami is a simple, privacy-focused analytics tool that integrates well with static sites.
Did you know Umami is a Japanese word that means “pleasant savory taste”?
- Create an Umami account and follow the steps to set up analytics for your website. They are pretty straightforward and involve adding a tracking code to your site.
- Set up Umami. Follow the Umami steps when adding your website (hosted version). Or you could self-host it, in which case you would need to follow the Umami install guide
- Add the tracking code. Insert the Umami tracking code into your Hugo template. This is usually done in the
headsection of your HTML files.
This is an example of one:
<!-- Umami Analytics -->
<script defer src="https://cloud.umami.is/script.js" data-website-id="some-hash-here-hehe"></script>
<!-- End Umami Analytics -->
Conclusion
Setting up a static website with Hugo, Cloudflare and Umami is a simple process, and at the end of it the page is yours.
This is a high-level overview, so check the official documentation for each tool for detailed, up-to-date instructions.
Feel free to reach out if you have any questions, and I mean it! If there’s any doubt, I’ll make sure to update this post with the answer so that it can help others in the future.
Happy building!