Today I ran into an issue while deploying my Hugo website (this website) on Cloudflare Pages. My build failed with this error:
|
|
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:
- Log into your Cloudflare Dashboard
- Go to Pages > Your Project > Settings
- Click on “Build & deployments”
- Under “Environment variables”, add:
- Variable name:
HUGO_VERSION
- Value:
v0.137.1+extended
(or whatever version you need)
- Variable name:
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.