How to create and deploy a Hugo site? Basic setup of Hugo with Hextra theme on Arch Linux and deployment on Cloudflare Pages

September 1, 2025

This article is for Linux. For Windows or MacOS 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 github-cli

sudo pacman -S github-cli

gh auth login

  • gh auth status to check login status

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/* 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`

Paste the content of .zip file from hextra

git add .

git commit -m "basic setup"

git push origin main

Github edit go.mod: module 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

hugo new content/blog/_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

Edit

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

Push to Github

ls

tree -a

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

tree -a

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