Cloud Storage: my static page online in 1 single command
Here it is:
gsutil cp -r -a public-read page/* gs://my-quick-page/
Done! My little HTML website is now online at https://storage.googleapis.com/my-quick-page/index.html . Try the link!
That is really convenient, provided these prerequisites are satisfied:
- I have an HTML page on my local machine ;
- I am a Google Cloud Storage customer, which means I have enabled billing (or the “free trial”) in my Google Cloud Platform account ;
- I have installed and initialized the Cloud SDK, which includes gsutil ;
- I already have a bucket named “my-quick-page”. If not, I create it with :
gsutil mb gs://my-quick-page
The website for this example has the following structure on my local drive:
page/index.html
page/css/main.css
page/img/pear.png
page/img/favicon.png
The URL is quite long and uses a GCS domain, not my custom domain. The nice part about it is that my website is automatically secure (HTTPS) thanks to the *.storage.googleapis.com certificate.
Go to the gsutil cp documentation and Hosting a Static Website to know about a myriad of options to better fit your needs, e.g. to use your custom domain name.