Pages deployment commands

Hi there,

I am using Cloudflare pages with hugo. And since now Cloudflare lets me create staging builds i wonder if i can actually change the staging build command.

So for example in regualar build i have the domain but in the staging build i want to use the Cloudflare pages url for example

In hugo i can easily set different urls for different builds. QUestion is with Cloudflare pages how can control the command to build the staging site. The hugo command is hugo --environment staging

Any idea on how to do this with pages as i see no option to control the build command in staging. you can read more about this here

Thanks for taking the time.

You can’t do this natively today but you can do it with a script and using the CF_PAGES_BRANCH environment variable

We have a little guide on that here: Set build commands per branch · Cloudflare Pages docs

Thanks @WalshyMVP

Does this over ride the default hugo command or this will run in addition to the hugo command

I only want to run hugo --environment staging and no other build command


As per the guide you specify what command you want to run where. If you want to run that command only on the staging branch you can and then run the normal one elsewhere

Thanks @WalshyMVP

Just a feedback if possible it is much easier to just define the hugo build command for different enviornment. And i hope Cloudflare pages will consider this for future.


Yep, it is on the roadmap :slight_smile:

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.