Skip to content

fix: clear the Hugo deprecations behind live-editing guards - #388

Merged
markdumay merged 4 commits into
mainfrom
fix/hugo-0158-deprecations
Nov 3, 2026
Merged

markdumay merged 4 commits into
mainfrom
fix/hugo-0158-deprecations

Conversation

@markdumay

@markdumay markdumay commented Nov 3, 2026 •

Copy link
Copy Markdown
Collaborator

Clears the three Hugo deprecations mod-utils emits (.Site.Data, Image.Exif, .Site.AllPages), and adds a test that runs the partials in CloudCannon's live-editing renderer. Part of gethinode/hinode#2049.

CloudCannon's Live Editor renders partials with Bookshop's embedded Hugo v0.147.6, where hugo.Data, hugo.Sites and Image.Meta fail with can't evaluate field. Each replacement is therefore behind a hugo.Version.Compare check, with the old call kept for older Hugo, never inside cond. The module floor (0.146.0) is unchanged.

Commit Item Change
fix: test partials in Bookshop's live-editing renderer gethinode/hinode#2310 tests/renderer/ loads the real v0.147.6 renderer, builds the exampleSite test pages in it and compares them with the golden output. Two negative controls (an unguarded hugo.Data, and one inside cond) must fail. Adds a liquidjs@10 override so pnpm audit stays clean.
fix: read data through a guarded hugo.Data helper gethinode/hinode#2307 New utilities/GetData.html; moves all 14 site.Data reads to it. hinode and mod-blocks will call it too.
fix: read image orientation through a guarded Image.Meta gethinode/hinode#2308 Same orientation handling, read from Meta on Hugo 0.155.3 or later.
fix: match GetPage references through a guarded hugo.Sites gethinode/hinode#2309 Matches the same pages, including on projects with versions or roles. A new matrix test covers those.

Verification

  • pnpm test passes at every commit: deprecation check, 19 golden groups, the versions/roles matrix, and the renderer test (25 pass, 1 skipped: the renderer cannot encode WebP).
  • With the old partials and the new ones, exampleSite output is identical on every Hugo release from 0.155.0 to 0.169.0, and on 0.147.6. With the versions and roles overlays, it is identical from 0.155.3 to 0.169.0.
  • GetPage returned the same pages as site.AllPages in 280 runs: every release from 0.156.0 to 0.169.0, × 10 language, version and role configurations, with drafts on and off.
  • pnpm audit --audit-level=high exits 0.
  • Hinode's exampleSite and squadra.nl, built against this branch, give the same output as with v6.18.0, minus the Image.Exif warning.
  • Two blind review rounds. The first found the versions/roles mismatch, the audit failure and two untrue statements, all fixed.

Not run: the new tests on Windows. The paths and quoting were checked by reading the code.

🤖 Generated with Claude Code

markdumay and others added 4 commits November 3, 2026 21:24
CloudCannon's Live Editor renders partials in Bookshop's embedded Hugo
v0.147.6 (@bookshop/hugo-engine), where newer template APIs such as
hugo.Data fail. tests/renderer/harness.mjs loads that renderer in Node;
tests/renderer/renderer.test.mjs builds the exampleSite test pages in it
and compares each against the golden file the current Hugo's build is
compared against.

Negative controls: an unguarded hugo.Data, and the same call inside cond,
both fail the build; behind a hugo.Version.Compare guard it renders the
old branch.

pnpm test now runs the renderer test (pnpm test:renderer).
@bookshop/hugo-engine is pinned to 3.20.0; its esbuild dependency may
not run install scripts. The engine pins liquidjs 10.17.0, which pnpm
audit reports with high and critical advisories; an override lifts it
to ^10.27.2, and the renderer test never loads liquidjs.

The harness require()s an ES module, so it needs Node.js v22.12.0 or
later on Node 22. Its header documents that, and how another repo such
as hinode or mod-blocks reuses it: copy the file, and add its own
exactly pinned @bookshop/hugo-engine devDependency or pass engineDir.
A Hugo project's vendored copy of this module leaves tests/ out.

Refs gethinode/hinode#2310

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Hugo v0.156.0 deprecated site.Data in favour of hugo.Data. The new
utilities/GetData.html returns hugo.Data on Hugo v0.156.0 or later and
site.Data otherwise. ArgsSchema, GetContact, GetI18nData and GetMenu
read their 14 site.Data references through it, as does the exampleSite
test runner.

The guard is an if/else on hugo.Version.Compare: Bookshop's v0.147.6
live-editing renderer fails on hugo.Data, also inside cond.

Tests: a new exampleSite group (data) covers GetContact, GetMenu and
GetI18nData; its golden file was generated before the migration. The
renderer test covers GetData. tests/deprecations.mjs builds exampleSite
at --logLevel info and fails on a .Site.Data deprecation; pnpm test runs
it in place of the plain build.

Refs gethinode/hinode#2307

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Hugo v0.155.0 deprecated Image.Exif in favour of Image.Meta, which
reports the EXIF orientation as Meta.Orientation, an int. Hugo's docs
give Meta as new in v0.155.3, though v0.155.0 already has it. GetImage
reads it from Meta on Hugo v0.155.3 or later and from
Exif.Tags.Orientation otherwise, including Bookshop's v0.147.6
live-editing renderer.

Tests: new exampleSite groups getimage and getimage-webp render GetImage
on a 16x8 fixture with each EXIF orientation 1-8 as JPEG, orientation 6
as PNG, TIFF and WebP, and no EXIF as JPEG, GIF and BMP (generated by
exampleSite/assets/img/orientation/generate.py). Their golden files were
generated with Exif, before the change, and pass unchanged with Meta.
The renderer test builds getimage through a GetResource stub that
decodes the fixtures from base64, since the renderer takes no binary
files; it skips getimage-webp, since the renderer cannot encode WebP.
tests/deprecations.mjs now also fails on an Image.Exif deprecation.

Refs gethinode/hinode#2308

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Hugo v0.156.0 deprecated site.AllPages. It returns the pages of every
language in the first version and the first role of Hugo's sort order,
which are the version and role of the first site in hugo.Sites, and not
necessarily the default version or role. On Hugo v0.156.0 or later,
GetPage builds its fallback match list from the hugo.Sites entries with
that version and role; it keeps site.AllPages otherwise, including
Bookshop's v0.147.6 live-editing renderer.

Tests: exampleSite now has a second language (nl), and a new getpage
group resolves references through the permalink fallback: a page that
exists only in the other language, its section and home page, a
permalink present in both languages (ambiguous, so no match) and a
missing one. Its golden file was generated with site.AllPages, before
the change, and passes unchanged; the renderer test builds the same
group. tests/deprecations.mjs now also fails on a .Site.AllPages
deprecation.

tests/matrix.mjs builds exampleSite with each config overlay in
tests/matrix: two versions, or two roles, whose default is not the
first in Hugo's sort order, with every page in each. It compares the
getpage group on every site that renders it against
tests/matrix/<name>.json, which was generated with site.AllPages. A
match against every site's pages, the default site's or the current
site's fails it. pnpm test runs it.

Refs gethinode/hinode#2309

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@markdumay

Copy link
Copy Markdown
Collaborator Author

🎉 This PR is included in version 6.18.1 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant