How to make a static website with Google Cloud

For modern developers and business-minded individuals, Google Cloud can be a flexible option for users that need a multi-purpose storage solution for their website and other projects, backed by some of the most robust servers on the market. Publii includes support for Google Cloud services, so it's a great option if you need a well-designed but easily-maintained site for your project.

Note: Unlike similar services like Amazon S3 or Netlify, Google Cloud users in Europe are restricted to creating a business cloud account; that is, an account exclusively for a project intended to produce a profit. For non-business uses it's advisable to use one of the other cloud services that are compatible with Publii such as Netlify or Amazon S3.

Configuring Google Cloud for Publii

Before we start on the step-by-step guide to configuring Google Cloud, we must first make some preparations as Google Cloud requires more credentials than similar services. Ensure that you already have a working Google Cloud account (a payment option must have been added), and a domain that you have confirmed ownership of in the Search Console. A custom domain is necessary to take advantage of website functionality in Google Cloud storage (that is, working index.html redirects that redirect browsers from URLs to the specific directories).

When you have met all of these requirements, we may then move on to creating and configuring your bucket to work with Publii. Follow these steps to set-up Google Cloud:

  1. Start off by opening your Google Cloud console at
  2. Make sure that your website project is selected in the drop-down list in the toolbar at the top of the screen, or create a new one if necessary.

    Select Project

  3. Now click on the hamburger menu on the left of the toolbar, and select the Storage option.

    Google Cloud Storage

  4. The storage screen should default to the Browser tab; on this page, click on the Enable billing button; this will allow your account to be charged for any usage over the complimentary amounts.

    Enable billing

  5. With billing enabled the Browser tab will change to display some new options; click on the Create bucket button to get started.

    Creating Google Cloud backet

  6. You'll now need to enter some details for your bucket. For the bucket name, use your previously-verified domain name. For the Default storage class option, choose either Regional or Multi-regional depending on whether you expect your visitors to be from across the world or just one particular region. Finally, click the Create button to finish creating the bucket.

    Storage class multi-regional

  7. With the bucket created we now need to create a JSON key file that Publii can use to access the bucket in order to upload or update your website files. In the Google Cloud console, click on the hamburger menu and and choose IAM & Admin → Service accounts option.

    IAM and Admin

  8. A Create service account form will appear; in the Service account name option enter a name of your choice (it will not affect functionality). Set the Role option to Storage Admin and check the Furnish a new private key checkbox, then click the Create button.

    Service account management

    Creating service account

  9. The JSON file containing the key will be downloaded; make sure to keep it somewhere safe because it will not be possible to download it again later.

    Service account and key created

  10. To enable communication between Publii and Google Cloud we need to enable the Cloud Storage JSON API service; start by clicking on the hamburger menu and then on the API Manager option.

    API Manager

  11. In the API Manager screen, click on the Enable API link near the top of the page; you'll be taken to a list of APIs that you can enable, plus a search bar for ones not already visible.

    Enable API

  12. To find the API we need, Cloud Storage JSON API, click on the More link at the bottom of the list of Google Cloud APIs. Once you find it, click on it.

    Google Storage JSON API

  13. The settings screen for the API will load, but we don't need to change anything; just click the Enable button to the right of the name at the top of the page; with this done, configuration is complete.

    Enable Google Cloud storage JSON API

Google Cloud has now been setup, so we just need to open Publii and configure the server settings to make sure it is able to connect and upload files to the bucket.

Configuring Publii

Google Cloud might be a little fiddly to set up, but rest assured that Publii is not! Open Publii and navigate to the Server Settings screen by clicking on the Server option in the left sidebar menu, then set the options as follows:

  • Domain - Enter your verified domain here.
  • Protocol - Select Google Cloud from the drop-down list.
  • Your JSON key - Browse for your previously-downloaded JSON key for this field.
  • Bucket - Enter the bucket name here; this will be your custom domain in most cases.
  • Prefix - You can put your website in the subdirectory. Please avoid slash at the beginning (i.e. /blog/) - as it will create additional directory with the empty name. Proper prefix example: blog.

Google Cloud Website Settings

With all fields completed, click on the Save settings button, then click the Test connection button too to make sure that Publii is able to connect to the bucket. With that done, your now ready to start uploading and updating your site!