docs(examples): Cloudflare Pages Static Deployment
@aRustyDev ci sta già lavorando.
Dal 5/1/2026.
Valutazione
Questa issue non è ancora stata valutata.
Descrizione
Cloudflare Pages Static Deployment
Deploy mdbook-htmx output as a static site on Cloudflare Pages.
Implementation
The Cloudflare deployment configuration lives in the mdbook-htmx repository:
mdbook-htmx/
├── wrangler.jsonc # Wrangler configuration
├── workers/
│ ├── index.ts # Main worker with HTMX routing
│ ├── auth.ts # Auth utilities (Phase 3)
│ ├── search.ts # Search handler (Phase 4)
│ ├── analytics.ts # Analytics (Phase 5)
│ ├── package.json
│ └── tsconfig.json
├── migrations/
│ └── 0001_sessions.sql # D1 schema (Phase 3)
└── .github/workflows/
├── test-deployments.yml
└── deploy-cloudflare.yml
Production URL: https://mdbook-htmx.arusty.dev
See ADR-0016 for phase-by-phase additions.
Overview
This is the simplest deployment option—pure static files served from Cloudflare's edge network. Ideal for public documentation without authentication requirements.
Prerequisites
- Cloudflare account
- Wrangler CLI (
npm install -g wrangler) - mdbook-htmx built output
Project Structure
my-docs/
├── book.toml
├── src/
│ └── ... (markdown files)
├── book/ # mdbook-htmx output
│ ├── index.html
│ ├── manifest.json
│ ├── search-index.json
│ └── assets/
└── wrangler.toml # Pages config
Configuration
book.toml
[book]
title = "My Documentation"
authors = ["Your Name"]
language = "en"
[output.htmx]
# Base URL for assets (Cloudflare Pages domain)
base_url = "https://docs.example.com"
# Enable asset hashing for cache busting
asset_hashing = true
# Prerender all pages for static deployment
prerender = true
# Disable server-side features
[output.htmx.search]
mode = "client" # Client-side search only
[output.htmx.authn]
enabled = false # No authentication
wrangler.toml
name = "my-docs"
compatibility_date = "2024-01-01"
pages_build_output_dir = "book"
# Optional: Custom headers
[[headers]]
for = "/*"
[headers.values]
X-Frame-Options = "DENY"
X-Content-Type-Options = "nosniff"
Referrer-Policy = "strict-origin-when-cross-origin"
# Cache static assets aggressively
[[headers]]
for = "/assets/*"
[headers.values]
Cache-Control = "public, max-age=31536000, immutable"
Build Script
#!/bin/bash
# build.sh
set -e
echo "Building documentation..."
mdbook build
echo "Optimizing assets..."
# Optional: Compress images, minify CSS/JS
# npx postcss book/assets/css/main.css -o book/assets/css/main.min.css
echo "Build complete!"
GitHub Actions Deployment
# .github/workflows/deploy.yml
name: Deploy to Cloudflare Pages
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
deploy:
runs-on: ubuntu-latest
permissions:
contents: read
deployments: write
steps:
- uses: actions/checkout@v4
- name: Install mdbook
run: |
curl -sSL https://github.com/rust-lang/mdBook/releases/download/v0.4.37/mdbook-v0.4.37-x86_64-unknown-linux-gnu.tar.gz | tar -xz
chmod +x mdbook
sudo mv mdbook /usr/local/bin/
- name: Install mdbook-htmx
run: |
cargo install mdbook-htmx
- name: Build documentation
run: mdbook build
- name: Deploy to Cloudflare Pages
uses: cloudflare/pages-action@v1
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
projectName: my-docs
directory: book
gitHubToken: ${{ secrets.GITHUB_TOKEN }}
branch: ${{ github.head_ref || github.ref_name }}
Custom Domain Setup
- In Cloudflare Dashboard → Pages → your-project → Custom domains
- Add domain:
docs.example.com - DNS will be configured automatically if domain is on Cloudflare
Redirects
Create book/_redirects for URL handling:
# Redirect old paths
/old-page /new-page 301
# SPA fallback (if needed)
/* /index.html 200
Headers
Create book/_headers for custom response headers:
# All pages
/*
X-Frame-Options: DENY
X-Content-Type-Options: nosniff
Content-Security-Policy: default-src 'self'; script-src 'self' 'unsafe-inline'; style-src 'self' 'unsafe-inline'
# Cache static assets
/assets/*
Cache-Control: public, max-age=31536000, immutable
# Don't cache HTML
/*.html
Cache-Control: public, max-age=0, must-revalidate
Performance Optimization
Enable Brotli Compression
Cloudflare automatically compresses responses. Ensure it's enabled:
- Dashboard → your-domain → Speed → Optimization
- Enable "Brotli"
Image Optimization
Use Cloudflare Image Resizing for dynamic image optimization:
<img src="/cdn-cgi/image/width=800,quality=80/images/diagram.png" alt="Diagram">
Monitoring
Web Analytics
Enable Cloudflare Web Analytics (privacy-friendly):
<!-- In layout.html before </body> -->
<script defer src='https://static.cloudflareinsights.com/beacon.min.js'
data-cf-beacon='{"token": "your-token"}'></script>
Page Views in Dashboard
View analytics at: Dashboard → Pages → your-project → Analytics
Cost
- Free tier: Unlimited requests, 500 builds/month
- Pro: $20/month for advanced features
Limitations
- No server-side rendering
- No authentication (use cf-workers-d1 for auth)
- No server-side search (client-side only)
- Build output limited to 25,000 files, 25 MB per file
Next Steps
- Add authentication with Workers
- Set up Meilisearch for server-side search
- Configure KV caching
- Lingua principale
- Rust
- Stelle
- 0
- Fork
- 1
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di aRustyDev/mdbook-htmx
-
feat(ci): Implement cross-repo-validate compliance for docs syncForse di nuovo libera @aRustyDev l’ha presa 280 giorni fa e non c’è nessuna pull request aperta. Apertaci enhancement
aRustyDev/mdbook-htmx#58 · 1 commento · 1 assegnatario ·
-
docs(htmx): Explain how HTMX worksForse di nuovo libera @aRustyDev l’ha presa 282 giorni fa e non c’è nessuna pull request aperta. Aperta
aRustyDev/mdbook-htmx#48 · 3 commenti · 1 assegnatario ·
-
docs(mdbook-htmx): Parent Issue for documentationForse di nuovo libera @aRustyDev l’ha presa 282 giorni fa e non c’è nessuna pull request aperta. Apertadocumentation
aRustyDev/mdbook-htmx#47 · 1 assegnatario ·
-
docs(examples): Secure Self-Hosted Meilisearch via CloudflareForse di nuovo libera @aRustyDev l’ha presa 282 giorni fa e non c’è nessuna pull request aperta. Apertadocumentation
aRustyDev/mdbook-htmx#46 · 1 assegnatario ·
-
docs(examples): Kubernetes with MeilisearchForse di nuovo libera @aRustyDev l’ha presa 282 giorni fa e non c’è nessuna pull request aperta. Apertadocumentation
aRustyDev/mdbook-htmx#45 · 1 assegnatario ·
Tutte le issue di aRustyDev/mdbook-htmx
Issue simili
-
Four problem loader browser tests fail on WindowsForse già presa @Patriciaath999 l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
I maintainer di solito rispondono entro 1 giorno
-
Claude Code guards in .claude/settings.json never block: they read unset variables and exit 1Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
starkware-libs/sequencer#15229 ·
I maintainer di solito rispondono entro 1 giorno
-
`fnox set` ignores piped stdin when `--description` is given, saving the secret without a valueAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 66/100
ActivityWatch/aw-notify-rs#47 · 1 commento ·