Connor Shade

Hugo Setup

Published 29.07.2023 , Last Edited 01.08.2023

My deployment is now (almost) entirely automated. I write Markdown files in one repo, push the changes, and my site in another repo is automatically rebuilt - changes appear to my website about a minute after my push.

Repo structure

I have two GitHub repositories I’m using for this blog:

With this workflow I am able to keep private any drafts I want, running hugo will automatically build any changes, and with some light automation on GitHub Actions I should be able to build and deploy updates any time there is a push to cnnrshd/connorshade.com.

Theme

I’m using bear cub right now. It’s pretty light weight and doesn’t require npm to compile some HTML. I tried to use Gruvbox but the idea of installing nvm to install node to install npm to install >100 dependencies to compile a webpage is disgusting, despite how nice the page looks. I also like that bear cub is light weight (for HTML) - my webapp page is currently ~25kB, from a ~7.8kB source Markdown file, and most of the bloat seems to be styling on the code blocks.

Automation

Right now I have:

GitHub Actions Workflow

Here is the content of my GitHub Actions workflow:

 1on: 
 2  push:
 3  workflow_dispatch:
 4jobs:
 5  build:
 6    runs-on: ubuntu-latest
 7    permissions:
 8      contents: write
 9    steps:
10      - name: Checkout with submodules
11        uses: actions/checkout@v3
12        with:
13          submodules: 'recursive'
14          fetch-depth: 0
15          token: ${{ secrets.WEBSITE_TOKEN }}
16      - name: List the files in the repository
17        run: |
18          ls -R          
19      - name: Download and Install Hugo
20        run: |
21          wget "https://github.com/gohugoio/hugo/releases/download/v0.116.1/hugo_extended_0.116.1_linux-amd64.deb" -O hugo.deb
22          sudo dpkg -i hugo.deb          
23      - name: Checkout master in the submodule
24        run: |
25          cd public
26          git checkout master          
27      - name: Delete everything in the public folder # Prevent errors from old files
28        run: |
29          rm -rf public/*          
30      - name: Build the website # this should write all changes to the public folder
31        run: |
32          hugo          
33      - name: Ensure the CNAME file is in the public folder
34        run: |
35          echo "connorshade.com" > public/CNAME          
36      - name: Commit and push changes to submodule
37        run: |
38          cd public
39          git config --global user.email "github-actions[bot]@users.noreply.github.com"
40          git config --global user.name "github-actions[bot]"
41          git add .
42          git commit -m "Automated submodule update"
43          git push origin master          
44      - name: Update the submodule reference in the main repository
45        run: |
46          git config --global user.email "github-actions[bot]@users.noreply.github.com"
47          git config --global user.name "github-actions[bot]"
48          git add public
49          git commit -m "Update submodule reference"
50          git push          

Most of that should be pretty self-explanatory. There is room for improvements:

Prev: Intro Post