|
| 1 | +# Deploying the landing page to Cloudflare Pages |
| 2 | + |
| 3 | +The site lives in `web/`. Cloudflare Pages watches the `main` branch and rebuilds automatically on every push. No GitHub Actions workflow required — Cloudflare's own CI does the build. |
| 4 | + |
| 5 | +## One-time setup (~2 minutes) |
| 6 | + |
| 7 | +1. Sign in at [dash.cloudflare.com](https://dash.cloudflare.com/) (free account). |
| 8 | +2. **Workers & Pages → Create → Pages → Connect to Git.** |
| 9 | +3. Authorize Cloudflare for the `ArpitRajputGithub` account, pick the `httpsdev` repo. |
| 10 | +4. **Set up builds and deployments:** |
| 11 | + |
| 12 | + | Field | Value | |
| 13 | + |-------|-------| |
| 14 | + | Framework preset | Astro | |
| 15 | + | Build command | `npm run build` | |
| 16 | + | Build output directory | `dist` | |
| 17 | + | Root directory | `web` | |
| 18 | + | Node version | `22` (set via env var `NODE_VERSION` → `22`) | |
| 19 | + |
| 20 | +5. **Save and Deploy.** First build takes ~90s. |
| 21 | +6. Live at `httpsdev.pages.dev` (or `<some-hash>.httpsdev.pages.dev` on preview branches). |
| 22 | + |
| 23 | +## Custom domain (optional, when ready) |
| 24 | + |
| 25 | +- Buy a domain — [Porkbun](https://porkbun.com/) has `.dev` for ~$10/yr. |
| 26 | +- **Pages project → Custom domains → Set up a custom domain.** Cloudflare handles SSL and DNS automatically if the domain is on their nameservers. |
| 27 | +- Suggested: `httpsdev.dev`. |
| 28 | + |
| 29 | +## Preview deployments |
| 30 | + |
| 31 | +Every branch and PR gets its own preview URL — great for reviewing landing page changes before merging. |
| 32 | + |
| 33 | +## Local dev |
| 34 | + |
| 35 | +```bash |
| 36 | +cd web |
| 37 | +npm run dev # http://localhost:4321 |
| 38 | +npm run build # writes dist/ |
| 39 | +npm run preview # serves dist/ locally |
| 40 | +``` |
| 41 | + |
| 42 | +## Why Cloudflare Pages over GitHub Pages |
| 43 | + |
| 44 | +- Unlimited bandwidth (GH Pages soft-caps at 100 GB/month). |
| 45 | +- Faster CDN (Cloudflare's edge > GitHub's Fastly). |
| 46 | +- Cleaner URL (`httpsdev.pages.dev` vs `arpitrajputgithub.github.io/httpsdev`). |
| 47 | +- Automatic preview URLs per branch. |
| 48 | + |
| 49 | +## Emergency fallback: GitHub Pages |
| 50 | + |
| 51 | +If Cloudflare setup blocks you, GH Pages works with a one-liner workflow: |
| 52 | + |
| 53 | +```yaml |
| 54 | +# .github/workflows/deploy-web.yml |
| 55 | +name: deploy-web |
| 56 | +on: |
| 57 | + push: |
| 58 | + branches: [main] |
| 59 | + paths: [web/**] |
| 60 | +jobs: |
| 61 | + build: |
| 62 | + runs-on: ubuntu-latest |
| 63 | + steps: |
| 64 | + - uses: actions/checkout@v4 |
| 65 | + - uses: actions/setup-node@v4 |
| 66 | + with: { node-version: '22' } |
| 67 | + - run: cd web && npm ci && npm run build |
| 68 | + - uses: actions/upload-pages-artifact@v3 |
| 69 | + with: { path: web/dist } |
| 70 | + deploy: |
| 71 | + needs: build |
| 72 | + permissions: { pages: write, id-token: write } |
| 73 | + runs-on: ubuntu-latest |
| 74 | + steps: |
| 75 | + - uses: actions/deploy-pages@v4 |
| 76 | +``` |
| 77 | +
|
| 78 | +Then in the repo's Settings → Pages → Source: "GitHub Actions". |
0 commit comments