Deploy a Hugo site
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.
Before you continue
Install the Hugo CLI, using the specific instructions for your operating system below:
Your Linux distro’s package manager may include Hugo. If this is the case, install it directly using your distro’s package manager – for instance, in Ubuntu, run the following command:
$ sudo apt-get install hugo
$ brew install hugo
$ choco install hugo --confirm
$ scoop install hugo
Create a new project
$ hugo new site my-hugo-site
Hugo sites use themes to customize the look and feel of the statically built HTML site. There are a number of themes available at – for now, use the by running the following commands in your terminal:
$ cd my-hugo-site$ git init$ git submodule add https://github.com/panr/hugo-theme-terminal.git themes/terminal$ git submodule update --init --recursive
You should also copy the default configuration provided by the theme into the
config.toml file in your project’s directory. Take the following information and customize it per your site’s needs:
baseurl = "/"languageCode = "en-us"theme = "terminal"paginate = 5[params]# dir name of your main content (default is `content/posts`).# the list of set content will show up on your index page (baseurl).contentTypeName = "posts"# ["orange", "blue", "red", "green", "pink"]themeColor = "orange"# if you set this to 0, only submenu trigger will be visibleshowMenuItems = 2# show selector to switch languageshowLanguageSelector = false# set theme to full screen widthfullWidthTheme = false# center theme with default widthcenterTheme = false# set a custom favicon (default is a `themeColor` square)# favicon = "favicon.ico"# set post to show the last updated# If you use git, you can set `enableGitInfo` to `true` and then post will automatically get the last updatedshowLastUpdated = false# Provide a string as a prefix for the last update date. By default, it looks like this: 2020-xx-xx [Updated: 2020-xx-xx] :: Author# updatedDatePrefix = "Updated"# set all headings to their default size (depending on browser settings)# it's set to `true` by default# oneHeadingSize = false[params.twitter]# set Twitter handles for Twitter cards# see https://developer.twitter.com/en/docs/tweets/optimize-with-cards/guides/getting-started#card-and-content-attribution# do not include @creator = ""site = ""[languages][languages.en]languageName = "English"title = "Terminal"subtitle = "A simple, retro theme for Hugo"owner = ""keywords = ""copyright = ""menuMore = "Show more"readMore = "Read more"readOtherPosts = "Read other posts"missingContentMessage = "Page not found..."missingBackButtonLabel = "Back to home page"[languages.en.params.logo]logoText = "Terminal"logoHomeLink = "/"[languages.en.menu][[languages.en.menu.main]]identifier = "about"name = "About"url = "/about"[[languages.en.menu.main]]identifier = "showcase"name = "Showcase"url = "/showcase"
Create a post
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:
$ hugo new posts/hello-world.md
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 GitHub repository
$ git remote add origin https://github.com/<your-gh-username>/<repository-name>$ git branch -M main$ git push -u origin main
Deploy with Cloudflare Pages
To deploy your site to Pages:
- Log in to the 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:
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
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 on new pull requests, so you can preview how changes look to your site before deploying them to production.
Use a specific or newer Hugo version
To use a , 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).