Cutting over the docs site to a company-owned Cloudflare account#
The Hugo docs are currently deployed under a personal Cloudflare account at cube2-backend-docs.pages.dev. This is the playbook to move it under the company’s Cloudflare account with a company domain (e.g. docs.manex.com) with zero downtime.
The code is already set up so the cutover is a repo-variable change, not a code edit: CLOUDFLARE_PAGES_PROJECT in Bitbucket controls the target project name. deploy-docs.sh reads the same var.
Phase 1 — Ops (company side)#
- Cloudflare account — create or use existing for the company
- Domain in Cloudflare — pick one:
- Subdomain-only (recommended first pass): keep existing registrar/DNS; add
CNAME docs → <new-project>.pages.dev - Full zone: Cloudflare nameservers on
manex.com— bigger change, one-time nameserver flip at registrar
- Subdomain-only (recommended first pass): keep existing registrar/DNS; add
- API token — Cloudflare dashboard → My Profile → API Tokens → Create Token → template “Edit Cloudflare Workers” or a custom token with scope
Cloudflare Pages: Editon the company account - Copy Account ID — visible in the dashboard sidebar
Ops hands back: API token, Account ID, agreed project name (e.g. manex-cube2-docs), agreed custom domain (e.g. docs.manex.com).
Phase 2 — Bitbucket cutover (zero downtime)#
The old project keeps serving traffic until step 5.
Repo settings → Repository variables — replace with company values:
CLOUDFLARE_API_TOKEN(secured) — company tokenCLOUDFLARE_ACCOUNT_ID— company account IDCLOUDFLARE_PAGES_PROJECT— new project name (e.g.manex-cube2-docs)
First deploy under the new account — trigger a build on the
developbranch (or any push). Pipeline callswrangler pages project create "$CF_PROJECT"which creates the project idempotently, then uploads. Site is live at<new-project>.pages.devimmediately.Attach the custom domain — Cloudflare dashboard → Pages → new project → Custom domains → add
docs.manex.com. Cloudflare shows the CNAME target and auto-issues an SSL cert.Update DNS at your registrar / DNS provider — add
CNAME docs → <new-project>.pages.dev. Propagation is typically minutes.Re-apply Cloudflare Access (Google SSO gating for
@manex.com) under the new account:- Zero Trust dashboard → Access → Applications → Add application → Self-hosted
- Application domain:
docs.manex.com - Policy: Include → Emails ending in
@manex.com - Identity provider: Google (or company Google Workspace SSO)
- Test in an incognito window — expect Google login prompt
Phase 3 — Retire the old (personal) project#
Only after Phase 2 step 5 works end-to-end.
- Old Cloudflare account → Pages →
cube2-backend-docs→ Delete project - Revoke old personal
CLOUDFLARE_API_TOKEN - Remove any stale CNAMEs pointing at the old
pages.devURL - (Optional)
wrangler logouton your laptop, thenwrangler loginunder the company account
Phase 4 — Update in-repo URLs#
Bulk-replace the old public URL wherever it’s mentioned:
grep -rn 'cube2-backend-docs.pages.dev' docs/ scripts/ README.md
# then bulk-replace to docs.manex.com — one commit, no code changePlaces to check:
README.mddocs/content/docs/**(anyhref="https://cube2-backend-docs.pages.dev/…")- Jira ticket comments — historical, no action needed
Local dev after cutover#
wrangler logout # drop personal auth
wrangler login # re-auth under company account
export CLOUDFLARE_PAGES_PROJECT=manex-cube2-docs
./scripts/deploy-docs.sh --branch=<any>Rollback#
If the cutover fails mid-flight (bad token, wrong project name, DNS not propagating):
- Revert the three repo variables to the personal-account values
- Trigger a pipeline run → old project resumes accepting deploys
- Old
cube2-backend-docs.pages.devcontinues serving traffic uninterrupted
DNS is the only irreversible-in-cache step — TTL should be set low (60s) before step 4 to make rollback fast.
Why this playbook#
Cloudflare has no “transfer project between accounts” primitive. Recreating is the supported path, and because Pages projects are just “point at a build output,” creation cost is near zero. The zero-downtime property comes from serving the two .pages.dev origins in parallel while DNS decides which one traffic reaches.