Updating Hugo Blox Websites
Keep your Hugo Blox website current with new features, fixes, and enhancements by updating Hugo, Go, and Hugo Blox modules. Regular updates ensure compatibility and leverage improvements like better blocks or styling. This guide outlines a Git-based workflow to test changes safely before deployment.
Before You Begin: Back Up Your Site
Always back up your site directory before updating to protect your content and config. For instance, cp -r site site.bak makes an exact copy of the site directory and all its contents and names the copy site.bak. Here’s the process in practical terms, assuming you’re working on a system like Linux, macOS, or Windows with a Unix-like terminal (e.g., Git Bash):
-
Open Your Terminal:
- On Linux or macOS, just open the Terminal app.
- On Windows, you might use something like Git Bash, WSL (Windows Subsystem for Linux), or PowerShell with a Unix emulator installed.
-
Navigate to the Right Location:
-
Use the
cdcommand to move to the directory that contains yoursitefolder. For example, if your website files are in/home/user/projects/site, type:cd /home/user/projects -
You can check you’re in the right place by typing
ls(ordiron some Windows setups) to see ifsiteis listed.
-
-
Run the Command:
- Type
cp -r site site.bakand press Enter. - If
siteexists, the system will create a new directory calledsite.bakin the same location and copy everything fromsiteinto it.
- Type
-
Verify the Backup:
-
After the command finishes, you can check that site.bak exists and contains the same files as site. Use ls (or dir) to see the new directory, or explore it manually:
ls -l -
You could also compare the contents with a tool like diff if you want to be extra sure:
diff -r site site.bak
(If there’s no output, they’re identical.)
-
-
Things to Keep in Mind:
- Permissions: You need write access to the directory where you’re creating
site.bak. If you get a “permission denied” error, you might need to run the command withsudo(e.g.,sudo cp -r site site.bak) or adjust permissions. - Existing Destination: If
site.bakalready exists,cp -rwill copysiteintosite.bakrather than overwriting it, unless you force an overwrite with the-fflag (cp -rf site site.bak). Be cautious—overwriting could erase an older backup. - Space: Make sure you have enough disk space for the duplicate. If
siteis large,site.bakwill take up just as much room. - Naming:
.bakis just a convention to indicate a backup. You could name it anything, likesite_backup_2025orsite_copy.
- Permissions: You need write access to the directory where you’re creating
Choosing Your Update Approach
Two mindsets exist for keeping Hugo Blox current, each suited to different goals. Choose based on whether you prioritize content or new features.
Hugo Blox Release-Driven Approach
- When to Update: Update only when a new Hugo Blox template releases (e.g., a new
blox-bootstrapversion ingo.mod). These may align with Hugo updates but often don’t, as Hugo Blox updates independently. - Process: Follow the steps below per Hugo Blox release, applying all breaking changes since your last update (from Hugo Blox and Hugo).
- Pros:
- Fewer updates, more focus on content.
- Updates only when Hugo Blox requires it, avoiding extra work if features aren’t needed.
- Cons:
- More breaking changes at once, spanning multiple updates, harder to fix if docs lag.
- Best For: Users focused on content over features, waiting for Hugo Blox releases.
Incremental Hugo-Driven Approach
- When to Update: Update often, with Hugo releases (e.g., monthly, like 0.140.0 to 0.141.0), refreshing Hugo Blox modules as needed.
- Process: Follow the steps per Hugo update, fixing smaller breaking changes over time.
- Pros:
- Smaller, manageable changes per update.
- Early access to Hugo and Hugo Blox advancements, less hunting for issues.
- Cons:
- More frequent updates, possibly disrupting content work.
- Check Hugo Blox compatibility per Hugo version, even without new releases.
- Best For: Users wanting early Hugo and Hugo Blox features, spreading out fixes.
Which Should You Choose?
- Content Focus: If content is key and you don’t need advancements until a Hugo Blox release, use the Release-Driven Approach for less disruption.
- Feature Focus: If you want Hugo and Hugo Blox enhancements sooner with fewer fixes per update, use the Incremental Approach for a current site.
Both use the same steps below—your choice sets the frequency. Check Hugo Releases and Hugo Blox GitHub to monitor updates and decide.
Step 1: Prepare Your Website
Preparation ensures a smooth update and a baseline for testing.
Record Current Versions
Document your starting point to track changes and revert if needed:
- Hugo: Run
hugo version(Homebrew) or./bin/hugo version(local) to note the version (e.g.,v0.140.0+extended). - Go: Run
go version(e.g.,go1.24.0 darwin/amd64). - Hugo Blox Modules: Open
go.modin your site’s root with VS Code or a text editor. Checkrequirestatements (e.g.,github.com/HugoBlox/hugo-blox-builder/modules/blox-bootstrap/v5.9.6). Note versions (e.g.,v5.9.6) or dev builds (e.g.,v0.0.0-20231123212609-31fc15e5b205—cross-reference hashes like31fc15ein the Hugo Blox GitHub commit log).
Create a Local Hugo Binary (Optional, Recommended for Testing)
To test new Hugo versions without affecting your system-wide install:
-
In your site’s root (e.g.,
/path/to/your/site), create abinfolder:mkdir bin -
Download the latest Hugo Extended from Hugo Releases (e.g.,
hugo_extended_0.140.0_darwin-amd64.tar.gzfor macOS Big Sur, Intel). -
Extract and move:
tar -xzf hugo_extended_0.140.0_darwin-amd64.tar.gz mv hugo ./bin/hugo -
Verify:
./bin/hugo version.
Why? A local ./bin/hugo isolates tests, useful as Hugo updates often (e.g., weekly or monthly vs. Go’s less regular updates).
Update .gitignore
Keep the local binary out of Git:
-
Edit or create
.gitignorein your site’s root:/bin/ -
Commit in VS Code:
- Open Source Control (Ctrl+Shift+G or Git icon).
- Stage
.gitignore(click+). - Commit (message: “Ignore local Hugo binary”) and push to GitHub.
Test Your Current Site
Confirm everything works pre-update:
- Run:
hugo server(Homebrew) or./bin/hugo server(local). - Open
http://localhost:1313in a browser and check functionality (e.g., pages, Hugo Blox blocks load correctly).
Step 2: Update Hugo and Go
Hugo Blox evolves with Hugo, and Hugo uses Go for modules, so updating both ensures compatibility. Hugo updates often (e.g., monthly), while Go updates less (e.g., twice yearly) and should align with Hugo needs.
Create a Test Git Branch
Before updating Hugo and Go, isolate your changes in a Git branch tied to a GitHub Issue:
- In VS Code: Click the branch name in the status bar (e.g.,
main) > “Create new branch” > name itchore-123-hugo-update(e.g., for GitHub Issue #123: “Update Hugo to 0.141.0”). - Why This Name? We use
type-issue#-description(e.g.,feature-123-hugo-update) to link branches to GitHub Issues tracking updates like Hugo/Go changes. Issues manage todos, dates are tracked by Git, and the prefix clarifies purpose (e.g.,featurefor new updates). - Feature/Issue-Based Naming Convention:
- Format: type-issue#-description
- Structure: type/description or type-issue#-description
- Type: A prefix indicating the purpose of the branch (e.g., feature, bug, hotfix, chore, docs).
- Issue# (Optional): A reference to a specific issue or ticket number from a tracking system (e.g., GitHub Issues), if applicable.
- Description: A concise, hyphen-separated summary of the work (e.g., hugo-update, module-compat).
- Examples:
feature/hugo-update(general feature work)feature-123-hugo-update(tied to GitHub Issue #123)bug/module-compat(fixing a module compatibility issue)hotfix/urgent-deploy(quick deployment fix)
- Format: type-issue#-description
- Core Principles
- Clarity: The type immediately signals the branch’s intent (e.g., new feature vs. bug fix), while the description provides context.
- Consistency: Standardized prefixes ensure branches are easily categorized and sorted (e.g., all feature/ branches group together).
- Integration with Tools: Adding an issue# links directly to issue trackers (e.g., GitHub auto-links #123 in commit messages or PRs).
- Scalability: Works well for solo projects and scales seamlessly to teams with ticketing systems.
- How It Leverages Git’s Date/Time Tracking
-
Commit Metadata: Git records the creation date and time of each commit (
git log --pretty=fullershowsAuthorDateandCommitDate), and branches inherit the timeline of their commits. For example:git log --pretty=fuller commit 7a8b9c0... AuthorDate: Mon Feb 24 12:34:56 2025 -0500 CommitDate: Mon Feb 24 12:34:56 2025 -0500 -
GitHub Insights: On GitHub, the branch list (e.g., under “Branches” tab) shows the last commit date, and PRs display commit timestamps, making manual date prefixes redundant.
-
GitLens: VS Code’s GitLens extension shows commit dates in the timeline, making date prefixes unnecessary.
-
Why Prefixes Over Dates? Git’s built-in date tracking (e.g.,
git log, GitHub) makes manual date prefixes redundant, focusing on purpose (e.g., feature, bug) for clarity and consistency.
-
- Best Practices Within This Convention
- Use Descriptive Types: Stick to common prefixes:
feature(new stuff),bug(fixes),hotfix(urgent fixes),chore(maintenance),docs(documentation). - Keep Descriptions Short: Use 2-4 words, hyphen-separated (e.g., hugo-update, module-compat-fix).
- Incorporate Issue Numbers: If using GitHub Issues (even solo), add the ticket number (e.g.,
feature-123-hugo-update) for linking. - Avoid Ambiguity: Be specific (e.g.,
feature/hugo-141-updatevs.feature/hugo-update) if multiple updates occur. - Delete Merged Branches: Once merged or abandoned, delete branches (
git branch -d feature/hugo-update) to avoid clutter, relying on commit history.
- Use Descriptive Types: Stick to common prefixes:
Option 1: Update Local Hugo Binary (Recommended for Testing Hugo Updates)
-
Download New Hugo Version:
- Visit Hugo Releases and download the latest Extended version (e.g.,
hugo_extended_0.141.0_darwin-amd64.tar.gz). - Extract and replace:
mv hugo ./bin/hugo. - Verify:
./bin/hugo version.
- Visit Hugo Releases and download the latest Extended version (e.g.,
-
Update Go (If Required):
- Check the Release Notes for Hugo for your new version (e.g., 0.141.0).
- If notes indicate a Go update (e.g., minimum version rise or fixes), upgrade Go via Homebrew:
- Check current:
go version(e.g.,go1.24.0 darwin/amd64). - Update:
brew upgrade go. - Verify:
go version(e.g.,go1.25.0 darwin/amd64). - Specific Go Version (If Needed): If Hugo needs a specific Go (e.g., 1.25.0) not latest in Homebrew:
- Check versions:
brew search go(listsgo,go@1.24, etc.). - Install:
brew install go@1.25.0(if available;@may not cover latest). - Link (if keg-only):
brew link --overwrite go@1.25.0(may needbrew unlink gofirst). - If unavailable, see Option 2 methods.
- Check versions:
- Check current:
- If no Go update is noted, Hugo upgrades suffice—for instance, recent Hugo aligns with Go 1.24.0+.
-
Test:
- Run
./bin/hugo serverand checkhttp://localhost:1313for errors or breaking changes.
- Run
Why Local Hugo? A local ./bin/hugo simplifies version swaps vs. Homebrew, where specific downgrades are tricky—requiring manual steps. Replace ./bin/hugo easily from Hugo’s site. Upgrade frequency is the same; it’s about control.
Option 2: Update via Homebrew (Recommended after Testing Hugo Updates)
-
Update Hugo:
-
Run:
brew upgrade hugo -
Verify:
hugo version.
-
-
Update Go (If Required):
- Check the Release Notes for Hugo for your new version.
- If a Go update is needed:
- Check:
go version. - Update:
brew upgrade go. - Verify:
go version.
- Check:
-
Specific Go Version (If Needed): If Hugo needs a specific Go (e.g., 1.25.0) not latest:
- Method 1: Switch:
brew list --versions go(e.g.,go 1.24.0 1.25.0);brew switch go 1.25.0(if cached). - Method 2: Check:
brew search go(e.g.,go@1.24); Install:brew install go@1.25.0; Unlink:brew unlink go; Link:brew link --overwrite go@1.25.0. - Method 3: Tap:
brew tap homebrew/cask-versionsorbrew tap homebrew/core; Search:brew search go; Install:brew install go@1.25.0. - Method 4: Find commit at Homebrew Core; Extract:
brew extract --version=1.25.0 go my-tap/go; Install:brew install my-tap/go/go@1.25.0. - Fallback: Download from golang.org/dl (e.g.,
go1.25.0_darwin-amd64.tar.gz), extract, use locally (see Local Go Testing).
- Method 1: Switch:
-
Verify:
go versionmatches the needed version. -
If no Go update is noted, skip—existing Go is fine.
-
Test:
- Run:
hugo serverand checkhttp://localhost:1313for errors or breaking changes.
- Run:
Best Practice: Use a local ./bin/hugo (Option 1) in a test branch for frequent Hugo updates to keep Homebrew stable. Update via Homebrew (Option 2) when specific versions are required per Hugo notes—version management can be complex.
Local Go Testing (Rare): For specific Go tests (e.g., Hugo needs per release notes), download (e.g., go1.25.0_darwin-amd64.tar.gz from golang.org/dl), extract (tar -xzf go1.25.0_darwin-amd64.tar.gz), move (mv go ./go), use (./go/bin/go mod tidy), edit .gitignore with /go/ or delete the go folder after completed testing. PATH will need to be set for that terminal session with export PATH=$PATH:/path/to/your/site/go/bin (e.g., export PATH=$PWD/go/bin:$PATH). Killing the terminal session will reset the PATH to its previous configuration when testing is complete. Verify: ./go/bin/go version.
Step 3: Update Your Modules
Hugo Blox uses modules in go.mod. Updating them adds features and fixes.
Edit go.mod
-
Open
go.modin your site’s root with VS Code or a text editor. -
Check current versions (e.g.,
github.com/HugoBlox/hugo-blox-builder/modules/blox-bootstrap/v5). -
Update to specific versions or latest:
- TL;DR Quick Update: Use
mainfor dev versions (e.g.,github.com/HugoBlox/hugo-blox-builder/modules/blox-bootstrap main). Caution:mainmay be unstable; check commit logs if prior dev builds were used. - Specific Version (Recommended): Use tagged releases (e.g.,
v5.9.6from Hugo Blox GitHub “Releases” or module subdirs likemodules/blox-bootstrap).
- TL;DR Quick Update: Use
-
Example:
require ( github.com/HugoBlox/hugo-blox-builder/modules/blox-bootstrap/v5.9.6 github.com/HugoBlox/hugo-blox-builder/modules/blox-tailwind main )
Update Modules
- In your test branch (
feature-123-hugo-update): - Run:
go mod tidy(uses Homebrew’s Go or./go/bin/goif local, cleansgo.modandgo.sum). - Optional:
hugo mod vendor(downloads modules to_vendor/for offline use). - Test:
./bin/hugo serverorhugo server.
Tip: If module URLs changed (e.g., github.com/wowchemy/ to github.com/HugoBlox/), update hugo.yaml or module.yaml imports (check a fresh Hugo Blox template’s go.mod).
Step 4: Apply Any Breaking Changes
Updates to Hugo or Hugo Blox modules may need manual fixes.
Review Release Notes
- Hugo Blox Release Notes: Check changes since your
go.modversion. - Hugo Release Notes: Note Hugo updates (e.g., syntax) and Go needs.
Update Configuration
- Edit
config/_default/files (e.g.,hugo.yaml,params.yaml) for new or renamed params. - Example: A module might swap
themeforappearance—adjust it.
Update Content
- Fix front matter in
content/*.mdif fields change (e.g.,dateformat).
Test Again
- Run
./bin/hugo serverand verify all pages and features (e.g., blocks, styling) work.
Best Practice: Compare with a fresh Hugo Blox template (e.g., Academic) for config or layout diffs. Check overridden files (e.g., layouts/) for conflicts.
Step 5: Test Locally
Test your updated site in the test branch:
- Build:
./bin/hugo(orhugo). - Serve:
./bin/hugo server(orhugo server). - Check:
- Browser:
http://localhost:1313—ensure content renders right. - Terminal: Look for errors (e.g., missing partials, module issues).
- Browser:
Step 6: Deploy Your Website
Decide to deploy or revert based on test results.
If the Update is Successful
-
Switch to Main Branch:
- In VS Code, check the status bar (bottom-left). It shows
feature-123-hugo-update. - Click
feature-123-hugo-update> pickmain. This returns to your stable version.
- In VS Code, check the status bar (bottom-left). It shows
-
Merge Changes:
- Go to Source Control (Git icon or Ctrl+Shift+G).
- Click
...(More Actions) at top-right. - Choose “Branch” > “Merge Branch.”
- Pick
feature-123-hugo-updateand click it. This merges changes intomain. - If “Conflicts” appear, open files (e.g.,
go.mod), fix overlaps, click+to stage, and checkmark to commit.
-
Push to GitHub:
- In Source Control, click
...> “Push” (or click the cloud icon with an up arrow in the status bar). - This updates
mainon GitHub.
- In Source Control, click
If the Update is Unsuccessful (Site Fails to Build)
If the new Hugo, Go, modules, or changes fail (e.g., blank pages, “template not found” errors):
-
Check the Problem:
- Check terminal output from
./bin/hugoor./bin/hugo server. Note errors (e.g., “module not found”). - Visit
http://localhost:1313—if broken or missing content, it failed.
- Check terminal output from
-
Switch Back to Main Branch:
- In VS Code, status bar shows
feature-123-hugo-update. - Click
feature-123-hugo-update> pickmain. This reverts to your working site. - Files (e.g.,
go.mod,hugo.yaml) return to their original state asmainis unchanged.
- In VS Code, status bar shows
-
Discard Changes in Test Branch:
- Go to Source Control (Git icon or Ctrl+Shift+G).
- Click
...> “Branch” > “Delete Branch.” - Pick
feature-123-hugo-updateand click it. - If asked “Are you sure?” click “Yes” (or “Delete”). This drops the branch and its changes (e.g.,
go.modedits).
-
Revert the Hugo and Go Versions:
- If Local Hugo Binary:
- If
./bin/hugoupdated (e.g., 0.141.0) and you want the old (e.g., 0.140.0):- Download from Hugo Releases (e.g.,
hugo_extended_0.140.0_darwin-amd64.tar.gz). - Extract:
tar -xzf hugo_extended_0.140.0_darwin-amd64.tar.gz. - Replace:
mv hugo ./bin/hugo. - Verify:
./bin/hugo versionmatches (e.g.,0.140.0).
- Download from Hugo Releases (e.g.,
- Since
./bin/is ignored by Git, this is local only. - If Homebrew Hugo:
- Check:
brew list --versions hugo(e.g.,hugo 0.140.0 0.141.0). - Method 1: Switch:
brew switch hugo 0.140.0(if cached). - Method 2: Check:
brew search hugo; Install:brew install hugo@0.140.0; Unlink:brew unlink hugo; Link:brew link --overwrite hugo@0.140.0. - Method 3: Tap:
brew tap homebrew/cask-versionsorbrew tap homebrew/core; Search:brew search hugo; Install:brew install hugo@0.140.0. - Method 4: Find commit at Homebrew Core; Extract:
brew extract --version=0.140.0 hugo my-tap/hugo; Install:brew install my-tap/hugo/hugo@0.140.0. - Fallback: Download from Hugo, extract, use as
./bin/hugo. - Verify:
hugo versionmatches (e.g.,0.140.0).
- Check:
- If Go Updated:
- Check:
brew list --versions go(e.g.,go 1.24.0 1.25.0). - Method 1: Switch:
brew switch go 1.24.0(if cached). - Method 2: Check:
brew search go; Install:brew install go@1.24.0; Unlink:brew unlink go; Link:brew link --overwrite go@1.24.0. - Method 3: Tap:
brew tap homebrew/cask-versionsorbrew tap homebrew/core; Search:brew search go; Install:brew install go@1.24.0. - Method 4: Find commit at Homebrew Core; Extract:
brew extract --version=1.24.0 go my-tap/go; Install:brew install my-tap/go/go@1.24.0. - Fallback: Download from golang.org/dl (e.g.,
go1.24.0_darwin-amd64.tar.gz), extract, use as./go. - Verify:
go versionmatches (e.g.,1.24.0).
- Check:
-
Test the Original Site:
- Run
./bin/hugo server(local) orhugo server(Homebrew). - Check
http://localhost:1313to confirm your site works.
- Run
-
Plan Next Steps:
- Review failed test errors (e.g., terminal or browser).
- Check Hugo Blox or Hugo notes for fixes (e.g., dependencies, syntax).
- Start a new branch (e.g.,
feature-124-hugo-update) linked to a new GitHub Issue. - Why This Name? We use
feature-issue#-descriptionto tie branches to GitHub Issues tracking updates (e.g., Hugo/Go changes), leveraging Git’s date tracking and issue links for clarity. See Create a test Git branch for details.
Update Deployment Config
- After a successful merge (or keeping
main): - GitHub Pages: Edit
.github/workflows/publish.yaml, setWC_HUGO_VERSIONto your tested Hugo (e.g.,0.141.0—check Hugo Blox compat). - Netlify: Update
netlify.toml, setHUGO_VERSION(e.g.,0.141.0). - Deploy: Push to GitHub, monitor Actions > Deploy Site (check log if fails), or verify Netlify via Deploys tab. If you’ve properly tested the changes and updated your site, it should deploy without issues.
Why Branches?
feature-123-hugo-updatekeeps your main site safe.- Merge updates to
main - Delete and retry if it fails
- Linking to GitHub Issues
See Create a test Git branch for details.
Troubleshooting
Module Errors
- Run
hugo mod getor verifygo.modURLs. Clear cache:hugo --cacheDir ./cache/and delete./cache/.
VS Code Go Extension (gopls) Issues
-
If using a local
./go(e.g., for Go testing), exclude it: -
Edit
settings.json(Cmd+Shift+P > “Preferences: Open Settings (JSON)”):"files.exclude": { "**/go": true, "**/bin": true }, "go.toolsEnvVars": { "GOROOT": "/usr/local/Cellar/go/1.24.0/libexec" } -
Restart VS Code.
More Help
Best Practices
- Backup First: Copy your site folder (e.g.,
cp -r site site.bak). - Test in Branches: Use
feature-123-hugo-updateto isolate changes, linking to GitHub Issues. - Local Hugo Binary: Test Hugo updates with
./bin/hugofor flexibility. - Stick with Homebrew Go: Simplifies modules, update per Hugo notes.
- Track Versions: Note Hugo, Go, and module versions pre/post-update.
- Apply Sequentially: Update Hugo/Go, modules, configs, test each step.