Theme
Deploy on Cloudflare Pages
This page shows the exact steps to host this documentation website on Cloudflare Pages.
Prerequisites
- Git repository is pushed to GitHub (or GitLab)
- Cloudflare account with Pages access
- Node 20+ available in build environment
Build settings for Cloudflare Pages
Use these values in Pages project setup:
- Framework preset:
None - Build command:
npm run docs:build - Build output directory:
docs/.vitepress/dist - Root directory:
/(repository root)
Required environment variables:
NODE_VERSION=20DOCS_SITE_URL=https://your-docs-domain.com
DOCS_SITE_URL is used to auto-generate:
sitemap.xmlhostnamerobots.txtsitemap link
Step-by-step deployment
- Push this project to GitHub.
- In Cloudflare Dashboard, open Workers & Pages -> Create application -> Pages.
- Choose Connect to Git and select this repo.
- Add build settings shown above.
- Click Save and Deploy.
After the first build completes, Cloudflare provides a live *.pages.dev URL.
Add custom domain (optional)
- Open your Pages project.
- Go to Custom domains.
- Add
docs.yourdomain.com(or any preferred subdomain). - If your DNS is already in Cloudflare, records are auto-configured.
Local commands
bash
npm run docs:dev
npm run docs:build
npm run docs:previewAuto-generated SEO files
When you run npm run docs:build:
- VitePress generates
sitemap.xml - Build script generates
robots.txtand points to your sitemap URL
Troubleshooting
- Build fails with Node error -> set
NODE_VERSION=20 - 404 on pages -> verify output directory is
docs/.vitepress/dist - Sitemap URL wrong -> set
DOCS_SITE_URLcorrectly in Cloudflare Pages env variables - Styles missing -> clear cache and redeploy