Google doesn’t officially provide web hosting services, but you can use Google Cloud Storage to upload your website files for free. Google Cloud Storage supports a static website with only CSS, HTML, and Images – this essentially removes the need to buy web hosting services.
The entire process is free, you’ll still need to purchase a domain though and a Google Cloud account.
Here are the steps involved in setting up a static website:
- Register a domain name
- Set up an account with Google Cloud
- Verification of domain ownership
- Pointing your domain to Google Cloud Storage
- Upload website files and make it go live!
Verifying Ownership of Domain
Verify domain ownership using Google Search Console. In the search console, click on Add a Property to enter your domain.
Pointing the Domain
Pointing your domain name to Cloud Storage requires changing the CNAME records pointing to www.yourdomain.com to c.storage.googleapis.com. Here’s how:
- Visit the DNS settings of your Domain, select “Add Record” and click on “CNAME”.
- In the Name section, type www
- In the Points section, type c.storage.googleapis.com
- Hit Save
Setting up the Website
- Visit the Google Cloud Console and check out storage
- Click on Create Bucket
- In Name, enter your domain name
- Under Default storage class, select Multi-regional
- In Location, select your preferred location
- Hit Create
- Click on the Permissions tab in your bucket to select Add Members
- Under Members, enter ‘all users’
- In Roles, click ‘Storage Object Viewer’
- Click ‘Add’
Now your ‘bucket’ is visible to the public.
Uploading Website Files
It’s time to upload the website’s files to the bucket.
Changing Website Config
Go to storage, click on the 3 dots next to your bucket, and select “Edit website configuration”.
- In Main page, enter details about your main html file (usually index.html)
- Hit Save
- Use the DNS Propagation tool here to check for a global test. You can view your website once the if your DNS is properly configured.
Note, your website will have HTTP by default. To enable HTTPs, check out the following steps to set up an SSL certificate for your website.
Use an SSL Certificate with Cloudflare
If you route your traffic through Cloudflare, you can easily enable HTTPs.
First, create an account with Cloudflare and click on Add Site.
Enter your website address and click on Add Site.
Cloudflare should fetch and import your DNS records.
- Click on Next to select a plan (a free plan should do just fine).
- Click on Confirm Plan.
Now you should see your imported DNS records.
- Click continue.
- Make sure to change the nameservers for your website with Cloudfare’s nameservers.
Once you’re done, click Continue.
To Activate HTTPs:
- Go to Crypto tab
- Scroll down and toggle Always Use HTTPS
- Next, activate Automatic HTTPS rewrites
- Now visit your website, it should load with HTTPS.
This method also allows your website to be accessible through Cloudflare.
So there you have it, you now have access to free and secure web hosting with Google Cloudflare.