Today I ran into an issue while deploying my Hugo website (this website) on Cloudflare Pages. My build failed with this error:

1
2
3
4
5
6
13:13:51.471	ERROR => hugo v0.125.7 or greater is required for hugo-PaperMod to build
13:13:51.538	Total in 126 ms
13:13:51.538	Error: error building site: logged 1 error(s)
13:13:51.545	Failed: Error while executing user command. Exited with error code: 1
13:13:51.553	Failed: build command exited with code: 1
13:13:52.314	Failed: error occurred while running build command

I recently updated my PaperMod theme to its latest version, and that was the cause of the build error. The new theme required a newer Hugo version than Cloudflare’s default. Fortunately, updating the Hugo version on Cloudflare Pages was straightforward.

Here’s how to update your Hugo version on Cloudflare Pages:

  1. Log into your Cloudflare Dashboard
  2. Go to Pages > Your Project > Settings
  3. Click on “Build & deployments”
  4. Under “Environment variables”, add:
    • Variable name: HUGO_VERSION
    • Value: v0.137.1+extended (or whatever version you need)

That’s it! After adding this environment variable, my build started working perfectly again.

By the way, this same approach works for other runtimes on Cloudflare Pages too. You can set versions for:

  • Node.js using NODE_VERSION = "20.11.0"

  • Python using PYTHON_VERSION = "3.11"

  • PHP using PHP_VERSION = "8.2"

  • Ruby using RUBY_VERSION = "3.2.0"

  • Go using GO_VERSION = "1.21"

You can find other runtimes’ specific env variable name in Cloudflare Pages’ documentation. You can find other runtime-specific environment variables in the Cloudflare Pages documentation .

Remember to check your theme’s requirements before updating, as some themes might need specific Hugo versions to work correctly.