跳到主要内容

Cloudflare Pages

Use Cloudflare Pages as a static host for the Docusaurus build output.

Build settings

Set these values in Cloudflare Pages:

SettingValue
Framework presetNone
Build commandnpm run build
Build output directorybuild
Root directory/
Node.js version22

What the build does

npm run build runs Docusaurus first, then Pagefind:

npm run build:site
npm run index:search

The generated build/pagefind/ directory is deployed with the rest of the static site.

GitHub deployment flow

  1. Push changes to main.
  2. Cloudflare Pages installs dependencies from package-lock.json.
  3. Cloudflare Pages runs npm run build.
  4. Cloudflare Pages serves the generated build/ directory.