Conversation
Page.GetPage resolves relative references against Hugo's active rendering context (the `page` global), not the receiver page. When content is processed from a foreign render — for example a custom output format whose layout iterates other pages and reads .Plain, .Content, or .Summary — the active context is the driving page, and the receiver-based lookup returns nil even though the explicitly passed `$page` is correct. site.GetPage is context-independent and resolves the reference by name across the site. Adding it as a fallback before the existing AllPages-regex fallback fixes the lookup in foreign render contexts without affecting normal page rendering. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
site.Home.RelPermalink returns the active output's permalink, so during a non-HTML output render (custom searchindex / RSS / custom JSON output) this helper would inject that output's path into the base URL and emit nonsensical results — for example "/flexsearch-index.json/introduction" when called from inside a searchindex output layout. The HTML output's permalink is the canonical site root and remains stable across render contexts; falling back to site.Home.RelPermalink only when the html output format is absent preserves the previous behavior for sites that disable HTML output. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Collaborator
Author
|
🎉 This PR is included in version 5.23.2 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Two related fixes to mod-utils' page-resolution helpers, plus the 9 dependabot/chore commits already accumulated on develop.
The new fixes
fix(GetPage):fall back tosite.GetPagefor foreign-render contexts.fix(GetStaticURL):pin the base URL to the HTML home permalink (notsite.Home.RelPermalink, which returns the active output's permalink).Why
When a Hugo layout renders content from a foreign page context — e.g. a custom output format whose layout iterates
site.RegularPagesand reads.Plain/.Content/.Summaryof other pages — Hugo'spageglobal is the driving page, not the page whose content is being processed.Page.GetPage(url)for a relative reference uses Hugo's active rendering context (thepageglobal), not the receiver page, so the receiver-based lookup returns nil even when$pageis correctly passed. The first fix addssite.GetPageas a context-independent fallback.GetStaticURLbuilds a base URL fromsite.Home.RelPermalink. During a non-HTML output render this returns the active output's permalink (e.g./flexsearch-index.json), producing absurd patterns like/flexsearch-index.json/introduction/that match no page in the existingwhere site.AllPages "RelPermalink" "like" …fallback. The second fix pins the base to the HTML home permalink, which is stable across render contexts.The bug was surfaced by gethinode/mod-flexsearch's new lazyLoad feature (a
searchindexoutput format that iterates all pages to build the index data). It manifests aspartial [assets/link.html] - Invalid arguments / Cannot find page or asset: '<name>'errors on any consuming site with markdown links that use short page names ([text](introduction)), because the relative-name resolution chain breaks.Verification
npm test).link.htmloverride →npm run build --ignore-scriptsproduces 0 errors, exit 0,flexsearch-index.json(120 docs) emitted,data-search-index=/flexsearch-index.jsonwired, core bundle carries the lazy runtime.lazyLoad=true, mod-llm's llmstxt) should now resolve short-name links correctly withoutlink.htmlerrors.Coordination
lazyLoad(gethinode/mod-flexsearch@caaa1fb) produces noisy "Cannot find page or asset" errors on Hinode-docs-heavy sites — exit non-zero, even though the rendered output is correct.mod-utils/v5to the new version.🤖 Generated with Claude Code