Wiring Pagefind into an Astro site that already serves five locales: expected the multilingual work to be a whole ticket. It took zero lines of config.

When pagefind --site dist runs, it reads the <html lang="..."> attribute on each page and emits a per-locale index (pagefind.en.pf_meta, pagefind.ar.pf_meta, etc.). On the browser side, when the Pagefind JS module initialises, it reads the same attribute from the current page and only loads the matching index.

Result: a page served at /ar/search/ with <html lang="ar"> only sees Arabic content; a page at /search/ only sees English. The Pagefind UI and the JS API both benefit - no filter code required on my side.

The single pre-requisite: your BaseLayout already sets lang correctly on the <html> element per-locale. Which mine did, because I’d set that up months ago for i18n’s sake. Sometimes you build one thing and get another for free.