fix(search): use absolute bundle-path for Pagefind Component UI#1021
Merged
Conversation
The Pagefind modal Component UI failed to load its search bundle on
shallow pages (e.g. the site homepage) with "Could not load search
bundle". The bundle was requested at /pagefind/pagefind/pagefind.js
(404, served as text/html) instead of /pagefind/pagefind.js.
Root cause: bundle-path was page-relative ({{siteRootPath}}/pagefind/).
The components load the index via a dynamic import(`${bundlePath}pagefind.js`)
that runs inside /pagefind/pagefind-component-ui.js, and import() resolves
relative specifiers against the importing module's URL, not the page. On
shallow pages siteRootPath is ".", so "./pagefind/" resolved against
.../pagefind/ and doubled to .../pagefind/pagefind/pagefind.js. Deeper
pages emitted an absolute /pagefind/ and worked, masking the bug.
Use an absolute, root-relative bundle-path="/pagefind/": depth-independent
and matching Pagefind's documented convention (their examples use absolute
paths; auto-detect also falls back to /pagefind/).
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Signed-off-by: Thomas Müller <1005065+DeepDiver1975@users.noreply.github.com>
phil-davis
approved these changes
Jun 16, 2026
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.
Problem
Pagefind search fails on
doc.owncloud.com— opening the search modal shows "Pagefind Error: Could not load search bundle". The browser requests/pagefind/pagefind/pagefind.js(a doubledpagefind/segment) which 404s (served astext/html), so the dynamically imported module is blocked.This affects shallow pages such as the site homepage; deeper pages happened to work, which masked the bug.
Root cause
The modal Component UI was configured with a page-relative
bundle-path:The components load the index via a dynamic
import(\${bundlePath}pagefind.js`)that executes **inside**/pagefind/pagefind-component-ui.js. A dynamicimport()resolves relative specifiers against the **importing module's URL**, not the page. On shallow pagessiteRootPathis., so./pagefind/resolves against…/pagefind/and doubles to…/pagefind/pagefind/pagefind.js`.Verified against production:
/pagefind/pagefind.js200✓/pagefind/pagefind/pagefind.js404(text/html)Fix
Use an absolute, root-relative
bundle-path="/pagefind/". It is depth-independent and matches Pagefind's documented convention (their examples use absolute paths; auto-detect also falls back to/pagefind/).One-line template change;
npm run lintpasses on Node 22.🤖 Generated with Claude Code