Customize Bengal themes without breaking theme updates. Use theme inheritance, template overrides, and CSS customization techniques.
Understand Theme Resolution
Bengal resolves themes in this order:
- Project themes -
themes/your-theme/(highest priority) - Installed themes - Installed via pip/uv
- Bundled themes - Built into Bengal (e.g.,
default)
Check Active Theme
1 2 3 4 5 6 7 8 | |
Create a Project Theme
Option 1: Start from Scratch
bengal new theme my-custom-theme
This creates:
themes/my-custom-theme/
├── theme.yaml
├── templates/
│ ├── base.html
│ ├── page.html
│ └── partials/
│ ├── header.html
│ └── footer.html
└── static/
├── css/
│ └── style.css
└── js/
└── main.js
Configure Your Theme
Editbengal.toml:
1 2 3 | |
Override Templates Selectively
Template Inheritance
You don't need to copy all templates. Override only what you need:
themes/my-custom-theme/templates/base.html:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | |
Partial Overrides
Override specific partials:
themes/my-custom-theme/templates/partials/footer.html:
1 2 3 4 | |
Bengal will use your partial instead of the theme's default.
Customize CSS
Method 1: Override Theme CSS
Create your own CSS file that overrides theme styles:
themes/my-custom-theme/static/css/custom.css:
1 2 3 4 5 6 7 8 9 10 11 | |
Include in your base template:
themes/my-custom-theme/templates/base.html:
1 2 3 4 5 | |
Method 2: Use CSS Variables
Many themes support CSS variables. Override them:
themes/my-custom-theme/static/css/overrides.css:
1 2 3 4 5 6 | |
Theme Configuration Options
Themes can expose configuration options:
themes/my-custom-theme/theme.yaml:
1 2 3 4 5 6 7 8 9 | |
Access in templates:
1 2 3 | |
Configure inbengal.toml:
1 2 3 4 5 6 7 | |
Best Practices
Don't Modify Installed Themes
❌ Bad:
1 2 | |
✅ Good:
1 2 3 | |
Use Theme Inheritance
✅ Good:
1 2 3 4 | |
❌ Bad:
1 2 3 4 5 | |
Troubleshooting
Theme Not Found
Issue:Theme 'my-theme' not found
Solutions:
- Verify theme directory exists:
themes/my-theme/ - Check
theme.yamlhas correctnamefield - Run
bengal utils theme listto see available themes
Template Inheritance Not Working
Issue: Changes to parent theme not reflected
Solutions:
- Verify
extendspath is correct:"default::base.html" - Check theme chain:
bengal utils theme debug - Clear cache:
bengal clean --cache
CSS Not Loading
Issue: Custom CSS not applying
Solutions:
- Use
asset_url()filter:{{ asset_url('css/style.css') }} - Check file location:
themes/your-theme/static/css/ - Hard refresh:
Cmd+Shift+R
Seealso
- Templating — Template basics
- Assets — Asset pipeline
- Icon Reference — SVG icons and customization
- Variables Reference — Available template variables