EnglishAdvanced GuidesMono-repo Config

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

  1. Create a new Pages project.
  2. Select my-repo.
  3. Build configurations > Root directory: apps/docs (or wherever your Nextra app is).
  4. Build command: npm install && npm run build.
  5. Output directory: out.

Project 2: Blog

  1. Create another new Pages project.
  2. Select the same my-repo.
  3. Build configurations > Root directory: apps/blog.
  4. Configure build settings appropriate for that framework.

Managing Dependencies

In a mono-repo, dependencies can be tricky.

  • Workspaces: If using npm workspaces or yarn workspaces, ensure your root package.json defines them.
  • Lockfile: As discussed in the troubleshooting guide, sometimes it’s easier to let Cloudflare resolve dependencies per-project by running npm install in the sub-project, rather than relying on a complex root lockfile.