The --baseURL arg can be passed when calling hugo to build the site to override the base URL set in config/_default/hugo.toml. This is particularly useful when previewing changes in PRs because various links in the preview will link to the preview build instead of the main site.
There's a CF_PAGES_URL environment variable we should be able to reference when building the preview site:
https://developers.cloudflare.com/pages/configuration/build-configuration/#environment-variables
I'm going to experiment with this as preview builds have a different configuration section in Cloudflare, so it shouldn't impact production deployments.
The
--baseURLarg can be passed when callinghugoto build the site to override the base URL set in config/_default/hugo.toml. This is particularly useful when previewing changes in PRs because various links in the preview will link to the preview build instead of the main site.There's a
CF_PAGES_URLenvironment variable we should be able to reference when building the preview site:https://developers.cloudflare.com/pages/configuration/build-configuration/#environment-variables
I'm going to experiment with this as preview builds have a different configuration section in Cloudflare, so it shouldn't impact production deployments.