I’ve been thinking about starting a blog for years, but always got caught in analysis paralysis deciding where and how to do it. I finally put some time into making decisions and actually putting something of my own together while participating in Recurse Center. As a high-level goal, I wanted a simple way to turn Markdown on my computer into a website and blog.
Initially I thought writing my own static site generator could be an enjoyable project, but after scoping out what the project would consist of, I realized it would be a distraction from many other goals like writing words and learning Rust with others and learning about machine learning.
Instead I decided on using a popular static site generator, Hugo, and to host it on Github Pages where I’d already moved my homepage from my university’s computer club earlier in the year. I spent a bit of time learning how to use GitHub Actions, one of which had already been written for Hugo.
The final workflow for blogging should be simply writing a markdown file, commiting it, and pushing it to GitHub to make it appear on this blog.
Here’s the GitHub actions config to accomplish this:
name: Publish blog to akgerber.github.io/blog
on:
push:
branches:
- main # Set a branch name to trigger deployment
pull_request:
jobs:
deploy:
runs-on: ubuntu-22.04
permissions:
contents: write
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
steps:
- uses: actions/checkout@v3
with:
submodules: true # Fetch Hugo themes (true OR recursive)
fetch-depth: 0 # Fetch all history for .GitInfo and .Lastmod
- name: Setup Hugo
uses: peaceiris/actions-hugo@v2
with:
hugo-version: '0.113.0'
- name: Build
run: hugo --minify
- name: Deploy
uses: peaceiris/actions-gh-pages@v3
# If you're changing the branch from main,
# also change the `main` in `refs/heads/main`
# below accordingly.
if: github.ref == 'refs/heads/main'
with:
personal_token: ${{ secrets.BLOG_PUBLISH_TOKEN }}
external_repository: akgerber/akgerber.github.io
publish_dir: ./public
publish_branch: main
destination_dir: blog