Skip to main content
  1. Blog/

How this site was created

4 mins
Azure Hugo Static Web App GitHub
Mark D. Hughes
Author
Mark D. Hughes
Microsoft Cloud Consultant/Architect | Microsoft Certified Trainer | Microsoft Azure & 365 Certified Expert
Table of Contents
Discover how to create your very own blog just like this one.

This site was built using Hugo and is hosted using a static web application in Microsoft Azure. There are associated GitHub actions which control how the site is built and published.

It uses the Blowfish theme created by Nuno Coração which available from here and follows the Microsoft Learn guide available from here.

If you’d like to build something similar you can follow the below steps. My guide is based on using Windows and the site name Example Site. If you are using a different operating system some commands may differ and you can use your own site name.

Prerequisites
#

Create a Hugo application
#

  1. In order to create a similar site you must first install Hugo. To install Hugo on Windows simply open up a Command Prompt and run the following and agree to the terms.
winget install Hugo.Hugo.Extended
  1. You also need Git installing. To install this run the following in a command prompt also.
winget install --id Git.Git -e --source winget
  1. Once both of these are installed, restart command prompt and run the Hugo CLI within your chosen directory to create a new site.
hugo new site "Example Site"
  1. Change directory into the newly created site.
cd "Example Site"
  1. Initialize a Git repository for the new site.
git init
  1. Next create a main branch.
git branch -M main
  1. Then add the Blowfish theme to the site by installing the theme as a git submodule.
git submodule add https://github.com/nunocoracao/blowfish themes/blowfish
  1. Now apply the example site to give the new site some content.
xcopy themes\blowfish\exampleSite\* .\ /s /y
  1. Next configure git (replace with your GitHub email) and commit the changes to the main branch
git add -A
git config --global user.email "you@example.com"
git commit -m "initial commit"
  1. Finally preview the example site by running the following and then browsing to http://localhost:1313/ or the site shown if different.
hugo server

Example Site running locally
Example Site running locally

Publish to GitHub
#

A GitHub repository is neeced to connect to Azure Static Web Apps.

  1. Create a blank GitHub repo (don’t create a README) here named example-site.
  2. Add the GitHub repository as a remote to your local repo. Replace <YOUR_USER_NAME> with your GitHub username.
git remote add origin https://github.com/<YOUR_USER_NAME>/example-site
  1. Then push your local repo up to GitHub.
git push --set-upstream origin main

Your site now in GitHub
Your site now in GitHub

Deploy your web app
#

The following steps show you how to create a new static site app and deploy it to a production environment.

Create the application
#

  1. Go to the Azure Portal.
  2. Select Create a Resource.
  3. Search for Static Web App.
  4. Select Static Web App.
  5. Select Create.
  6. On the Basics tab, enter the following values.
Property Value
Subscription Your Azure subscription name.
Resource group example-group (create a new one)
Name example-site
Plan type Free
Source GitHub
  1. Select Sign in with GitHub and authenticate with GitHub.
  2. Enter the following GitHub values.
Property Value
Organization Select your desired GitHub organization.
Repository Select example-site.
Branch Select main.
  1. In the Build Details section, select Hugo from the Build Presets drop-down and keep the default values.
  2. Click next and on the Advanced tab select the region closest to you.

Create your new web app
Create your new web app

Review your web app
#

  1. Select Review + Create to verify the details are all correct.
  2. Select Create to start the creation of the App Service Static Web App and provision a GitHub Actions for deployment.
  3. Once the deployment completes, select Go to resource.

Review your new web app
Review your new web app

Update your web app
#

  1. In order for the Blowfish theme to work you will need to update the URL within the themes config file. On the resource screen, copy the URL link to your deployed application.
  2. Within the /config/_default/config.toml file update the baseURL with the copied URL.
  3. Commit and push the changes to GitHub which will automatically run the GitHub action to update the site.

Update your url
Update your url

Review GitHub action
Review GitHub action

Confirm your deployment
#

  1. Wait a minute or two for the GitHub Actions to complete.
  2. Navigate to your web applications URL to confirm deployment

Your fully deployed web app running in Azure
Your fully deployed web app running in Azure

Conclusion
#

This will provide you with an Azure static web app similar to mine with the Blowfish theme applied. From here you can add a custom domain and further customise the site.