Skills2026年5月12日·1 分钟阅读

Pagefind — Static Low-Bandwidth Search for Any Website

A Rust-based static search library that indexes your site at build time and delivers instant search in the browser with minimal bandwidth.

Agent 就绪

这个资产可以被 Agent 直接读取和安装

TokRepo 同时提供通用 CLI 命令、安装契约、metadata JSON、按适配器生成的安装计划和原始内容链接,方便 Agent 判断适配度、风险和下一步动作。

Native · 98/100策略:允许
Agent 入口
任意 MCP/CLI Agent
类型
Skill
安装
Single
信任
信任等级:Established
入口
Pagefind
通用 CLI 安装命令
npx tokrepo install 609f9351-4dfd-11f1-9bc6-00163e2b0d79

Introduction

Pagefind is a fully static search library written in Rust that indexes your built website and generates a compact search index. Users search entirely in the browser with no server required, making it ideal for documentation sites, blogs, and static site generators.

What Pagefind Does

  • Indexes static HTML files after your site build completes
  • Generates a compressed search index that loads incrementally as users type
  • Provides a default search UI component or a JavaScript API for custom interfaces
  • Supports filtering, sorting, and metadata extraction from HTML data attributes
  • Works with any static site generator (Hugo, Astro, Eleventy, Jekyll, etc.)

Architecture Overview

Pagefind runs as a post-build step, parsing your HTML output directory and extracting text content. It builds an inverted index that is split into small chunks, so the browser only downloads the fragments relevant to the current query. The index uses a custom binary format optimized for size. On the client side, a small JavaScript runtime (~6KB gzipped) loads index chunks on demand via fetch and ranks results using BM25.

Self-Hosting & Configuration

  • Run after your static site build: npx pagefind --site ./public
  • Configure via pagefind.yml or CLI flags for source directory, output path, and language
  • Use data-pagefind-body attributes to control which content gets indexed
  • Exclude elements with data-pagefind-ignore to skip navigation, footers, or boilerplate
  • Add data-pagefind-filter and data-pagefind-meta attributes for faceted search

Key Features

  • Tiny client runtime (~6KB gzipped) with incremental index loading
  • A 10,000-page site produces an index that transfers under 300KB total
  • Multilingual support with language-specific stemming and segmentation
  • Built-in search UI or headless JavaScript API for custom interfaces
  • Supports indexing across multiple sites into a single merged index

Comparison with Similar Tools

  • Algolia — hosted search-as-a-service; Pagefind is fully static with zero ongoing cost
  • Lunr.js — client-side search that loads the entire index upfront; Pagefind loads chunks on demand
  • MiniSearch — in-memory JS search library; Pagefind pre-builds the index at compile time for lower runtime cost
  • Orama — full-text search engine in JS; Pagefind is optimized specifically for static sites with minimal bandwidth

FAQ

Q: Does Pagefind work with Next.js or Nuxt? A: Yes, as long as you generate static HTML output. Run Pagefind against the exported directory.

Q: How does it handle large sites? A: The chunked index architecture scales well. Sites with tens of thousands of pages remain fast because only relevant chunks are downloaded.

Q: Can I customize the search UI? A: Yes. Use the built-in PagefindUI component with CSS overrides, or use the JavaScript API to build a fully custom interface.

Q: Does it support CJK languages? A: Yes. Pagefind uses language-aware segmentation for Chinese, Japanese, and Korean text.

Sources

讨论

登录后参与讨论。
还没有评论,来写第一条吧。

相关资产