A pure .NET library that generates Pagefind-compatible search indexes. No native binaries, no subprocess, no platform restrictions -- the entire indexing pipeline runs in managed code.
| Package | NuGet |
|---|---|
| Pagefind.Net | |
| Pagefind.Net.Frontend |
Install both packages:
dotnet add package Pagefind.Net
dotnet add package Pagefind.Net.FrontendBuild an index and let the frontend runtime extract automatically:
using Pagefind.Net;
var index = new PagefindIndex(new PagefindIndexOptions { Language = "en" });
index.AddRecord(new PagefindRecord
{
Url = "/guide/",
Title = "Getting started",
Content = plainTextBody,
WeightedSegments =
[
new WeightedSegment(h1Text, Weight: 7),
new WeightedSegment(h2Text, Weight: 4),
new WeightedSegment(bodyText, Weight: 1),
],
Anchors =
[
new PagefindAnchor(ElementId: "intro", Text: "Introduction", ByteLocation: 0),
],
Meta = new Dictionary<string, string>
{
["title"] = "Getting started",
},
});
await index.WriteAsync("wwwroot", CancellationToken.None);WriteAsync emits the index data files (pagefind-entry.json, *.pf_meta, index/*.pf_index, fragment/*.pf_fragment) into wwwroot/pagefind/.
The Pagefind.Net.Frontend package ships pagefind.js and wasm.en.pagefind and automatically extracts them into wwwroot/pagefind/ on build via an MSBuild target. No npm install required.
Targets Pagefind version 1.5.2. The index format is version-pinned; see PagefindIndex.PagefindTargetVersion.
Full documentation is available at nullean.github.io/pagefind-net.
MIT -- see LICENSE.txt. Third-party notices in NOTICE.txt.