Bengal is designed with multiple extension points that allow customization without modifying core code.
1. Custom Content Strategies
Purpose: Define how different content types are organized and rendered
Implementation:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | |
Configuration:
1 2 | |
Documentation: See Content Types
2. Custom Markdown Parsers
Purpose: Add support for alternative markdown flavors or custom syntax
Implementation:
1 2 3 4 5 6 7 8 9 10 11 12 13 | |
Configuration:
1 2 | |
3. Custom Template Functions
Purpose: Add custom filters and functions for Jinja2 templates
Implementation:
1 2 3 4 5 6 7 8 9 10 | |
Usage in templates:
{{ page.title | custom }}
Examples: See example_templates/filters/safe_filters.py for real-world custom filter implementations.
Future: Plugin system will formalize this
4. Custom Post-Processors
Purpose: Add custom build steps after page rendering
Implementation:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | |
Future: Plugin system will provide hooks
5. Custom Validators
Purpose: Add custom health checks and validation rules
Implementation:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | |
Configuration:
1 2 | |
Documentation: See Health Checks
6. Custom Themes
Purpose: Package templates, styles, and scripts for reuse
Structure:
my-theme/
├── templates/
│ ├── base.html
│ ├── page.html
│ └── blog/
│ ├── post.html
│ └── list.html
├── assets/
│ ├── css/
│ │ └── style.css
│ ├── js/
│ │ └── main.js
│ └── fonts/
└── theme.toml # Theme metadata
Configuration:
theme = "my-theme"
Documentation: Themes automatically override default templates
7. Custom Shortcodes (Planned)
Purpose: Define custom markdown syntax extensions
Planned API:
1 2 3 4 5 6 7 8 9 10 11 | |
Usage in markdown:
1 2 3 | |
8. Plugin System (Planned v0.4.0)
Purpose: Formal plugin architecture with lifecycle hooks
Planned API:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | |
Planned Hooks:
pre_build- Before build startspost_content_discovery- After content discoveredpre_page_render- Before page renderspost_page_render- After page renderspost_build- After build completestemplate_context- Modify template contextpre_asset_process- Before asset processingpost_asset_process- After asset processing
9. Custom CLI Commands (Future)
Purpose: Add custom commands to Bengal CLI
Planned API:
1 2 3 4 5 6 7 8 9 10 | |
10. Custom Autodoc Extractors
Purpose: Generate documentation from other sources
Implementation:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | |
Current Workarounds
Until the plugin system is implemented, some extensions require:
- Fork and modify: Make changes in your own fork
- Wrapper scripts: Write scripts that call Bengal + custom logic
- Template-based: Many customizations possible via templates alone
- Theme-based: Package customizations in a theme
Extension Best Practices
- Prefer Templates: Many customizations possible without code
- Use Themes: Package related customizations together
- Follow Conventions: Match Bengal's patterns and style
- Document: Provide clear documentation for your extensions
- Test: Write tests for custom functionality
- Share: Consider contributing back to Bengal
Community Extensions (Future)
Planned extension registry atbengal-ssg.org/extensions/:
- Themes
- Plugins
- Template function packs
- Validators
- Content strategies
- CLI commands
Migration Path
When plugin system arrives:
- Existing extensions can be migrated incrementally
- Old patterns will continue working (backward compatibility)
- New APIs will be opt-in
- Migration guides will be provided
Related Documentation
- Content Types - Custom content strategies
- Rendering - Template and parser customization
- Health Checks - Custom validators
- Design Principles - Extension design patterns