The easiest way to host a static website on Google Cloud is to put your HTML, CSS, JavaScript, and images in a Cloud Storage bucket and serve them through Google’s global network. There are no servers to patch, no web server to tune, and the setup scales automatically from ten visitors to ten million. Add Cloud CDN and an HTTPS load balancer, and visitors get fast, encrypted responses from an edge location close to them.
This tutorial walks through the complete production setup: naming the bucket after your domain, uploading your site files, configuring index and error pages, wiring up DNS, and putting the bucket behind a load balancer with Cloud CDN and a Google-managed SSL certificate. If you are migrating an existing site, our guides on how to redirect HTTP to HTTPS and how to secure Nginx with Let’s Encrypt SSL will help you compare the traditional server approach with this serverless one.
Prerequisites to Host a Static Website on Google Cloud
- A Google Cloud project with billing enabled and the Compute Engine and Cloud Storage APIs enabled.
- A domain you control, with ownership verified in Google Search Console — this is required because the bucket must be named after the domain.
- Access to your domain’s DNS settings so you can create CNAME and A records.
- Your static site files ready, including an
index.htmland a customerror.htmlpage. - The
gcloudCLI installed if you prefer command-line steps.
The official Google Cloud static website hosting documentation is a useful companion while you follow along.
Step 1: Create a Bucket Named After Your Domain
For direct bucket website hosting, the bucket name must exactly match the domain or subdomain you want to serve, for example www.example.com. First verify the domain in Search Console, then create the bucket:
gcloud storage buckets create gs://www.example.com --location=US
gcloud storage buckets update gs://www.example.com --uniform-bucket-level-access
Choose a multi-region location if your audience is spread out, or a single region close to most visitors if the site sits behind Cloud CDN anyway, because the CDN will cache content at the edge regardless of the bucket location.

Step 2: Upload Files and Set Website Configuration
Upload your site files and set the main page suffix and the not-found page. Google Cloud uses MainPageSuffix to serve your homepage for directory requests and NotFoundPage for 404 responses:
# Upload the site
gcloud storage cp -r ./public/* gs://www.example.com/
# Configure website behaviour
gcloud storage buckets update gs://www.example.com \
--web-main-page-suffix=index.html \
--web-error-page=error.html
# Verify the configuration
gcloud storage buckets describe gs://www.example.com
Set sensible cache headers on your assets while uploading. HTML should be cached briefly, while fingerprinted CSS and JavaScript files with versioned filenames can be cached for a year:
gcloud storage cp -r --cache-control="public, max-age=3600" ./public/*.html gs://www.example.com/
gcloud storage cp -r --cache-control="public, max-age=31536000, immutable" ./public/assets gs://www.example.com/assets
Step 3: Make the Objects Public
A public website bucket needs anonymous read access. With uniform bucket-level access enabled, grant the objectViewer role to allUsers:
gcloud storage buckets add-iam-policy-binding gs://www.example.com \
--member=allUsers --role=roles/storage.objectViewer
Only do this for a bucket that contains public website files. Never grant allUsers access to buckets holding backups, uploads from users, or anything private, and note that public access prevention must be disabled on this bucket for the grant to work. At this point you can test the plain HTTP endpoint at http://www.example.com once DNS is configured, or immediately via https://storage.googleapis.com/www.example.com/index.html.
Step 4: Point DNS to Cloud Storage
For the simple HTTP-only setup, create a CNAME record at your DNS provider:
www CNAME c.storage.googleapis.com.
This routes www.example.com directly to Cloud Storage. It works, but it does not support HTTPS on your custom domain and it does not use Cloud CDN. For a real production site, skip exposing this endpoint publicly and complete the load balancer setup in the next step instead — you will point the DNS A record at the load balancer’s IP address, not at the CNAME target.
How to Host a Static Website on Google Cloud with HTTPS and Cloud CDN
HTTPS and caching require an external Application Load Balancer with a backend bucket. The load balancer terminates TLS, applies your URL map, and Cloud CDN caches responses at Google’s edge locations.
Create the backend bucket and enable Cloud CDN
# Reserve a global static IP address
gcloud compute addresses create website-ip --global
# Create the backend bucket and enable Cloud CDN
gcloud compute backend-buckets create website-backend \
--gcs-bucket-name=www.example.com \
--enable-cdn
# Create the URL map
gcloud compute url-maps create website-map \
--default-backend-bucket=website-backend
Add a Google-managed SSL certificate and HTTPS proxy
# Managed certificate for your domain
gcloud compute ssl-certificates create website-cert \
--domains=www.example.com --global
# HTTPS target proxy and forwarding rule
gcloud compute target-https-proxies create website-https-proxy \
--url-map=website-map --ssl-certificates=website-cert
gcloud compute forwarding-rules create website-https-rule \
--global --target-https-proxy=website-https-proxy \
--address=website-ip --ports=443
# Optional: HTTP to HTTPS redirect
gcloud compute url-maps create website-http-redirect \
--default-url-redirect-https-redirect=true \
--default-url-redirect-strip-query=false
gcloud compute target-http-proxies create website-http-proxy \
--url-map=website-http-redirect
gcloud compute forwarding-rules create website-http-rule \
--global --target-http-proxy=website-http-proxy \
--address=website-ip --ports=80
# Get the IP to use in DNS
gcloud compute addresses describe website-ip --global --format="get(address)"
Finally, replace the CNAME from Step 4 with an A record for www pointing to that reserved IP address. DNS propagation and certificate provisioning usually complete within 15 to 60 minutes.
Cache invalidation basics
Cloud CDN caches objects according to their cache headers. When you publish an urgent fix, invalidate the cached copies instead of waiting for them to expire:
gcloud compute url-maps invalidate-cdn-cache website-map \
--host=www.example.com --path="/index.html" --global
# Invalidate everything under a path
gcloud compute url-maps invalidate-cdn-cache website-map \
--host=www.example.com --path="/assets/*" --global
Invalidations are fast but not free at scale, so prefer versioned asset filenames for routine releases and reserve invalidation for corrections.
Troubleshooting When You Host a Static Website on Google Cloud
403 errors on objects
The bucket is not public, uniform access is blocking an old ACL, or public access prevention is still enforced. Re-check the IAM binding for allUsers with roles/storage.objectViewer and confirm the organization policy allows public access for this project.
HTTPS certificate stuck in PROVISIONING
A managed certificate only activates after DNS points to the load balancer IP and propagation finishes. Verify the A record with dig www.example.com, confirm the forwarding rule uses the reserved address, and wait — provisioning commonly takes up to an hour. A FAILED status usually means the domain does not resolve to Google or DNS was changed mid-provisioning; fix DNS, delete the certificate, and create it again.
Cloud CDN not caching
Check that Cloud CDN is enabled on the backend bucket, that responses do not carry Cache-Control: private or no-store, and that requests are not bypassing the load balancer by going to the direct storage URL. Look for the Age header and a cache hit in the load balancer logs to confirm the CDN is serving the object.
404 page not showing
Confirm error.html exists at the bucket root, is publicly readable, and that NotFoundPage is set exactly to that filename in the bucket website configuration.
Conclusion
You now have a complete recipe to host a static website on Google Cloud: a domain-named bucket for storage, public read access scoped to that bucket only, and a load balancer providing HTTPS and Cloud CDN caching in front of it. The result is a site with no servers to maintain, automatic global scaling, and a monthly bill that is typically just a few cents for storage plus modest load balancer and CDN charges. For blogs, documentation, landing pages, and portfolio sites, it is one of the simplest and most reliable hosting setups available.