Module

core.theme

Theme configuration object for Bengal SSG.

Provides theme-related configuration accessible in templates assite.theme. Includes feature flags system for declarative theme customization.

Classes

Theme dataclass
Theme configuration object. Available in templates as `site.theme` for theme developers to access …
4

Theme configuration object.

Available in templates assite.themefor theme developers to access theme-related settings.

Attributes

Name Type Description
name str

Theme name (e.g., "default", "my-custom-theme")

default_appearance str

Default appearance mode ("light", "dark", "system")

default_palette str

Default color palette key (empty string for default)

features list[str]

List of enabled feature flags (e.g., ["navigation.toc", "content.code.copy"])

config dict[str, Any] | None

Additional theme-specific configuration from [theme] section Feature Flags: Features are declarative toggles for theme behavior. Users enable/disable features via config rather than editing templates.

Methods 3

has_feature
Check if a feature is enabled.
1 bool
def has_feature(self, feature: str) -> bool

Check if a feature is enabled.

Parameters 1
feature str

Feature key (e.g., "navigation.toc", "content.code.copy")

Returns

bool

True if the feature is in the enabled features list

from_config classmethod
Create Theme object from configuration dictionary. Attempts to load theme.yaml…
2 Theme
def from_config(cls, config: dict[str, Any], root_path: Path | None = None) -> Theme

Create Theme object from configuration dictionary.

Attempts to load theme.yaml first, then falls back to config dict. This allows themes to define their configuration in theme.yaml while still supporting site-level overrides in bengal.toml.

Parameters 2
config dict[str, Any]

Full site configuration dictionary

root_path Path | None

Optional root path for theme discovery

Returns

Theme

Theme object with values from config or theme.yaml

to_dict
Convert theme to dictionary for template access.
0 dict[str, Any]
def to_dict(self) -> dict[str, Any]

Convert theme to dictionary for template access.

Returns

dict[str, Any]

Dictionary representation of theme

Internal Methods 1
__post_init__
Validate theme configuration.
0 None
def __post_init__(self) -> None

Validate theme configuration.