Getting Started with Hugo
On this page
Hugo is one of the fastest static site generators in the world. It is written in Go, builds an entire site in milliseconds, and uses Markdown as its native content format.
Why Hugo?
- Fast builds — even hundreds of pages compile in under a second.
- Markdown native — content stays portable forever.
- Multilingual built-in — perfect for a bilingual site like this one.
- No database, no runtime server — the output is pure static HTML, ideal for Cloudflare Pages.
Install Hugo
On macOS you can install Hugo Extended via Homebrew:
brew install hugo
hugo versionCreate a new site
hugo new site jeiii-codes
cd jeiii-codes
hugo serverOpen http://localhost:1313 to preview your site locally.
Write your first post
hugo new content posts/my-first-post.en.mdThen edit the Markdown file, set draft: false, and save — Hugo will reload automatically.
Build for production
hugo --minifyThe generated site lives in the public/ directory, ready to be deployed to Cloudflare Pages.
Deploy to Cloudflare Pages
Cloudflare Pages connects to your Git repository, runs the Hugo build on every push, and publishes the generated files to its global network.
1. Push the project to GitHub
If the project is not in a Git repository yet:
git init
git add .
git commit -m "Initial commit"
git branch -M main
git remote add origin https://github.com/<your-account>/<your-repo>.git
git push -u origin main2. Create a Pages project
- Sign in to the Cloudflare dashboard and open Workers & Pages.
- Choose Create → Pages → Connect to Git.
- Select your repository and the
mainbranch. - Use the following build settings:
| Setting | Value |
|---|---|
| Framework preset | Hugo |
| Production branch | main |
| Build command | hugo --minify |
| Build output directory | public |
| Root directory | / (or the directory containing hugo.yaml) |
3. Pin the Hugo version
Cloudflare’s build image may not include the same Hugo version as your machine. Pin it explicitly with an environment variable so local and production builds stay identical.
In the Pages project, open Settings → Environment variables, add the variable below to Production (and Preview if you use preview deployments), then save:
| Variable | Value |
|---|---|
HUGO_VERSION |
0.169.0 |
This project is developed with Hugo Extended v0.169.0, so the same version is used on Cloudflare Pages. You can check your local version with:
hugo versionIf Cloudflare does not support the exact version, use the closest available version, or install the required Hugo binary in a custom build step.
4. Deploy
Click Save and Deploy. Cloudflare runs hugo --minify and publishes the public/ directory. Every push to main triggers a new production deployment, while pull requests receive their own preview URLs.
5. Bind a custom domain
- Open the Pages project and go to Custom domains → Set up a custom domain.
- Enter your domain, for example
code.example.com, and follow the DNS instructions. - Update
baseURLinhugo.yamlto the final domain:
baseURL: "https://code.example.com/"- Commit and push the change. This keeps canonical URLs,
sitemap.xml, RSS, and Open Graph links consistent.
This site is built with
HUGO_VERSION=0.169.0and published at https://code.jeiii.us/.