Skip to content

Deploying to Cloudflare (MkDocs)

This guide covers a repeatable workflow for deploying this MkDocs site to Cloudflare and troubleshooting common failures.

Prerequisites

  • A GitHub repository with this project
  • A Cloudflare account with Workers enabled
  • A working local build:
make build

If local build fails, fix that first before trying cloud deployment.

1) Verify local project structure

For this setup, your repository should include:

  • mkdocs.yml
  • requirements.txt
  • docs/ (source content)
  • site/ (generated output from MkDocs build)

site/ is generated by mkdocs build and is what gets deployed as static assets.

2) Connect Git repository in Cloudflare

In Cloudflare Worker build settings:

  1. Connect the correct GitHub repository.
  2. Select the production branch (for this repo: master).
  3. Confirm the repository name carefully. A wrong repo connection causes missing-file errors during build.

3) Configure build and deploy commands

Use the following commands:

  • Build command:
pip install -r requirements.txt && mkdocs build --strict
  • Deploy command:
npx wrangler deploy --assets site --compatibility-date 2026-03-23 --name hyperpastadev-website
  • Non-production/version command:
npx wrangler versions upload --assets site --compatibility-date 2026-03-23 --name hyperpastadev-website

4) Configure root path and branch control

  • Root directory/path: /
  • Production branch: master (for this repository).

If branch naming changes in GitHub later, update Cloudflare production branch to match.

5) Trigger deployment

After connecting or reconfiguring:

  1. Push a commit to the production branch.
  2. Open Cloudflare build history.
  3. Confirm:
  4. dependency install succeeds
  5. mkdocs build --strict succeeds
  6. wrangler deploy --assets site ... succeeds

6) Validate deployed site

Check:

  • Worker URL (*.workers.dev) loads the full MkDocs site
  • CSS, JS, and images load correctly
  • key internal pages and links work

If you see only Hello world, Cloudflare is serving a default Worker response instead of static assets.

7) Add custom domain and DNS

In Worker settings:

  1. Go to Domains & Routes
  2. Add route(s), for example:
  3. hyper-pasta.dev/*
  4. www.hyper-pasta.dev/*
  5. In DNS, add proxied CNAME records:
  6. @ -> hyperpastadev-website.inkpenguin2010.workers.dev
  7. www -> hyperpastadev-website.inkpenguin2010.workers.dev
  8. Wait a few minutes, then verify both:
  9. https://hyper-pasta.dev
  10. https://www.hyper-pasta.dev

Both DNS records and both Worker routes are required for apex and www to work reliably.

8) Multi-domain mapping for this site

This site is configured to be reachable from multiple domains:

  • www.hyper-pasta.dev
  • www.rebooted.dev

To support this setup in Cloudflare:

  1. Add DNS records for each hostname pointing to the Worker hostname:
  2. www on hyper-pasta.dev -> hyperpastadev-website.inkpenguin2010.workers.dev (proxied)
  3. www on rebooted.dev -> hyperpastadev-website.inkpenguin2010.workers.dev (proxied)
  4. Add Worker routes for each hostname:
  5. www.hyper-pasta.dev/*
  6. www.rebooted.dev/*
  7. Validate both URLs load the same deployed site content.

Troubleshooting

Error: Could not open requirements file: requirements.txt

Likely causes:

  • wrong Git repository connected
  • wrong branch selected
  • incorrect build root/path

Actions:

  1. Confirm Cloudflare is connected to the intended repository.
  2. Confirm production branch matches your actual branch.
  3. Re-run build.

Error: A compatibility_date is required when publishing

Fix:

  • add --compatibility-date YYYY-MM-DD to deploy/version commands, or
  • define it in wrangler.toml.

Warning about Worker name mismatch

Fix:

  • set --name <worker-name> in deploy/version commands so CI and worker config agree.

Build succeeds but deployed site is wrong

If deployed output does not match local:

  1. Compare Cloudflare URL with local preview (http://127.0.0.1:8001).
  2. Confirm latest deployment is active.
  3. Confirm deploy command includes --assets site.

Domain does not resolve (Could not resolve host)

Likely causes:

  • DNS records for @/www are missing
  • DNS records are not proxied

Actions:

  1. Add proxied CNAME for @ and www to the Worker *.workers.dev hostname.
  2. Confirm Worker routes include both:
  3. hyper-pasta.dev/*
  4. www.hyper-pasta.dev/*
  5. Re-test after a short wait (usually a few minutes).

Before every deploy:

  1. Run local preview: make serve
  2. Run strict build: make build
  3. Commit and push changes
  4. Verify Cloudflare build/deploy logs
  5. Smoke test live URL