Mono-repo Configuration
If you want to manage multiple sites (e.g., a documentation site, a blog, and a marketing site) in a single Git repository, Cloudflare Pages supports it natively.
Structure
A common mono-repo structure looks like this:
my-repo/
├── package.json
├── apps/
│ ├── docs/ (Nextra)
│ ├── blog/ (Next.js)
│ └── landing/ (Astro)
└── packages/
└── ui/Configuring Cloudflare
You can deploy each app as a separate Cloudflare Pages project from the same repository.
Project 1: Docs
- Create a new Pages project.
- Select
my-repo. - Build configurations > Root directory:
apps/docs(or wherever your Nextra app is). - Build command:
npm install && npm run build. - Output directory:
out.
Project 2: Blog
- Create another new Pages project.
- Select the same
my-repo. - Build configurations > Root directory:
apps/blog. - Configure build settings appropriate for that framework.
Managing Dependencies
In a mono-repo, dependencies can be tricky.
- Workspaces: If using
npm workspacesoryarn workspaces, ensure your rootpackage.jsondefines them. - Lockfile: As discussed in the troubleshooting guide, sometimes it’s easier to let Cloudflare resolve dependencies per-project by running
npm installin the sub-project, rather than relying on a complex root lockfile.