Jump to content

Searching

From Wikven

Static sites have no server to answer queries, so MediaWiki's built-in search does not work in the export. Wikven ships SifterSearch built in and enabled by default: it builds a static search index at build time and serves results entirely in the browser, so every site has working search with no setup. This documentation site uses it.

How it works

SifterSearch indexes the rendered pages with Pagefind and writes a static index bundle into the build output. On each page it feeds those results into the skin's own search box: the Codex typeahead where the skin mounts one (Vector 2022 and MinervaNeue), and core's classic suggestions box elsewhere. Either way the box suggests as you type, a suggestion leads to the page it names, and nothing behind it is asked — no API, no database, no load.php.

A site built with more than one skin is written once per skin, and each of those copies carries the index as well as the pages, under its own pagefind/. A result is a page in the copy the reader is already reading, so choosing a skin survives a search.

Configuring it

Search needs no configuration: the index is written to a pagefind/ directory under the build output and served from /pagefind/. You only adjust it in a few cases, all in .wikven.yaml.

If your site lives in a subdirectory, set the bundle path to include it. This site deploys under /wikven on GitHub Pages:

config:
  SifterSearchBundlePath: /wikven/pagefind/

To list all matches on a page rather than just the typeahead, name a content page (see below):

config:
  SifterSearchResultsPage: "Search"

To turn search off, point the output directory at nothing:

config:
  SifterSearchOutputDir: ""

The Codex typeahead keeps a column for each result's thumbnail, and a Pagefind result has none, so a skin that mounts it shows an empty column until it is told not to. Each such skin reads its own setting, and takes the value whole rather than merging it into the default, so the block is restated in full for each — the API keys among it, at the values the skin already had. This site sets both:

config:
  VectorTypeahead:
    apiUrl: null
    recommendationApiUrl: null
    options:
      showThumbnail: false
      showDescription: true
  MinervaTypeahead:
    apiUrl: null
    recommendationApiUrl: null
    options:
      showThumbnail: false
      showDescription: true

Full results page

The skin's search box shows the top matches as you type. For a page that lists all matches, create an (otherwise empty) content page and name it in SifterSearchResultsPage. SifterSearch mounts its full search UI there and runs the query from the URL, and the search box's "search for pages containing…" action and its Enter key go to that page. This site uses a page titled Search.

Retrieved from "Searching/en.html"