Skip to content

Add baseurl-aware Pagefind bundlePath tag for GitHub Pages project sites - #3

Merged
phothinmg merged 3 commits into
mainfrom
copilot/check-plugin-dir-lib
Jul 21, 2026
Merged

phothinmg merged 3 commits into
mainfrom
copilot/check-plugin-dir-lib

Conversation

Copilot AI commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Pagefind UI was resolving bundles from /pagefind/ by default, which breaks Jekyll sites deployed under url + baseurl (common on GitHub Pages project sites). This change makes bundle path resolution explicit and baseurl-aware while keeping indexing output behavior unchanged.

  • Plugin runtime path helper

    • Added Jekyll::Pagefind.bundle_path(config) to compute a normalized path from:
      • site.baseurl
      • jekyll_pagefind.output_subdir (default: pagefind)
    • Ensures stable output format: /<baseurl?>/<output_subdir>/ with normalized slashes.
  • Liquid integration

    • Added {% pagefind_bundle_path %} tag (BundlePathTag) to expose the computed bundle path directly in templates.
  • Documentation updates

    • Updated Default UI example to pass bundlePath explicitly.
    • Added guidance that bundlePath must be baseurl-aware when baseurl is set.
    • Added note for Component UI JS initialization to use the same path.
<script src="{{ '/pagefind/pagefind-ui.js' | relative_url }}"></script>
<link rel="stylesheet" href="{{ '/pagefind/pagefind-ui.css' | relative_url }}" />

<div id="search"></div>
<script>
  window.addEventListener('DOMContentLoaded', () => {
    new PagefindUI({
      element: "#search",
      showSubResults: true,
      bundlePath: "{% pagefind_bundle_path %}"
    });
  });
</script>

@phothinmg
phothinmg marked this pull request as ready for review July 21, 2026 08:28
@phothinmg
phothinmg merged commit 5037613 into main Jul 21, 2026
2 checks passed
@phothinmg
phothinmg deleted the copilot/check-plugin-dir-lib branch July 21, 2026 11:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants