Cloudflare Pages Deployment
Recommended stack: Docusaurus + Cloudflare Pages + custom domain.
1. Why Cloudflare Pages
- Free tier available for open-source projects
- Automatic builds and previews once integrated with GitHub
- Global CDN delivery — fast access to a static site
2. Pre-deployment Checklist
url/baseUrlindocs-site/docusaurus.config.tsare correct- Local
npm run buildsucceeds - No broken links in the docs
- Target branch strategy is clear (main/dev)
3. Cloudflare Pages Configuration
In the console, go to Workers & Pages -> Create -> Pages:
- Framework preset:
Docusaurus - Root directory:
docs-site - Build command:
npm run build - Build output directory:
build - Environment variable:
NODE_VERSION=20
4. Verification After First Deployment
- Is the homepage reachable
- Is
/docs/introreachable - Are key topic pages reachable, e.g.
/docs/coding-agent/overview - Does the 404 page render in the expected locale
5. Custom Domain
Recommended binding: docs.ai4j.dev
After binding, verify:
- DNS resolution has taken effect
- HTTPS certificate status is healthy
- canonical URL and sitemap are correct
6. Branch Strategy Recommendations
main: production docsdev: pre-release docs- PR branches: preview environment
7. Common Issues
7.1 404 After Deployment
Investigate in this order:
- Is the Root directory mistakenly set to the repository root
- Does
baseUrlmatch the deployment path - Is Cloudflare still serving a cached older version
7.2 Pages Still Show Old Content
- Trigger a redeploy
- Run a Purge Cache
7.3 Local Renders Chinese, Production Renders English
- Check that
i18n.defaultLocaleiszh-Hans - Check whether stale translation override files were left in place
- Rebuild and redeploy to avoid incremental cache pollution
8. Continuous Integration Recommendations
The repository can already wire up a docs build workflow (e.g. .github/workflows/docs-build.yml). Recommended to run automatically on every PR:
- markdown lint (optional)
- docusaurus build
- broken link check