Skip to content

Replace Sphinx search with Pagefind#1266

Open
KiaraGrouwstra wants to merge 1 commit into
NixOS:masterfrom
KiaraGrouwstra:pagefind-search
Open

Replace Sphinx search with Pagefind#1266
KiaraGrouwstra wants to merge 1 commit into
NixOS:masterfrom
KiaraGrouwstra:pagefind-search

Conversation

@KiaraGrouwstra

Copy link
Copy Markdown
Contributor

Sphinx's stock client-side search stems and splits identifiers like system.nix into ubiquitous terms (system + nix) and stores no positional data, so phrase/identifier ranking is impossible: searching system.nix did not (highly) rank guides/recipes/dependency-management.html, which contains the exact string.

Pagefind indexes the rendered HTML post-build and does real phrase/proximity ranking. Searching system.nix now ranks that page first.

  • pagefind.yml: scope indexing to the article body, exclude UI chrome.
  • default.nix: add pkgs.pagefind to nativeBuildInputs (also exposes it in the dev shell via inputsFrom).
  • Makefile: run pagefind --site build/html after sphinx-build in the html target for local/CI parity, guarded with a clear error if the binary is missing.
  • source/_templates/search.html: replace the Sphinx search page with a Pagefind UI, dropping the now-unused Sphinx search scripts and pre-filling from ?q= so the sidebar search box still works.

Verifying:

Assisted-by: Claude:claude-opus-4-8

@KiaraGrouwstra KiaraGrouwstra requested a review from a team as a code owner July 13, 2026 13:55
@nixos-discourse

Copy link
Copy Markdown

This pull request has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/discussion-of-flakes-from-2025-nixos-community-survey-report/78853/40

@nixos-discourse

Copy link
Copy Markdown

This pull request has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/discussion-of-flakes-from-2025-nixos-community-survey-report/78853/41

@hsjobeki

hsjobeki commented Jul 13, 2026

Copy link
Copy Markdown
Collaborator

I like the idea.

Tested this locally.

I think excerpts could be longer.

New

image

Current

image

I'd like to try some other queries still. But pagefind is a sane default for a fully static page imho.

Sphinx's stock client-side search stems and splits identifiers like
`system.nix` into ubiquitous terms (`system` + `nix`) and stores no
positional data, so phrase/identifier ranking is impossible: searching
`system.nix` did not rank `guides/recipes/dependency-management.html`,
which contains the exact string.

Pagefind indexes the rendered HTML post-build and does real
phrase/proximity ranking. Searching `system.nix` now ranks that page
first.

- `pagefind.yml`: scope indexing to the article body, exclude UI chrome.
- `default.nix`: add `pkgs.pagefind` to `nativeBuildInputs` (also exposes
  it in the dev shell via `inputsFrom`).
- `Makefile`: run `pagefind --site build/html` after `sphinx-build` in the
  `html` target for local/CI parity, guarded with a clear error if the
  binary is missing.
- `source/_templates/search.html`: replace the Sphinx search page with a
  Pagefind UI, dropping the now-unused Sphinx search scripts and
  pre-filling from `?q=` so the sidebar search box still works.

Assisted-by: Claude:claude-opus-4-8
@KiaraGrouwstra

Copy link
Copy Markdown
Contributor Author

I think excerpts could be longer.

i bumped the snippets up to 30 words now

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.

3 participants