Skip to content

Cloudflare Pages Direct Upload

This repo is configured to publish the Markdown docs with MkDocs Material and deploy them directly to Cloudflare Pages without GitHub.

Local Preview

Install dependencies:

python -m pip install -r requirements.txt
npm install

Run the local docs server:

python -m mkdocs serve

Build the static site:

python -m mkdocs build

MkDocs writes the static output to site/.

Direct Upload With Wrangler

Wrangler is included as a local dev dependency for direct deployment.

Useful commands:

npm run cf:login
npm run cf:pages:create
npm run cf:deploy

What they do:

  • cf:login: authenticates Wrangler with your Cloudflare account
  • cf:pages:create: creates a Pages direct-upload project
  • cf:deploy: rebuilds the docs and uploads site/ to Cloudflare Pages

For repeated deploys, the simplest Windows command is:

./scripts/deploy-pages.ps1 -ProjectName aelghar-docs

That command now defaults to the production branch so it updates the stable Pages URL.

Optional preview deploy:

./scripts/deploy-pages.ps1 -ProjectName aelghar-docs -Branch preview

First-Time Project Creation

Run:

npm run cf:login
npm run cf:pages:create

Wrangler will prompt for:

  • your Cloudflare login
  • the Pages project name
  • the production branch label for the direct-upload project

After the project exists, deploy with:

npm run cf:deploy

That script deploys to the production branch by default.

If you want to override the cached project and deploy to a specific Pages project immediately, use:

npx wrangler pages deploy site --project-name=aelghar-docs

Dashboard Fallback

If you do not want to use Wrangler, Cloudflare also supports dashboard drag-and-drop uploads for the built site/ folder.

Minimal fallback flow:

  1. run python -m mkdocs build
  2. open Cloudflare Pages
  3. choose direct upload / drag and drop
  4. upload the built site/ folder

Wrangler is the better repeatable path. Drag and drop is only a manual fallback.

API Token Alternative

If you prefer token-based auth instead of browser login, Cloudflare supports direct upload with:

  • CLOUDFLARE_ACCOUNT_ID
  • CLOUDFLARE_API_TOKEN

That is useful for CI later, but browser login is simpler for a local one-machine workflow.

Keep It Private

If the docs should not be public, put the Pages site behind Cloudflare Access.

Recommended pattern:

  1. deploy directly to Pages
  2. protect the Pages hostname with Cloudflare Access
  3. invite only the colleague email addresses that should be allowed to view it

Notes

  • The docs source stays in docs/.
  • MkDocs configuration lives in mkdocs.yml.
  • The generated site output in site/ should not be committed.
  • Direct Upload projects cannot later be converted into Git-integrated Pages projects.