Oct 14, 2026 • 2 min read
Host a static website (gcloud)
Introduction
The Hosting a static website blog post walks through the essentials of running a website from a Google Cloud Storage bucket.
In general just remember that the bucket name needs to be globally unique.
ProTip: prefix the bucket name with the Google project identifier e.g.
myawesomeproject-bucket
In this post, I show you how to add a landing page to a Google Cloud Storage bucket. If you just need a quick and easy website (e.g. not concerned about domains, SSL etc), this is a really simple option.
Requirements
- Google Cloud Project
- Static Website content e.g. School Website, Business Page, Hugo Blog!
Steps
To get up and running, we need to do a couple of activities
-
Create a bucket
-
Upload website content to the bucket
-
Add website configuration
Add web default settings on the bucket. Note:
- The setting below expects an
index.htmlas the main page. - It also adds a
404.htmlfile for content not accessible on the website.
NODE_TYPE // bashgcloud storage buckets update gs://[bucket name] \ --web-main-page-suffix=index.html \ --web-error-page=404.html - The setting below expects an
-
Add Cors configuration
A basic cors configuration file
bucket-cors.jsonthat enablesHTTP GETfrom anyoriginis shown below:NODE_TYPE // json[ { "origin": ["*"], "method": ["GET"], "responseHeader": ["Content-Type"], "maxAgeSeconds": 3600 } ]The file needs to be applied to your bucket to stop those nasty CORS messages when using web based browsing. To apply this to the bucket, use the following command:
NODE_TYPE // bashgcloud storage buckets update gs://[bucket name] \ --cors-file=bucket-cors.json -
Amend the bucket permission settings
In general websites are publically accessible, so apply the necessary permission for general internet access as below:
NODE_TYPE // bashgcloud storage buckets add-iam-policy-binding gs://[bucket name] \ --member=allUsers \ --role=roles/storage.objectViewerNote:
- The
allUsersrole is a special Google Cloud user which means make it public. - The permission
roles/storage.objectViewerenables the public to view the files within the stated bucket.
- The
-
Test the website
From the bucket click on the
index.htmlto show the public url e.g.https://storage.googleapis.com[bucket name]/index.htmlYou now successfully deployed a static website in Google Cloud.