Host a free blog site on Azure - Guide
Sat, May 15, 2021
2-minute read
Easily setup a site using Hugo static site generator. Automatically push changes from GitHub to Azure Static WebApps. Hosting is free while in preview.
Prerequisites
- Install Git
- Install Hugo (Use Chocolatey for Windows)
- Install Visual Studio Code
- Access to a custom domain name (optional)
1. Setup Local Website directory and install theme
- In Powershell type the following without quotes: Hugo new site “name of your site”
- Find a Hugo theme. I will be using Anatole.
- Install theme submodule: git submodule for theme. git submodule add https://github.com/lxndrblz/anatole.git themes/anatole
- Open Visual Studio: Code .
- Edit config.toml (See Hugo theme documentation for parameters)
- Test site locally: Hugo Server
- Navigate to 127.0.0.1:1313 in a browser
2. Setup Git
- Login into or create a GitHub account
- Create a new repo
- Copy the commands needed to connect to your repo (Make sure you are in the directory from step 1)
- Track all local files in the directory by typing: Git add .
- Commit changes and leave a tracking message: Git commit -m “Second Commit”
- Push changes to Repo: Git push
3. Setup Azure Static WebApp & and GitHub actions workflow
- Log into portal.azure.com
- Create Static WebApp and resource group
- Connect your GitHub account and select the main branch of your repo
- Select Hugo build preset and create. Azure will automatically upload the .yml files
- Check GitHub site for workflow logs under Actions tab
- Run Git pull to sync with your local machine
- Navigate to URL provided by Azure to view your live site 8 . Any changes you push using git will automatically update on your new site
4. Add Custom domain name (Optional)
- Login to your domain provider
- Add a CNAME record for www that points to your Azure URL
- And the custom domain to Azure and validate