Module

postprocess.output_formats.index_generator

Site-wide index.json generator for Bengal SSG.

Generates a comprehensive JSON index of all pages suitable for client-side search, filtering, and navigation.

Classes

SiteIndexGenerator
Generates site-wide index.json for search and navigation. Creates a comprehensive JSON index with:…
6

Generates site-wide index.json for search and navigation.

Creates a comprehensive JSON index with:

  • Page summaries (title, URL, excerpt, metadata)
  • Section counts and tag counts
  • Site metadata

Methods 2

generate
Generate site-wide index.json.
1 Path
def generate(self, pages: list[Page]) -> Path

Generate site-wide index.json.

Parameters 1
pages list[Page]

List of pages to include

Returns

Path

Path to the generated index.json file

page_to_summary
Convert page to summary for site index. Creates a search-optimized page summar…
1 dict[str, Any]
def page_to_summary(self, page: Page) -> dict[str, Any]

Convert page to summary for site index.

Creates a search-optimized page summary with enhanced metadata.

Parameters 1
page Page

Page object

Returns

dict[str, Any]

Dictionary with page summary for search indexing

Internal Methods 4
__init__
Initialize the index generator.
4 None
def __init__(self, site: Site, excerpt_length: int = 200, json_indent: int | None = None, include_full_content: bool = False) -> None

Initialize the index generator.

Parameters 4
site Site

Site instance

excerpt_length int

Length of excerpts in characters

json_indent int | None

JSON indentation (None for compact)

include_full_content bool

Include full content in index (increases size)

_get_index_path
Get the output path for index.json, handling i18n prefixes.
0 Path
def _get_index_path(self) -> Path

Get the output path for index.json, handling i18n prefixes.

Returns

Path

_write_if_changed
Write content only if it differs from existing file.
2 None
def _write_if_changed(self, path: Path, content: str) -> None

Write content only if it differs from existing file.

Parameters 2
path Path
content str
_add_enhanced_metadata
Add enhanced metadata fields to summary.
2 None
def _add_enhanced_metadata(self, summary: dict[str, Any], metadata: dict[str, Any]) -> None

Add enhanced metadata fields to summary.

Parameters 2
summary dict[str, Any]
metadata dict[str, Any]