Local setup

Last modified: 2026-11-02 21:35by Erik Hagen ID: e26cb201-0841-46b2-8ac7-2ba3708edde6 SAMT-X/solution-samt-bu-docs

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

ToolVersionPurpose
GitLatest stableVersion control
Hugo Extended0.155.3 or laterSite generator
Go1.21 or laterRequired 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.

RepositoryContentMounted under
samt-bu-docsMain documentation, configuration(root)
samt-bu-pilot-1Pilot 1pilotering/pilot-1/
samt-bu-pilot-2Pilot 2pilotering/pilot-2/
samt-bu-pilot-3Pilot 3pilotering/pilot-3/
samt-bu-pilot-4Pilot 4pilotering/pilot-4/
team-architectureHigh-level architecturearkitektur/overordnet-arkitektur/
team-semanticsInformation architecturearkitektur/informasjonsarkitektur/
samt-bu-draftsDrafts and inputsutkast/
solution-samt-bu-docsTechnical documentationprosjektleveranser/…

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 page
  • weight – 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

CommandDescription
tools/hugo-local.shStart local server with automatic module substitution
tools/hugo-local.sh --draftsInclude drafts as well
hugo serverStart local server (fetches modules from GitHub)
hugoBuild to public/ (check for errors)
git pull --rebaseFetch 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:

ScriptFunction
pull-all.sh / .batFetches the latest changes from GitHub for all repositories
push-all.sh / .batPushes unpushed local commits to GitHub
sync-all.sh / .batCombined: 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

SituationAction
Same locally and on GitHubNothing
Only GitHub aheadgit pull (fast-forward)
Only you aheadgit push
Both have new commitsRebase
Uncommitted changesStash → sync → stash pop
Unresolvable conflictStop, 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