Cloudflare Pages — handover docs site
Purpose
Section titled “Purpose”Deploy the developer handover documentation (docs/) separately from the Frappe app. This page does not describe hosting ERPNext.
Production URL: https://leekimdocs.pages.dev · Cloudflare Pages project leekimdocs.
Prerequisites
Section titled “Prerequisites”- Node.js 22.12+ (Astro 6 requires
>=22.12.0; seedocs/package.jsonenginesanddocs/.nvmrc). - Cloudflare account; optional Wrangler CLI (
npm installalready includeswranglerunderdocs/devDependencies).
PUBLIC_SITE_URL (what to set)
Section titled “PUBLIC_SITE_URL (what to set)”This environment variable feeds Astro’s site option at build time. It is used for sitemaps, canonical URLs, and any metadata that needs an absolute public URL for this handover site.
| Question | Answer |
|---|---|
| What value? | The URL users type to open this docs site: production is https://leekimdocs.pages.dev. If you attach a custom domain, use that instead (e.g. https://docs.example.com). |
| Format | Include https://. Do not add a trailing /. |
| Local dev | Optional; defaults in astro.config.mjs apply if unset. For a local-only build test you can use http://localhost:4321, but CI and Cloudflare builds should use the real production URL. |
| Where to set | Root or docs/ .env (see .env.example), GitHub Actions repository Variable PUBLIC_SITE_URL, and/or Cloudflare Pages → project → Environment variables for dashboard builds. |
If PUBLIC_SITE_URL is missing in CI, the build still uses the default in docs/astro.config.mjs (https://leekimdocs.pages.dev unless you change it).
One-time setup (Cloudflare dashboard)
Section titled “One-time setup (Cloudflare dashboard)”-
Workers & Pages → Create → Pages → Connect to Git.
-
Select this repository.
-
Configure builds:
Field Value Root directory docsBuild command npm run buildBuild output directory dist/client(notdist— static files live here with@astrojs/cloudflare) -
Environment variables (production / preview): set
PUBLIC_SITE_URLtohttps://leekimdocs.pages.dev(or your custom domain; no trailing slash). Used by Astro for sitemaps and canonical URLs. -
Production branch: In the dashboard this lives under Settings → General (not always under a separate “Builds & deployments” heading — Cloudflare’s UI changes). Set Production branch to the branch that should power
https://leekimdocs.pages.dev. If docs only build fromstagingbut production ismain, Git builds show as Preview only and the project URL stays empty until a Production deployment exists. Either set production branch tostaging, or merge docs tomainso that branch gets a production build. -
Build command / output / root directory: If you use Connect to Git, these are part of the linked repository’s Pages build configuration — in some accounts they appear under Settings → Pages configuration (or the Deployments tab → manage build settings). Use root
docs, commandnpm run build, outputdist/client. -
Save and deploy.
What you should see after a correct upload: at the root of the deployment file list, index.html, 404.html, _astro/, section folders like api/, architecture/ — not a single top-level folder named client that contains those files. If server/ (with entry.mjs, wrangler.json) appears alongside client/, you are still publishing dist/; switch the output to dist/client only.
GitHub Actions
Section titled “GitHub Actions”Workflow: .github/workflows/deploy-docs.yml
- Runs on changes under
docs/**or when the workflow file changes;workflow_dispatchallows manual runs. - Sets
PUBLIC_SITE_URLfrom repository Variables (vars.PUBLIC_SITE_URL); default inastro.config.mjsishttps://leekimdocs.pages.dev. Match Cloudflare Pages env if you use dashboard builds. - Uploads
docs/dist/clientas a workflow artifact for inspection. - Publish:
cloudflare/pages-action@v1uploadsdocs/dist/client(static site root) to the leekimdocs Pages project. Required repository Secrets:CLOUDFLARE_API_TOKEN,CLOUDFLARE_ACCOUNT_ID(see Cloudflare direct upload). The job usespermissions: deployments: writeandgitHubToken: ${{ github.token }}for GitHub deployment status.
Local commands
Section titled “Local commands”From repository root:
npm run docs:install # oncenpm run docs:build # produces docs/distnpm run docs:preview # Astro previewnpm run docs:preview:cf # after build: Wrangler Pages dev (static under dist/client)From docs/: see docs/README.md for wrangler.toml and adapter notes.
Adapter output
Section titled “Adapter output”@astrojs/cloudflare emits dist/client (static HTML, index.html, assets) and dist/server (Worker). Pages direct upload and the dashboard “output directory” must point at dist/client, not dist, so the site root serves index.html.
Related
Section titled “Related”- Deployment & operations — Frappe / Bench app hosting
- Repository
docs/README.md— developer-focused build reference