Tutorial for deploying a Hugo site to Github pages using Github Actions. Focus on content creation, not deployment.
Table Of Contents
Step 0: Follow Hugo Quick Start
This post assumes you already followed the Hugo quick start guide, which you can find here.
Step 1: Commit Blog Source to Github
Create a new repository on Github here.
Push your local repository to Github
|
|
- Create and push a branch called
gh-pages
- this is where the generated page will be deployed to.
|
|
Step 2: Enable Github Pages
- Go to your repository settings
- Navigate to the “Code and automation” section
- Click the “Pages” button
- Click the “Branch” button and select “gh-pages”
- Hit save
- Go to
https://YOUR_USERNAME/YOUR_REPONAME
. You should see your README.
Step 3: Deploy Hugo Site with Github Actions
Put this file at .github/workflows/gh-pages.yml
:
|
|
Commit the change.
Step 4: Verify Everything is Working
- Wait a few minutes
- Go to
https://YOUR_USERNAME/YOUR_REPONAME
(or your custom domain) - Your site should be there with new changes.
- Go into incognito mode or open a new browser if nothing has changed (it’s possible your browser is returning a cached result)