The documentation for Pages says to set HUGO_VERSION in env vars: 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 (see the Prerequisites for the minimum recommended version). For example, HUGO_VERSION: 0.128.0. Note If you plan to use preview deployments, make sure you also add environment variables to your Preview environment.
However, when using Workers, env vars are not available.