How to create and deploy a website? Setting up a Hugo project with Hextra theme hosted on Cloudflare Pages

November 1, 2025

This article is for Linux. For Windows, MacOS or other Linux distros check out my other articles.

Here I use Arch Linux btw. For other Linux distros, the way to install packages is different. Check out the installation guide for Linux on the official Hugo website. https://gohugo.io/installation/linux

Install git

sudo pacman -S git

git config --global init.defaultBranch main

git config --global user.name "your-user-name"

git config --global user.email "your-email"

Install go

sudo pacman -S go

Install seahorse (aka “Passwords and Keys”)

Recommended to install to avoid storing github-cli credentails as plaintext. The combination of Seahorse and gnome-keying works best on Gnome. It can also work well on other desktop environment or window manager but may require more steps.

sudo pacman -S seahorse

Open “Passwords and Keys” -> If there is no keyring then logout and login to see a “Login” keyring show up -> Right click and set as default

Install github-cli

sudo pacman -S github-cli

gh auth login

github.com https

Install hugo

sudo pacman -S hugo

Github create repository: hugo--1

Create a new repository on Github: hugo--1 (public or private)

Create a new Hugo site

cd ~/workspace/github.com/your-user-name

git clone https://github.com/your-user-name/hugo--1

cd hugo--1

hugo new site hugo--1 --format=yaml

mv hugo--1/* ./

rm -rf hugo--1

hugo mod init github.com/your-user-name/hugo--1

Github create repository: __fork__hextra--1

Create a new repository on Github: __fork__hextra--1 (public)

cd ~/workspace/github.com/your-user-name

git clone https://github.com/your-user-name/__fork__hextra--1`

Copy and paste the content of the .zip file from Hextra releases https://github.com/imfing/hextra/releases excluding the dotfiles

git add .

git commit -m "basic setup"

git push origin main

Edit go.mod on Github https://github.com/your-user-name/__fork__hextra--1

  • [delete] module github.com/imfing/hextra
  • [add] module github.com/your-user-name/__fork__hextra--1

Add Hextra theme to the Hugo site

cd ~/workspace/github.com/your-user-name/hugo--1

hugo mod get github.com/your-user-name/__fork__hextra--1

nano hugo.yaml or use VSCode to edit

Add

module:
  imports:
    - path: github.com/your-user-name/__fork__hextra--1

Add content

hugo new content/_index.md

Check site render

hugo server -D --disableFastRender

Ctrl C to stop the server

Edit hugo.yaml

nano hugo.yaml or use VSCode to edit

baseURL: https://www.your-domain-name.com
languageCode: zh-TW
title: your-website-name

https://simplelocalize.io/data/locale-code/zh-TW

https://developers.google.com/workspace/admin/directory/v1/languages

Push to Github

ls

touch archetypes/.gitkeep assets/.gitkeep content/.gitkeep data/.gitkeep i18n/.gitkeep layouts/.gitkeep public/.gitkeep static/.gitkeep themes/.gitkeep

git add .

git commit -m "basic setup"

git push origin main

Deploy to Cloudflare Pages

Pages

ConfigurationValue
Production branchmain
Build commandhugo --gc --minify
Build directorypublic

Environment variables (advanced): HUGO_VERSION: 0.0.0

https://developers.cloudflare.com/pages/framework-guides/deploy-a-hugo-site