Hosting Hugo On Google App Engine

Using html or javascript or enable BlackFriday.hrefTargetBlank

Hugo Deployment

Ensure config.toml baseURL is live URL.

baseURL = "https://hugo-app.appspot.com/"

Compile the content for publishing using hugo command.

hugo# OutputStarted building sites ...Built site for language en:0 of 13 drafts rendered0 future content0 expired content78 regular pages created154 other pages created1 non-page files copied85 paginator pages created51 tags createdtotal in 724 ms

Create Google Cloud and Google App Engine Project

Create a project on Google Cloud Platform.

  • Remember your Project ID

Create an App Engine app

  • Language: Python (pick a language you are familar with, though it doesn't matter for static website)
  • Region: us-central (depending on your audience)
  • Don't have to proceed with the Quickstart Tutorial.

Create App Engine

Install Google Cloud SDK

Download the latest Google Cloud SDK

Extract the package (e.g. tar -zxf google-cloud-sdk*.tar.gz)

Run install script to add SDK rools to your path

./google-cloud-sdk/install.sh# OutputModify profile to update your $PATH and enable shell commandcompletion? [Y]Enter a path to an rc file to update, or leave blank to use[ENTER]

Initialize the SDK (enter your Google credential and select Project ID)

./google-cloud-sdk/bin/gcloud init# You can respond "n" to the followingAPI [compute-component.googleapis.com] not enabled on project[793702336627]. Would you like to enable and retry?  (Y/n)?

Create App Engine project files

Create a directory for your app engine project.

mkdir hugo-appcd hugo-app

Create an app.yaml file.

runtime: python27api_version: 1threadsafe: truehandlers:- url: /  static_files: www/index.html  upload: www/index.html- url: /(.*)  static_files: www/\1  upload: www/(.*)

Create www as symbolic link to hugo's public directory.

ln -s /hugo/public www

Deploy to App Engine

Deploy local files to App Engine server.

gcloud app deploy -v 1# outputServices to deploy:descriptor:      [/hugo-app/app.yaml]source:          [/hugo-app]target project:  [hugo-app-id]target service:  [default]target version:  [1]target url:      [https://hugo-app.appspot.com]Do you want to continue (Y/n)?  Y

Launch brower to preview the website

gcloud app browse -v 1

References

❤️ Is this article helpful?

Buy me a coffee ☕ or support my work via PayPal to keep this space 🖖 and ad-free.

Do send some 💖 to @d_luaz or share this article.

✨ By Desmond Lua

A dream boy who enjoys making apps, travelling and making youtube videos. Follow me on @d_luaz

👶 Apps I built

Travelopy - discover travel places in Malaysia, Singapore, Taiwan, Japan.