Skip to main content

Command Palette

Search for a command to run...

No Servers, No Stress: Host your site with Google Cloud Storage (GCS) & Cloudflare

Simple steps to host your static website with Google Cloud Storage and Cloudflare

Updated
4 min read
No Servers, No Stress: Host your site with Google Cloud Storage (GCS) & Cloudflare

So I had this basic tutorial site I built for a workshop purpose. The final artifact after the build was a static site, and I wanted to get it online.

I didn’t want to deal with spinning up a Cloud Run instance, a Lambda function, deploy via Netlify, or paying to any other service. I knew there’s AWS s3 static website hosting feature but never saw the same in Google Cloud. After poking around a bit, I figured out that Google Cloud Storage (GCS) is actually perfect for this. And with a little help from Cloudflare, you can even get a custom domain with HTTPS up and running pretty quickly.

This post is my attempt to write down the steps I took — hopefully it helps you avoid some of the “wait, what?” moments I had 😅

✅ What You Need First (Pre-reqs)

  • A Google Cloud account (duh)

  • A project with billing turned on (they need your card, but there’s a free tier)

  • Install the gcloud CLI — you’ll need this for the terminal stuff

  • Your site files: index.html, maybe a style.css, some images — whatever you’ve got

  • A domain name if you want to go fancy (optional but I recommend it if you’d like to learn the Cloudflare stuff)

Hosting from the GCP Console 🛠️

This is the click-click way to get your site online.

1. Create a Bucket

  • Go to Cloud Storage

  • Hit “Create bucket”

  • Name it exactly like your domain (e.g., mycoolblog.com) if you're planning to use a custom domain later

  • Choose multi-region, uniform access, skip the warning about public access (we’ll fix that next)

2. Upload Your Files

  • Drag in your files or folders — make sure there’s an index.html

3. Make It Public

  • Select the files

  • Click Permissions → Add principal

  • Add allUsers

  • Give them the role Storage Object Viewer

I messed this up once by not doing it on the bucket level — so double-check where you’re applying permissions.

4. Set Website Config

  • In your bucket, look for Website configuration

  • Set index.html as the main page

  • 404.html is optional, but it’s nice if someone hits a broken link

5. Visit Your Site

You can now open:
https://storage.googleapis.com/[your-bucket-name]/index.html

Is it the prettiest URL? No. Does it work? Absolutely.

💻 Hosting via CLI (gcloud storage)

If you’re a terminal person like me (or just lazy), the CLI is quicker.

# Make the bucket (use your domain name exact same if you're going custom)
gcloud storage buckets create gs://your-domain.com \
  --location=australia-southeast2 \
  --uniform-bucket-level-access

# Upload everything
gcloud storage cp ./your-site/* gs://your-domain.com

# Set website config
gcloud storage buckets update gs://your-domain.com \
  --web-main-page-suffix=index.html \
  --web-error-page=404.html

# Make it public
gcloud storage buckets add-iam-policy-binding gs://your-domain.com \
  --member=allUsers \
  --role=roles/storage.objectViewer

After that, boom 💥 Site’s live at:
https://storage.googleapis.com/your-domain.com/index.html

🌐 Adding Cloudflare (because HTTPS matters)

Cloudflare makes the domain + HTTPS setup painless.

1. Set Up Cloudflare

  • Go to cloudflare.com, sign up, and add your domain

  • It’ll ask you to switch your nameservers (do that in your domain registrar dashboard — usually under DNS settings)

2. Add a CNAME

In Cloudflare’s DNS settings:

  • Name: www

  • Target: c.storage.googleapis.com

  • Proxy: Set to DNS-only for now

Note: This only works if your GCS bucket is named www.yourdomain.com. I tried it with a different name and… nope.

3. Enable HTTPS

  • Under SSL/TLS, set mode to Flexible or Full (I used Flexible because it just worked)

  • Turn on — Always Use HTTPS & Automatic HTTPS Rewrites

4. Flip the Proxy

Once everything’s working with DNS-only, go back to your CNAME and turn the orange cloud ON (a.k.a. Proxied). That gives you caching and extra speed too.


➕ What’s Next?

  • Use a static site builder like Astro or Hugo if you’re tired of manually writing HTML

  • Add a CI/CD pipeline (GitHub Actions works great)

  • Add analytics (I’m trying out Plausible because I’m over Google Analytics)

  • Share your blog on X/Twitter/LinkedIn — let people know it’s alive!

Hope you learned something out of it. If you have any better way to do this, feel free to let me know in comments or share it personally.