From a domain name to a live website with Namecheap, Cloudflare, and GitHub
A step-by-step guide to registering a domain, publishing a static site on Cloudflare Workers, connecting the domain, and deploying updates from GitHub.
When I bought my first domain for this project, I could log in to my registrar and see the name in my account. What I still wanted was a more concrete result: type that name into a browser and see my page. After that, I wanted to edit the page, push to GitHub, and see the change appear at the same address.
Here’s the route I used. I’ll use example.com for the domain and my-static-site for the project throughout. Substitute the domain you register and your own project name. The tiny page in step 2 makes the whole process reproducible even if you don’t have an application ready.
The high-level picture
There are two paths worth keeping straight. When I publish, a commit goes to GitHub, Cloudflare builds it, and the resulting HTML becomes available on a Worker. When someone visits, DNS directs their browser to Cloudflare, which serves that HTML over HTTPS. Namecheap is where I manage the domain registration and renewal. Once Cloudflare serves the site, my laptop can be turned off.
I tested the hosting first on a Cloudflare-provided address. That gave me a working reference while I changed DNS. Here are the steps in that order.
1. Register a domain at Namecheap
- Sign in to Namecheap, open Domain Name Search, and search for the name and extension you want.
- Choose an available name. Compare the renewal price with the first-year price and check whether the name is marked premium. Add the domain to your cart.
- Review the registration term and auto-renew setting. For this setup, you can skip the hosting and SSL add-ons: Cloudflare will serve the files and issue the certificate for the custom domain.
- Enter accurate registrant contact information, review the total, and complete checkout. Look for a registrant verification email and complete verification if requested.
Checkpoint: Open Domain List → Manage for the new domain. Keep this tab handy. Later you’ll come back to change the Nameservers setting. Namecheap’s registration walkthrough
2. Put a buildable website in a private GitHub repository
If you already have a site, identify the directory your build produces. It should contain the actual homepage, usually index.html. In my deployment, the repository contained more than one build output. Checking which directory held the complete website saved me from publishing just a JavaScript library.
For a fresh example, install a current Node.js LTS release and Git, then run these commands in a terminal:
1
2
3
4
5
6
7
8
9
10
11
mkdir my-static-site
cd my-static-site
npm init -y
npm install --save-dev wrangler
mkdir public
printf '%s\n' '<!doctype html><html lang="en"><meta charset="utf-8"><title>My first deployment</title><h1>Hello from my domain</h1></html>' > public/index.html
cat > build.cjs <<'JS'
const fs = require("node:fs");
fs.cpSync("public", "dist", { recursive: true });
JS
npm pkg set scripts.build="node build.cjs"
Create a file named wrangler.jsonc beside package.json:
1
2
3
4
5
{
"name": "my-static-site",
"compatibility_date": "2026-12-05",
"assets": { "directory": "./dist" }
}
Run npm run build and open dist/index.html. You should see Hello from my domain. For an existing application, keep its build script and set assets.directory to its actual output directory. Workers Static Assets documentation
On GitHub, create an empty private repository named my-static-site. For the new project above, run the following after replacing YOUR-ACCOUNT with your GitHub username. Use your normal GitHub credentials when prompted.
1
2
3
4
5
6
printf 'node_modules/\ndist/\n.wrangler/\n' > .gitignore
git init -b main # Git 2.28+; else: git init && git checkout -b main
git add .gitignore public build.cjs package.json package-lock.json wrangler.jsonc
git commit -m "Add the first version of the site"
git remote add origin https://github.com/YOUR-ACCOUNT/my-static-site.git
git push -u origin main
Checkpoint: On GitHub, open the repository’s main branch and confirm it contains the source, lockfile, and Wrangler configuration. The build machine will generate dist from those files.
3. Deploy once and test the Cloudflare address
Create a Cloudflare account, verify your email, and start with the free plan. Back in the project directory, run:
1
2
3
4
5
npx wrangler login
npx wrangler whoami
npm run build
npx wrangler deploy --dry-run
npx wrangler deploy
The login command opens a browser for authorization. Check the account shown by whoami before deploying. The dry run checks the package locally. The last command is the one that publishes it.
On my first deployment, Wrangler asked me to register a workers.dev subdomain for my account. I chose an available name and confirmed. The resulting address followed the pattern https://my-static-site.YOUR-SUBDOMAIN.workers.dev. Open the exact URL Wrangler prints and check for the heading from your page.
My new address initially gave Chrome’s ERR_SSL_VERSION_OR_CIPHER_MISMATCH error. I checked npx wrangler deployments list, then retried HTTPS. The same deployment started serving the page a little later. If the error persists, check the production URL in the Worker’s Domains panel and test that address before touching your custom domain.
4. Give Cloudflare authority over the domain’s DNS
- In the Cloudflare dashboard, add your existing domain, enter the bare name, and choose Free for this walkthrough.
- Review the DNS records Cloudflare discovers. Compare them with the registrar’s records. A newly purchased domain may already have a parking record and mail records. If you use mail or forwarding, verify its migration requirements before switching. The checkboxes in Cloudflare’s record list select rows for bulk actions; leave them clear to keep the records.
- Cloudflare will display two assigned nameservers. Copy both. If DNSSEC is already active, follow Cloudflare’s migration guidance for removing the old DS record before changing nameservers.
- In Namecheap, open Domain List → Manage → Nameservers → Custom DNS. Replace the previous nameservers with the two assigned by Cloudflare, one per field, and save.
- Return to Cloudflare and wait for the domain status to become Active. You can keep using the
workers.devtest address while DNS updates.
Checkpoint: Cloudflare reports the domain is active. Your registration and renewal still live at Namecheap. Namecheap’s nameserver instructions
5. Bind the bare domain to the production Worker
In Cloudflare, go to Workers & Pages → my-static-site → Production → Domains. Look for Custom Domains and Routes, or Settings → Domains & Routes, depending on the dashboard layout. Choose Add → Custom Domain. If the form asks for the whole hostname, enter your domain. If it already displays your domain as a suffix, leave the optional Subdomain field empty. Keep Production selected and confirm.
This was the step that tripped me up. The dashboard said the hostname already had externally managed DNS records. Cloudflare DNS had imported my registrar’s old A record for the bare domain. The Worker needed to manage that same hostname.
For a newly registered domain with an unused parking record, identify the exact conflicting record under DNS → Records, confirm its purpose, remove that record, and retry the binding. If the record serves a live site, plan the cutover before replacing it. A separate www record and mail-related MX or TXT records can stay in place when binding the bare domain.
Checkpoint: Wait for the custom domain and its HTTPS certificate to be ready. Open your real domain in a fresh browser window and verify the page content. A registrar parking page can also return HTTP 200, so I check the heading as well as the status. Cloudflare’s custom domain guide
6. Connect GitHub so future pushes deploy automatically
Open the existing Worker in Cloudflare, then Settings → Builds → Git Repository. Connect GitHub and authorize the Cloudflare Workers and Pages GitHub app. I used Only select repositories and selected the private repository for the site. The Cloudflare and GitHub accounts can use different email addresses.
Keep builds enabled. Set the production branch to main, the root directory to /, the build command to npm run build, and the deploy command to npx wrangler deploy. The root directory tells npm where to find package.json; the assets directory in wrangler.jsonc tells Cloudflare which files to publish. Save the connection. Workers Builds Git integration
7. Prove the next release works from Git alone
Edit the heading in public/index.html, the source file. Change it to something recognizable, such as My second deployment, then run:
1
2
3
4
npm run build
git add public/index.html
git commit -m "Update the homepage heading"
git push origin main
Open the build in Cloudflare and match its commit to the one you just pushed. Once the deployment succeeds, refresh your custom domain and look for the new heading. This time there’s no manual wrangler deploy command. The changed page is the evidence that the entire path works, from the file on your laptop through GitHub to a visitor’s browser.
The most useful thing I kept from the setup was the temporary test URL. If the next release fails on both addresses, I can start with the build and deployment logs. If the Worker address serves the right page and the custom domain doesn’t, I know to start with DNS, the domain binding, and HTTPS.
8. Inspect and roll back a deployment
Once pushes deploy automatically, the skill that matters is reading the pipeline when something goes wrong. Cloudflare keeps every deployment with its commit and logs.
- In Cloudflare, open Workers & Pages → my-static-site → Deployments. Each entry lists the commit hash and status. Run
git log -1locally and match the hash to confirm which push produced a deployment. - Open a failed deployment to read its logs. The build step runs
npm run build; the deploy step runsnpx wrangler deploy. Most failures trace back to the build command or a wrongassets.directory. - Test both addresses. If the
workers.devURL serves the new page but the custom domain does not, the code is fine and the problem is DNS or the domain binding. If both fail, start with the build logs. - To recover quickly, select an earlier deployment from the list and roll back while you fix the code.
Checkpoint: git log -1 and the latest deployment show the same commit, and a rollback brings the previous version back on both addresses.

