The independent file on technology, travel & lifeFrom Pakistan, for everywhere
Huzi Blogs.
The ArchiveSectionsSearch

Planning a trip? HTG Travels — flights, visas, hotels & Umrah, handled properly.

WhatsApp +92 317 5054959
Huzi Blogs.

An independent file on technology, travel and life — long-form guides written plainly, from Pakistan, for everywhere.

ShopMeet the Creator

Sections

  • Travel
  • Technology
  • Lifestyle
  • Programming
  • Sports
  • Linux
  • All sections

The Desk

  • The Archive
  • Search the file
  • Disclaimer & Data Privacy Policy
  • A project of huzi.pk

© 2026 blogs.huzi.pk — All rights reserved.

Set in Playfair Display & Inter

    HomeProgrammingStory
    Programming

    The Ultimate Beginner's Guide to Building a Website with Cloudflare Pages (2026)

    H

    By Huzi

    File #99 · 3 min read

    Cloudflare Pages turned deployment into a single git push. Connect a repository and every commit builds on their edge network, served from hundreds of cities with automatic SSL and unlimited free bandwidth on static requests. Here is the shortest honest path from an empty folder to a live site.

    The quick answer: git push is the whole deployment story — connect the repo in the Cloudflare dashboard, every commit builds on the edge, and the two fixes everyone eventually needs are a _redirects file and a CNAME.

    Push, connect, deploy

    Start with a plain repository:

    git init
    git add .
    git commit -m "first commit"
    git branch -M main
    git remote add origin https://github.com/you/your-repo.git
    git push -u origin main
    

    In the Cloudflare dashboard, open Workers and Pages, create a Pages project, and connect that repository. The framework preset auto-detects most stacks; the one setting worth adding yourself is a NODE_VERSION environment variable so the build container matches your local Node.

    Each push then runs install and build and hands you a production URL at project.pages.dev plus a preview URL for every branch — which makes pull requests reviewable in a browser instead of imagination. If a build fails, the dashboard streams the full log, so a broken dependency install is a scroll, not a mystery.

    Preview URLs for every branch — nothing merges unseen — is also the courtesy a good itinerary deserves. HTG Travel puts the whole plan in front of you, hotels and trains and all, before anyone commits a rupee.

    Run the edge locally

    Wrangler is the CLI, and npx wrangler pages dev gives you a local server that mirrors the production edge runtime, bindings included. Scaffold with whatever you already use — Astro and Hugo work just as well, and Next.js is one preset away:

    npm create vite@latest my-site -- --template react-ts
    cd my-site && npm install && npm run dev
    

    If it works against Wrangler locally, the deploy behaves the same way. Same runtime, same result. Bindings that behave identically in both places are the difference between testing and hoping.

    Functions and bindings

    Add a functions directory and file-based routing turns it into an API — the file path is the route. Bind D1 (SQLite at the edge), KV or R2 through wrangler.toml, then read them from env, no servers to rent:

    // functions/api/items.ts — answers GET /api/items
    export const onRequestGet: PagesFunction = async ({ request, env }) => {
      const rows = await env.DB.prepare("SELECT * FROM items").all();
      return Response.json(rows.results);
    };
    

    The two fixes everyone needs

    When a single-page app 404s on refresh, that is routing, not bad luck. The five moments every beginner eventually meets, and the repair for each:

    Beginner moment The fix
    SPA 404s on refresh Add a public/_redirects file containing /* /index.html 200
    Custom domain Point a CNAME at project.pages.dev, let Universal SSL cover it, switch on Always Use HTTPS
    Build mismatch Set a NODE_VERSION environment variable
    Want production behaviour locally npx wrangler pages dev
    Last deploy went bad Instant rollback — one click back to the last good build

    That is genuinely the whole ceremony.

    Pro tip: Add the NODE_VERSION environment variable before your first build fails — a build container that matches your local Node turns build mysteries into a scroll through the streamed logs.

    In Gaza, volunteer teams keep shelter maps, medical supply lists and family-locator pages online through blackouts, on eSIMs and whatever charge remains — infrastructure as survival, not abstraction. Sudan's teachers rebuild syllabi from memory after each wave of destruction — may what they rebuild this time stay standing.

    Pages ships one quietly kind feature: instant rollback, one click back to the last good build. We run the same safety net at HTG Travel — when an airline cancels or a schedule collapses, we rebook and reroute until your plan is whole again. Deploy your site yourself; let us handle the departures: +92 317 5054959.

    Presented by

    HTG Travels — Plan the Trip, Skip the Runaround

    Flights, visas, Umrah packages and Hunza–Skardu tours, handled end to end from our licensed Sialkot desk. Real fares, hotel names in writing, and a human who answers — before you pay a rupee.

    Flights & rebooking Visa files Umrah 2026–27 Northern tours
    Visit huzi.pkWhatsApp +92 317 5054959

    Sialkot, Pakistan · Licensed agency · Fast quotes on WhatsApp


    You Might Also Like

    Heavy Embroidered Chiffon Bridal Dress 2025 | Cutwork & Embroidered Silk Trouser

    Heavy Embroidered Chiffon Bridal Dress 2025 | Cutwork & Embroidered Silk Trouser

    PKR 5750

    Luxurious Heavy Embroidered Bridal Chiffon Maxi 2026 (56" Length, 120" Width)

    Luxurious Heavy Embroidered Bridal Chiffon Maxi 2026 (56" Length, 120" Width)

    PKR 8650

    Fashion Men’s Unstitched Shalwar Kameez – Premium Soft Egyptian Cotton Fabric | Summer Wear Pakistan

    Fashion Men’s Unstitched Shalwar Kameez – Premium Soft Egyptian Cotton Fabric | Summer Wear Pakistan

    PKR 3000

    Silver Grey Hand-Embellished Raw Silk Wedding Dress – Unstitched Luxury Party & Bridal Outfit with Glittering Dupatta

    Silver Grey Hand-Embellished Raw Silk Wedding Dress – Unstitched Luxury Party & Bridal Outfit with Glittering Dupatta

    PKR 8000

    IB Swiss Fashion Men’s Unstitched Shalwar Kameez – Soft Egyptian Cotton Fabric | Premium Summer Collection Pakistan

    IB Swiss Fashion Men’s Unstitched Shalwar Kameez – Soft Egyptian Cotton Fabric | Premium Summer Collection Pakistan

    PKR 3300

    Keep reading

    Related files

    Programming
    English

    The Beginner's Guide to React: Building the Modern Web (2026)

    The component mental model, one-way props, the server/client split that defines modern React, and the scaffolding commands to start a real project today.

    By HuziFile #52

    Read
    Programming
    English

    Demystifying REST APIs: A Beginner's Guide (2026)

    Resources with URLs, HTTP verbs as actions, status codes as the contract, and where REST sits next to GraphQL and gRPC in a 2026 backend.

    By HuziFile #121

    Read
    Programming
    English

    Real-Time Revolution: Building Interactive Apps with WebSockets (2026)

    The 101 Switching Protocols handshake, choosing between polling, SSE and WebSockets, a working Yjs editor server, and the scaling and security rules that keep the bridge standing.

    By HuziFile #87

    Read
    Programming
    English

    Building a REST API with Node.js and Express 5 (2026)

    A hands-on walkthrough: scaffold a TypeScript project, build an Express 5 router with Zod-validated CRUD routes, and wire up one error handler.

    By HuziFile #86

    Read
    Programming
    English

    The Architecture of Scale: Building REST APIs with Node.js (2026)

    The design layer of a professional API: resource naming, honest status codes, layered architecture, Zod boundaries, argon2 hashing, and correlation-ID error handling.

    By HuziFile #85

    Read
    Programming
    English

    A Beginner's Guide to React Hooks: Mastering Modern React (2026)

    useState, useEffect, the React 19 form hooks, and the two rules that keep hooks from breaking — each with a runnable snippet.

    By HuziFile #10

    Read
    Back to the archive