A step-by-step guide to hosting a static website on Google Cloud Storage for better performance at a lower cost.
If you are hosting a static website (HTML/CSS/JS/Images), then you don’t need to bother about the cPanel web hosting plan to manage your site. Instead, you can use Google Cloud Storage (GCS), which will be cheaper, faster & easy to maintain.
A static site is suitable for personal, corporate, information page, or anything where you don’t expect to generate a transaction or dynamic content. It doesn’t need any server-side processing or database connectivity.
Why Google Cloud Storage?
It performs better at a lower cost.
You can host 10 GB of sites at multi-regional for high-availability for less than $1 per month.
You can choose to host your content on a multi-regional storage class, which means your data is available in two region’s data centers for high-availability.
Google offers high-performance cloud storage for fast loading content worldwide, with 99.95% availability SLA. There is no minimum limit of an object, and you pay what you use.
The following instructions will help you to host the static website on Cloud Storage in less than 15 minutes.
For this demonstration, I will use lab.geekflare.com.
Let’s get it started…
Verify Domain Ownership
First, you got to verify that you are an owner of the domain by adding the URL to “Search Console.”
Create Storage Bucket
- Log in to Cloud Storage and click “Create Bucket.”
- Enter the bucket name (important tips: if you would like to point your domain name to storage then you got to give the bucket name as a domain name)
- Select the storage class (leave multi-regional for high-performance & availability)
- Select location from US, EU & Asia (choose the nearest to your audience)
- Select standard as default storage class
- Select uniform access control
- Leave Google-managed key selected in advanced options.
- Click Create
Note: if a domain is not verified, you will get an error as below.
So you got to ensure the domain name which you’ve entered in the bucket name is verified.
Once a bucket is created, you should see them on the list.
Configuring Storage Bucket
It’s necessary to set up your bucket for your site to be accessible over the Internet.
- Select the bucket from the list
- Click on setting icon at right side >>Edit bucket permissions
- It will open permissions properties at the right side, click Add member
allUsersin the “New members” field and select role as “Storage Object Viewer.”
- Save the configuration and allow public access.
Let’s configure the index and error page.
- Click on setting icon again >>Edit website configuration
- Enter the index & 404 pages (Most of the time index page would be index.html & 404.html)
- Save the configuration
Uploading Static Website
It’s time to upload your site to cloud storage. I am using Slides by Designmodo for my static website.
- Click on the newly created bucket.
- Click “Upload folder/Upload files” and choose your website files to upload.
- Ensure index.html is present in bucket root
Based on file size, it may take some time.
Update CNAME Record
Finally, you got to point your domain to Google Cloud storage using a CNAME record.
Login to your Domain Registrar control panel and update CNAME to c.storage.googleapis.com of your domain. It may take some time to get DNS propagated globally, and you may use the DNS lookup tool to verify the result.
Once domain CNAME is resolving to c.storage.googleapis.com, you can try accessing the URL to confirm working as expected.
So as you can see, my static website is up and running on Google Cloud storage.
By default, a site will be available on
http:// however, if you need to secure and make it accessible using
https:// then I wrote this post to set up SSL on the GCS hosted site.
What’s an alternative to GCS to host static sites?
There are a few options.
I hope the above gives you an idea of how easy to host a static website on Cloud Storage at a low cost.
- Tagged in:
More great readings on Cloud Computing
An Introduction Guide to AWS FargateNaman Yash on June 14, 2022
10 Cloud-Based Cross Browser Testing Tools Saptak Chaudhuri on June 15, 2022
8 Best Virtualization Monitoring Tools for Medium to Big BusinessSatish Shethi on June 10, 2022
12 Best Hosting Platforms for the Germany MarketAmrita Pathak on June 11, 2022
Infrastructure as a Service (IaaS): Everything You Need To KnowNaman Yash on June 7, 2022
Deliver Your Application Content Faster to the Users with G-Core Labs CDNAmrita Pathak on May 26, 2022
Join Geekflare Newsletter
Every week we share trending articles and tools in our newsletter. More than 10,000 people enjoy reading, and you will love it too.