Module

postprocess.special_pages

Special pages generation for Bengal SSG.

Handles generation of special pages that don't come from markdown content:

  • 404 error page
  • search page (future)
  • other static utility pages

Classes

SpecialPagesGenerator
Generates special pages like 404, search, etc. These pages use templates from the theme but don't …
5

Generates special pages like 404, search, etc.

These pages use templates from the theme but don't have corresponding markdown source files. They need to be rendered during the build process to ensure they have proper styling and navigation.

Currently generates:

  • 404.html: Custom 404 error page with site styling
  • search.html: Client-side search page
  • graph.html: Interactive knowledge graph visualization

Future:

  • sitemap.html: Human-readable sitemap

Methods 1

generate
Generate all special pages that are enabled. Currently generates: - 404 page i…
1 None
def generate(self, build_context: BuildContext | Any | None = None) -> None

Generate all special pages that are enabled.

Currently generates:

  • 404 page if 404.html template exists in theme
  • search page if enabled and template exists (and no user content overrides)
  • graph visualization if enabled (and no user content overrides) Failures are logged but don't stop the build process.
Parameters 1
build_context BuildContext | Any | None

Optional BuildContext with cached knowledge graph

Internal Methods 4
__init__
Initialize special pages generator.
1 None
def __init__(self, site: Site) -> None

Initialize special pages generator.

Parameters 1
site Site

Site instance with configuration and template engine

_generate_404
Generate 404 error page with site styling. Uses 404.html template from theme i…
0 bool
def _generate_404(self) -> bool

Generate 404 error page with site styling.

Uses 404.html template from theme if it exists. Creates a minimal page context and renders the template with site navigation and styling.

Returns

bool

True if generated successfully, False if template missing or error occurred

_generate_search
Generate client-side search page using theme/site template. Behavior: - Respec…
0 bool
def _generate_search(self) -> bool

Generate client-side search page using theme/site template.

Behavior:

  • Respects [search] config: enabled, path, template
  • Skips if a user-authored content page exists that would handle /search/
  • Skips if template is missing
  • Writes to /search/index.html by default
Returns

bool

_generate_graph
Generate interactive knowledge graph visualization. Behavior: - Respects [grap…
1 bool
def _generate_graph(self, build_context: BuildContext | Any | None = None) -> bool

Generate interactive knowledge graph visualization.

Behavior:

  • Respects [graph] config: enabled, path
  • Skips if a user-authored content page exists that would handle /graph/
  • Uses cached knowledge graph from build_context if available
  • Writes to /graph/index.html by default
Parameters 1
build_context BuildContext | Any | None

Optional BuildContext with cached knowledge graph

Returns

bool

True if generated successfully, False if disabled or error occurred