Hugo Blogging - Deployment Automation

This post is one of several in the “Hugo Blogging” series. If you haven’t, read the introduction to get started.

Since we are already using GitHub, let’s use GitHub Actions for the automation. Once set up, GitHub Actions will automatically build and deploy the site any time a change is detected.

Instructions

GitHub

  1. Go to your repository on GitHub. Click the “Actions” tab.

  2. Click “New workflow” (top left).

  3. Look for the option to “Skip this step and set up a workflow yourself”.

  4. Name the workflow gh-pages.yml.

  5. Write the workflow here. You can use this example workflow as a template.

If you use the example, make sure the branch names are consistent with your repository. For example, I changed all instances of main to master.

  1. Click “Start commit” (top right). Click “Commit new file”.

  2. Go to your repository “Settings”.

  3. Choose “Options” on the left. Find the “GitHub Pages” settings.

  4. Set the branch to gh-pages.

  5. Set the folder to /(root).


Usage

Simply push your work to the repository. In a few moments, the site will be deployed to the gh-pages branch.


179 Words

2021-02-07 01:07 +0000