I decided to update the Hugo theme beautifulhugo and started the work.
This repository managed the theme with Hugo Modules.
In short, hugo mod get -u did not reach the latest version because the import path lacked /v5, and once I moved to v5 I also had to move the site’s layout overrides to the new structure.
It did not update to the latest version
When I ran hugo mod get -u, it failed with the following error because the shallow clone in the module cache was broken.
fatal: shallow file has changed since we read it
After clearing the cache with hugo mod clean --all and running it again, the command succeeded, but go.mod showed no diff.
At that point I concluded that it was already up to date, but the release page showed that the latest version was v5.2.1, so that conclusion was wrong.go.mod pinned github.com/halogenica/beautifulhugo not to a tag but to the pseudo-version v0.0.0-20260706190448-b2d547f7a61c.
Checking the upstream tags with git ls-remote --tags showed that v5.2.1 exists, and the pinned commit b2d547f was not a descendant of v5.2.1.
The upstream go.mod declares module github.com/halogenica/beautifulhugo/v5.
In Go modules, tags from v2 onward are resolved only through a path that includes the major version, so running -u against the path without /v5 never moved off the old line.
Switching the import path to v5
I wrote the path with /v5 added to module.imports in hugo.toml and fetched v5.2.1 explicitly.
[[module.imports]]
path = "github.com/halogenica/beautifulhugo/v5"
hugo mod get github.com/halogenica/beautifulhugo/[email protected]
hugo mod tidy
Right after fetching, go.mod had two lines, the old path and /v5, but hugo mod tidy removed the old path and left only the following line.
require (
github.com/halogenica/beautifulhugo/v5 v5.2.1 // indirect
)
The build passed but the output changed
The hugo build succeeded, but compared with public/ from before the update, about 1,100 files differed.
Most of the differences seem to come from RSS timestamps and HTML formatting, but I have not checked every file.
Comparing individual pages turned up four visible changes.
- Heading anchor links no longer appeared.
- The “this page contains promotions” notice at the top of each post disappeared.
- The mermaid
<script>tags in the page disappeared. - “Home” changed to “ホーム”, and “Tags:” changed to “タグ:”.
The cause was that v5 changed where the theme’s layouts live.
The old layouts/_default/single.html and partials/ were reorganized in v5 into layouts/page.html, _partials/, _shortcodes/ and _markup/.
The _default/single.html I had left on the site side was no longer used as an override in v5, and the theme’s page.html took precedence.
Moving the layout overrides to the v5 structure
First I moved the overridden files to their new locations with git mv.
Leaving the old copies as they were would miss v5’s features, so I rebuilt each file based on the v5 version and re-applied only the site’s own changes.
What I re-applied included the body width, promotion notice and heading anchors in page.html, and the hreflang and noindex handling in head.html.
After the migration, the build warned that .Language.LanguageName was deprecated in Hugo v0.158.0.
The sources were the theme’s translation_link.html and func/language-name.html.
I had deleted translation_link.html thinking the theme did not use it, but it was actually being called, so I restored my original override.
I overrode func/language-name.html with a version that uses .Language.Label.
I deleted my render-image.html override because the v5 default handles srcset and lazy loading.
The copies main.css, syntax.css and codeblock.css in static/css/ and static/js/main.js had stopped working, because v5 loads CSS and JS from the theme’s assets/.
I deleted them and also moved the copy button styles from codeblock.css into custom.css, but later I found that my own copy button duplicated the theme’s built-in copy feature and removed it.
I did not carry over the #FCFCFC background of .no-img, since I had added it before supporting dark mode.
The RSS alternate link came out as a relative URL in the v5 default, so I changed it to an absolute URL with .Permalink.
Checking the display
The hugo build passed without warnings, and opening the mermaid sample post with hugo server produced no console errors.
The diagrams rendered, and the promotion notice, TOC icon, tags and related posts were displayed.
In the output HTML I also confirmed the heading anchors and the absolute-URL RSS link.
Summary
The troubleshooting and the work this time come down to the following three points.
- When
hugo mod get -udoes not reach the latest version, check the upstream tags and the module declaration ingo.mod, and see whether the import path needs a major version. - Because v5 changes where layouts live, move the site’s overrides to the new locations and re-apply your own changes based on the v5 files.
- After updating, check for display regressions with the warnings and the diff against the
public/from before the update, not just whether the build succeeds.