Hugo
Hugo ↗ is a tool for generating static sites, written in Go. It is incredibly fast and has great high-level, flexible primitives for managing your content using different content formats ↗.
In this guide, you will create a new Hugo application and deploy it using Cloudflare Pages. You will use the hugo
CLI to create a new Hugo site.
All of the framework guides assume you already have a fundamental understanding of Git ↗. If you are new to Git, refer to this summarized Git handbook ↗ on how to set up Git on your local machine.
If you clone with SSH, you must generate SSH keys ↗ on each computer you use to push or pull from GitHub.
Refer to the GitHub documentation ↗ and Git documentation ↗ for more information.
Go to Deploy with Cloudflare Pages if you already have a Hugo site hosted with your Git provider.
Install the Hugo CLI, using the specific instructions for your operating system.
If you use the package manager Homebrew ↗, run the brew install
command in your terminal to install Hugo:
If you use the package manager Chocolatey ↗, run the choco install
command in your terminal to install Hugo:
If you use the package manager Scoop ↗, run the scoop install
command in your terminal to install Hugo:
The package manager for your Linux distribution may include Hugo. If this is the case, install Hugo directly using the distribution's package manager — for instance, in Ubuntu, run the following command:
If your package manager does not include Hugo or you would like to download a release directly, refer to the Manual section.
The Hugo GitHub repository contains pre-built versions of the Hugo command-line tool for various operating systems, which can be found on the Releases page ↗.
For more instruction on installing these releases, refer to Hugo's documentation ↗.
With Hugo installed, refer to Hugo's Quick Start ↗ to create your project or create a new project by running the hugo new
command in your terminal:
Hugo sites use themes to customize the look and feel of the statically built HTML site. There are a number of themes available at themes.gohugo.io ↗ — for now, use the Ananake theme ↗ by running the following commands in your terminal:
Create a new post to give your Hugo site some initial content. Run the hugo new
command in your terminal to generate a new post:
Inside of hello-world.md
, add some initial content to create your post. Remove the draft
line in your post's frontmatter when you are ready to publish the post. Any posts with draft: true
set will be skipped by Hugo's build process.
Create a new GitHub repository by visiting repo.new ↗. After creating a new repository, go to your newly created project directory to prepare and push your local application to GitHub by running the following commands in your terminal:
To deploy your site to Pages:
- Log in to the Cloudflare dashboard ↗ and select your account.
- In Account Home, select Workers & Pages > Create application > Pages > Connect to Git.
- Select the new GitHub repository that you created and, in the Set up builds and deployments section, provide the following information:
Configuration option | Value |
---|---|
Production branch | main |
Build command | hugo |
Build directory | public |
After completing deployment configuration, select the Save and Deploy. You should see Cloudflare Pages installing hugo
and your project dependencies, and building your site, before deploying it.
After deploying your site, you will receive a unique subdomain for your project on *.pages.dev
.
Every time you commit new code to your Hugo site, Cloudflare Pages will automatically rebuild your project and deploy it. You will also get access to preview deployments on new pull requests, so you can preview how changes look to your site before deploying them to production.
To use a specific or newer version of Hugo ↗, create the HUGO_VERSION
environment variable in your Pages project > Settings > Environment variables. Set the value as the Hugo version you want to specify (v0.112.0 or later is recommended for newer versions).
For example, HUGO_VERSION
: 0.115.4
.
By completing this guide, you have successfully deployed your Hugo site to Cloudflare Pages. To get started with other frameworks, refer to the list of Framework guides.