All contributions

Pagefind/pagefind

Pagefind

A Rust search engine for static sites that indexes the built site and only sends the needed parts of the index to the browser.

Language
Rust
GitHub stars
5,575
Merged changes
3
Project site
pagefind.app

What we changed

A bad selector in --exclude-selectors no longer stops the index build, page URLs from file names with spaces, non-ASCII letters or special characters are percent-encoded, and result images from an index on another domain load from its baseUrl.

What this work shows

  • URL percent-encoding
  • CSS selector parsing in lol_html
  • Relative URL resolution
  • In-browser integration tests
What was broken

One bad selector crashed the whole index build

All --exclude-selectors values were joined into one selector. When lol_html could not parse one of them, for example :not(.a b), Pagefind stopped with a panic.

How we fixed it

Each selector parsed on its own

Each selector is now parsed on its own. An unsupported one is logged as a warning and dropped, and the rest keep working. A test checks that with :not(.a b) indexing finishes and .ad is still excluded.

#1312

What was broken

File names went into URLs unencoded

build_url copied the file path into the URL almost verbatim and only encoded %, # and ?. A file called Müsli.html got the link /Müsli.html, and spaces or quotes in names produced invalid URLs.

How we fixed it

Full percent-encoding of the path

The URL is encoded with the percent-encoding crate using the URL spec's path encode set, minus the slash so directory boundaries survive. Müsli.html becomes /M%C3%BCsli.html and a b/c#d?e.html becomes /a%20b/c%23d%3Fe.html.

#1335

What was broken

Result images loaded from the wrong domain

With an index from another domain, attached through baseUrl, result links were right, but relative images were resolved to the path alone. They loaded from the search site's domain and showed as broken.

How we fixed it

Images keep the baseUrl domain

URL resolution now keeps the origin, in the components and in both default UI templates. An images/header.png on /blog/post/ points to https://example.com/blog/post/images/header.png. We added browser tests and a note in the resolveUrl docs.

#1363

Merged changes 3

  1. #1363 Resolve result images against an absolute baseUrl Merged 3 November 2026
  2. #1335 Percent-encode page URLs built from file paths Merged 1 November 2026
  3. #1312 fix(pagefind): skip exclude selectors that cannot be parsed Merged 13 September 2026

What it taught us

We work on both sides of a tool: in Rust at index time and in the TypeScript and Svelte interface. We know a file path is not yet a URL, and a relative address has to be resolved together with its domain.

More about this technology: Rust

Other projects we write code for

Describe your project.

A free quote comes back within an hour during working hours.