Troubleshoot Hosting Pagefind
Pagefind outputs a static bundle directory to your built site, and no hosting configuration is required.
Pagefind handles compression of the files in the bundle directly, so no server gzip support is required.
#Hosting on GitHub Pages
GitHub Pages won’t serve URLs that start with a leading underscore, so the default path of
_pagefind will 404. To fix this, set a custom bundle directory (e.g.
--bundle-dir mysearch), and update your JS and CSS references to match (e.g.
<script src="/mysearch/pagefind-ui.js" ...).
#Content Security Policy (CSP)
If you have a strict content security policy enabled on your site, you may encounter issues with the Pagefind WebAssembly — this isn’t specific to Pagefind but is an issue with CSP and WebAssembly.
The most widely-supported solution at the current moment is to ensure your Content Security Policy allows
script-src 'unsafe-eval', which will work in all browsers.
A proposal exists for
script-src 'wasm-unsafe-eval', which is supported in Chrome, Firefox, and Edge, but has not yet shipped to a stable Safari version.
If you’re using the Pagefind UI snippet as documented you will also need