Personal website and blog at balharrie.uk, built with Hugo and the Stack theme.
This repo uses a Nix flake to provide a reproducible development environment.
- Nix with flakes enabled, or NixOS
Enter the dev environment:
nix developStart the local dev server (includes draft posts):
just devThen visit http://localhost:1313.
nix buildThe output is written to result/.
-
In your GitHub repo, go to Settings → Pages and set the source to GitHub Actions.
-
Create
.github/workflows/deploy.ymlwith the following:
name: Deploy to GitHub Pages
on:
push:
branches: [main]
jobs:
deploy:
runs-on: ubuntu-latest
permissions:
contents: read
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: true
- uses: cachix/install-nix-action@v27
with:
nix_path: nixpkgs=channel:nixos-unstable
extra_nix_config: |
experimental-features = nix-command flakes
- name: Build
run: nix build
- uses: actions/upload-pages-artifact@v3
with:
path: result/
- uses: actions/deploy-pages@v4
id: deploymentEvery push to main will build and deploy automatically.
Build the site and deploy to the gh-pages branch in one step using the justfile:
just deployOr manually:
nix build
git checkout --orphan gh-pages
git rm -rf .
cp -r result/. .
git add .
git commit -m "Deploy"
git push origin gh-pages --forceThen in Settings → Pages, set the source to the gh-pages branch, root folder.