Cloudflare Pages Preview Deploy with Different Flags

I have several hugo sites that are deployed on Cloudflare pages. I would like to be able to setup my preview deploys to use the -D flag which will render draft posts.

Is there a way of adding preview-only flags to the Cloudflare pages deployment? Perhaps through a preview specific environment variable or something?

While you can’t use different build commands for preview vs production, you can use your own script as a build command instead of just calling hugo. You can set environment variables separately for preview, and you also automatically get CF_PAGES_BRANCH, so you could in a script check an env var and call hugo differently.

Yeah, not sure why I didn’t think of that :doh:

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