Skip to content

About

A pagefind indexer in native .NET

Topics

Resources

Contributing

Security policy

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

pagefind.net

Generate Pagefind search indexes from pure .NET: no native binary, no subprocess, no platform restrictions. The whole indexing pipeline runs in managed code and is AOT-compatible.

NuGet CI Docs

The Pagefind search UI in examples/Pagefind.Net.Web, querying an index Pagefind.Net built at startup

examples/Pagefind.Net.Web, run locally: the index is written by Pagefind.Net at startup, and searched in the browser by the Pagefind runtime that Pagefind.Net.Frontend ships.

Install

dotnet add package Pagefind.Net
dotnet add package Pagefind.Net.Frontend

Quick start

using Pagefind.Net;

var index = new PagefindIndex(new PagefindIndexOptions { Language = "en" });

index.AddRecord(new PagefindRecord
{
	Url = "/guide/",
	Title = "Getting started",
	Content = "Install the package, add your pages, write the index.",
	WeightedSegments =
	[
		new WeightedSegment("Getting started", Weight: 7),                                      // h1
		new WeightedSegment("Install the package, add your pages, write the index.", Weight: 1), // body
	],
	Anchors = [new PagefindAnchor(ElementId: "install", Text: "Install", Location: 0, Tag: "h2")],
	Meta = new Dictionary<string, string> { ["title"] = "Getting started" },
});

await index.WriteAsync("wwwroot");   // wwwroot/pagefind/: pagefind-entry.json, *.pf_meta, index/, fragment/

WriteAsync writes the index data files into wwwroot/pagefind/. Pagefind.Net.Frontend ships pagefind.js and wasm.en.pagefind and extracts them into wwwroot/pagefind/ on build, through an MSBuild target. No npm install required. Serve wwwroot/ and search it with Pagefind's JavaScript API or UI.

Pages you have already parsed into headings and text can go in as HtmlPageData with AddHtmlRecord, which weights them as the Pagefind binary does.

Targets Pagefind 1.5.2. The index format is version-pinned; see PagefindIndex.PagefindTargetVersion.

Packages

Package What it is
Pagefind.Net The indexer: records in, Pagefind index data files out. NuGet
Pagefind.Net.Frontend The Pagefind 1.5.2 browser runtime (pagefind.js, wasm.en.pagefind), extracted on build. NuGet

Learn more

MIT licensed. Copyright Nullean and contributors. Third-party notices in NOTICE.txt.

About

A pagefind indexer in native .NET

Topics

Resources

Contributing

Security policy

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages