You don't need expensive hosting to put a website online. With GitHub and Cloudflare Pages, you can host a static website completely free—with SSL, CDN, and excellent performance. Here's exactly how to do it.

What You'll Need

  • A GitHub account (free)
  • A Cloudflare account (free)
  • A domain name (optional, ~$12/year)
  • Your website files (HTML, CSS, JS)

Step 1: Create a GitHub Repository

First, let's get your files on GitHub.

  1. Go to github.com and sign in
  2. Click the + button → New repository
  3. Name it something like my-website
  4. Make it Public (required for free Cloudflare Pages)
  5. Turn on Add README
  6. Click Create repository

Step 2: Upload Your Files

You can either use Git from the command line or upload directly through the browser.

Option A: Using Git (Recommended)

# Navigate to your website folder
cd my-website

# Initialize git
git init

# Add all files
git add .

# Commit
git commit -m "Initial commit"

# Add your GitHub repo as remote
git remote add origin https://github.com/YOUR_USERNAME/my-website.git

# Push to GitHub
git branch -M main
git push -u origin main

Option B: Upload via Browser

  1. On your new repo page, click uploading an existing file
  2. Drag and drop your website files
  3. Click Commit changes

Step 3: Connect GitHub to Cloudflare Pages

Now let's deploy your site using Cloudflare Pages.

  1. Sign up or log in at dash.cloudflare.com
  2. In the left sidebar, click Workers & Pages
  3. Click Create application
  4. Select the Pages tab at the bottom
  5. Click Connect to Git
  6. Authorize Cloudflare to access your GitHub account
  7. Select your repository (e.g., my-website)
  8. Click Begin setup

Configure Build Settings

For a simple static HTML site (no build process):

  • Project name: your-project-name (this becomes your subdomain)
  • Production branch: main
  • Build command: leave empty
  • Build output directory: leave empty (or / if required)

Click Save and Deploy.

Wait 1-2 minutes for the deployment to complete. Once done, your site will be live at:

https://your-project-name.pages.dev

🎉 Congratulations! Your website is now online.

Step 4: Add a Custom Domain (Optional)

If you want your own domain (like mywebsite.com), keep reading. If the .pages.dev URL is fine for now, you can stop here.

4.1: Add Your Domain to Cloudflare

First, your domain needs to be managed by Cloudflare:

  1. In Cloudflare dashboard, click Add a Site
  2. Enter your domain name (e.g., mywebsite.com)
  3. Select the Free plan
  4. Cloudflare will scan your existing DNS records
  5. It will give you two nameservers - copy these

4.2: Update Nameservers at Your Registrar

Go to wherever you bought your domain (Namecheap, GoDaddy, Porkbun, etc.) and update the nameservers to the ones Cloudflare gave you. This usually takes 5-30 minutes to propagate (sometimes up to 24 hours).

4.3: Add Custom Domain to Cloudflare Pages

Once your domain is active in Cloudflare:

  1. Go to Workers & Pages
  2. Click on your Pages project
  3. Go to the Custom domains tab
  4. Click Set up a custom domain
  5. Enter your domain (e.g., www.mywebsite.com or mywebsite.com)
  6. Click Continue
  7. Cloudflare will automatically configure the DNS records
  8. Click Activate domain

Cloudflare handles everything automatically—DNS records, SSL certificate, the works. Within a few minutes, your custom domain will be live.

Tip: Add both mywebsite.com and www.mywebsite.com as custom domains so both work.

Updating Your Site

Whenever you want to update your website, you have two options:

Option A: Using Git (Recommended)

# Make your changes locally, then:
git add .
git commit -m "Update: description of changes"
git push

Option B: Direct Upload on GitHub

  1. Go to your repository on GitHub
  2. Navigate to the file you want to update
  3. Click the pencil icon (Edit this file) to edit directly, OR
  4. Click Add fileUpload files to upload updated files
  5. Upload your updated HTML file (it will replace the existing file with the same name)
  6. Click Commit changes

Cloudflare Pages automatically detects the changes and redeploys your site within 1-2 minutes.

Troubleshooting

Common issues and fixes:

  • 404 errors — Make sure you have an index.html file in the root of your repository
  • CSS not loading — Check your file paths (use relative paths like css/style.css, not /css/style.css)
  • Custom domain not working — Wait for DNS propagation (can take up to 24 hours), check nameservers are updated
  • Changes not showing — Hard refresh (Ctrl+Shift+R) or clear browser cache
  • Build failed — For static HTML, make sure build command is empty

What You Get for Free

With this setup, you get:

  • ✅ Free hosting (Cloudflare Pages — unlimited bandwidth)
  • ✅ Free SSL certificate (HTTPS)
  • ✅ Global CDN (Cloudflare's network)
  • ✅ DDoS protection
  • ✅ Fast page loads worldwide
  • ✅ Automatic deployments when you push to GitHub
  • ✅ Preview deployments for branches

The only cost is your domain name (~$12/year), and even that's optional if you're happy with the .pages.dev URL.

Wrapping Up

This is the same setup I use for this site and recommend to anyone building simple websites. It's reliable, fast, and costs almost nothing.

Got stuck somewhere? Drop me a message and I'll try to help.

📦 Related Resource

Want a head start? My Website Starter Kit includes a complete HTML template with this deployment workflow documented step-by-step (suitable for students and self-learners - $0 if you publish your website using GitHub / Cloudflare)