Local setup
This option gives you a full local working environment in which you can preview all changes in the browser as you write. Recommended for structural changes, larger amounts of new content, or technical development.
What You Need
| Tool | Version | Purpose |
|---|---|---|
| Git | Latest stable | Version control |
| Hugo Extended | 0.155.3 or later | Site generator |
| Go | 1.21 or later | Required by Hugo Modules |
| Text editor | – | VS Code recommended |
Installation on Windows
winget install --id Git.Git
winget install --id Hugo.Hugo.Extended
winget install --id GoLang.Go
winget install --id Microsoft.VisualStudioCode
Restart the terminal afterwards so that the newly installed programmes are available in PATH.
Verify the installation:
git --version
hugo version
go version
Installation on macOS
brew install git hugo go
Installation on Linux (Ubuntu/Debian)
sudo apt install git golang
# Hugo Extended is obtained from GitHub Releases (the apt version is often too old):
wget https://github.com/gohugoio/hugo/releases/download/v0.155.3/hugo_extended_0.155.3_linux-amd64.deb
sudo dpkg -i hugo_extended_0.155.3_linux-amd64.deb
Content structure – multiple repositories
SAMT-BU Docs uses content modules: content from different teams and pilots lives in separate GitHub repositories and is mounted automatically into the site at publication time.
| Repository | Content | Mounted under |
|---|---|---|
samt-bu-docs | Main documentation, configuration | (root) |
samt-bu-pilot-1 | Pilot 1 | pilotering/pilot-1/ |
samt-bu-pilot-2 | Pilot 2 | pilotering/pilot-2/ |
samt-bu-pilot-3 | Pilot 3 | pilotering/pilot-3/ |
samt-bu-pilot-4 | Pilot 4 | pilotering/pilot-4/ |
team-architecture | High-level architecture | arkitektur/overordnet-arkitektur/ |
team-semantics | Information architecture | arkitektur/informasjonsarkitektur/ |
samt-bu-drafts | Drafts and inputs | utkast/ |
solution-samt-bu-docs | Technical documentation | prosjektleveranser/… |
Scenario A – Preview the full site only
git clone --recurse-submodules https://github.com/SAMT-X/samt-bu-docs.git
cd samt-bu-docs
hugo server
Open http://localhost:1313/ in the browser.
Scenario B – Edit content in one specific repository
git clone https://github.com/SAMT-X/samt-bu-pilot-2.git
cd samt-bu-pilot-2
# edit files in content/
git add .
git commit -m "Description of the change"
git push
The site updates automatically within about one minute.
Scenario C – Full local development across all repositories
git clone --recurse-submodules https://github.com/SAMT-X/samt-bu-docs.git
git clone https://github.com/SAMT-X/samt-bu-pilot-1.git
# ... and so on for the modules you want to work with
cd samt-bu-docs
tools/hugo-local.sh
The script finds local clones automatically and starts Hugo with them. Modules you have not cloned are fetched from GitHub.
samt-bu-docs/ ← always clone this one
samt-bu-pilot-1/ ← clone the ones you want to edit
...
Including drafts:
tools/hugo-local.sh --drafts
Writing Content
---
title: "Page title"
weight: 30
---
Your content begins here in standard Markdown.
title– page title displayed in the menu and at the top of the pageweight– sort order (lower number = higher in the menu)draft: true– hides the page from publication until it is ready
Saving and Publishing Changes
git add content/path/to/file/_index.en.md
git commit -m "Brief description of what you changed"
git pull --rebase
git push
GitHub Actions builds and publishes automatically after 1–2 minutes.
No write access? Create a branch and pull request:
git checkout -b my-contribution→ make changes →git push origin my-contribution→ open a PR on GitHub.
Useful Commands
| Command | Description |
|---|---|
tools/hugo-local.sh | Start local server with automatic module substitution |
tools/hugo-local.sh --drafts | Include drafts as well |
hugo server | Start local server (fetches modules from GitHub) |
hugo | Build to public/ (check for errors) |
git pull --rebase | Fetch latest changes and rebase |
Synchronisation and Conflict Handling
When several contributors work at the same time – or when someone saves a change via the browser interface while you have a local copy – the repositories can fall out of sync.
The Helper Scripts
There are three scripts in the root folder for your local clones:
| Script | Function |
|---|---|
pull-all.sh / .bat | Fetches the latest changes from GitHub for all repositories |
push-all.sh / .bat | Pushes unpushed local commits to GitHub |
sync-all.sh / .bat | Combined: fetches, merges, and pushes in the correct order |
Recommended workflow:
Before you start: sync-all
While working: commit frequently → push-all
When you are done: sync-all
What sync-all Does
| Situation | Action |
|---|---|
| Same locally and on GitHub | Nothing |
| Only GitHub ahead | git pull (fast-forward) |
| Only you ahead | git push |
| Both have new commits | Rebase |
| Uncommitted changes | Stash → sync → stash pop |
| Unresolvable conflict | Stop, report, no data lost |
Manual Conflict Resolution
cd "<path to repo>"
git pull --rebase
# Open the file and look for conflict markers:
# <<<<<<< HEAD ← your version
# =======
# >>>>>>> abc1234 ← remote
# Delete the markers, keep the correct content.
git add <filename>
git rebase --continue
git push
go.mod / go.sum Conflicts
git pull --rebase
git checkout --theirs go.mod go.sum
hugo mod tidy
git add go.mod go.sum
git rebase --continue
git push
UUID Workflow and Rejected Pushes
GitHub Actions automatically commits UUID fields after pushing new files. If you push twice in quick succession:
git pull --rebase && git push
Prevention:
git add <files> && git commit -m "..." && git pull --rebase && git push