static site search

31 Oct 2022

Aiming to replace Stork for my Pelican-powered static site. !projects/notes

Asked question regarding support of Github Pages:


Requires Node.js with npx.

Install from:

Not working with code snippet provided on Pagefind homepage.
Seems like an issue with CSS and JS paths.
Copied .js and .css files to Pelican theme/js and theme/css.
This works (currently Live), ie search input and output appear.. but empty.
404 on (which I should have tried and figured out at the previous step!) - which means the standard Github Actions worfklow triggered by Github Pages does not include the folder when deploying? 馃
Downloaded the Artifact (ie root folder content of the website on server) from Github Pages, and indeed the folder _pagefind is not included, despite being present in the main Github branch used as source for the default Github Actions workflow that generates Github Pages.
Confirmed that folders prefixed with _ do not get included in the build: https://github/orgs/community/discussions/23640
How to get it included?
Asked: https://github/CloudCannon/pagefind/discussions/126

02 Nov 2022

Working now, using:

npx -y pagefind --source "/Users/USER/path/to/folder/with/html/files" --bundle-dir pagefind

The last pagefind argument defines the name of the folder to be created, overriding the default _pagefind which did not work because Github Pages ignores folders prefixed with _ upon deployment.


鈹溾攢鈹 filter
鈹溾攢鈹 fragment
鈹溾攢鈹 index
鈹溾攢鈹 pagefind-entry.json
鈹溾攢鈹 pagefind-ui.css
鈹溾攢鈹 pagefind-ui.js
鈹溾攢鈹 pagefind.en_4dc9564564.pf_meta
鈹溾攢鈹 pagefind.en_8ba44c3efa.pf_meta
鈹溾攢鈹 pagefind.en_a9db73dbfe.pf_meta
鈹溾攢鈹 pagefind.en_eca087938c.pf_meta
鈹溾攢鈹 pagefind.en_fbece7798f.pf_meta
鈹溾攢鈹 pagefind.js
鈹溾攢鈹 wasm.en.pagefind
鈹斺攢鈹 wasm.unknown.pagefind

Next steps:

  • exclude folders from search index (eg author, tag, etc..)
  • show only sections with results
  • show categories without having to expand each
  • focus: true on load
  • navigate results with keyboard

exclude folders from search index

Asked on Github:

05 Mar 2023 been in place and working well since Nov'.


passing a search query via URL parameter


"There's some discussion of this in #144 鈥 it is possible but you'll need a small code snippet of your own to get the query from the URL 馃檪"

let pagefind = new PagefindUI({ element: "#search" });
pagefind.triggerSearch("some search terms");