Repository navigation
Theme Integration
This guide explains how theme developers can integrate the Backdrop Theme Setup library into their own Backdrop CMS themes.
The library is designed to be reusable. Developers do not need to use the example theme's machine name.
Backdrop Theme Setup separates three responsibilities:
- Native Backdrop configuration.
- JSON-driven setup operations.
- The theme settings interface.
The theme provides its own appearance and presentation.
Backdrop's Configuration Management system provides supported site configuration.
The Theme Setup library performs optional setup operations that complement the existing configuration.
Assume your theme is named my_theme.
A possible directory structure is:
my_theme/
├── my_theme.info
├── theme-settings.php
├── template.php
├── css/
│ └── style.css
├── includes/
│ └── theme-setup.inc
├── config/
│ ├── taxonomy.vocabulary.projects.json
│ ├── node.type.project.json
│ ├── field.field.field_image.json
│ ├── field.instance.node.project.field_image.json
│ └── views.view.featured_projects.json
└── settings-content/
├── taxonomy/
│ └── terms.json
├── content/
│ └── content.json
├── menu/
│ └── links.json
├── views/
│ └── filters.json
├── layouts/
│ ├── settings.json
│ └── blocks.json
└── files/
└── project-example.jpg
The configuration filenames above are illustrative. Use the exact filenames and configuration structures supported by your Backdrop version and modules.
Your theme may contain additional templates, CSS, JavaScript, and other assets.
Copy the reusable library into:
my_theme/includes/theme-setup.inc
Load it when executing setup operations:
$theme = 'my_theme';
$library = backdrop_get_path('theme', $theme) . '/includes/theme-setup.inc';
require_once $library;You can then call:
theme_setup_import_terms($theme);
theme_setup_import_content($theme);
theme_setup_import_menu_links($theme);The library's function names remain unchanged.
The example theme uses:
backdrop_theme_setup
Your own theme should use its own machine name.
For example:
my_theme
This affects:
- The theme directory.
- The
.infofilename. - Theme-specific hooks and form callbacks.
- The settings page URL.
- Theme-specific paths used by the library.
It does not require renaming the reusable theme_setup_ library functions.
Place supported native configuration files in your theme's config directory.
Examples include:
- Taxonomy vocabularies.
- Content types.
- Field definitions.
- Field instances.
- Views.
Use Backdrop's native configuration formats and APIs.
Important: Theme Setup does not directly import these native configuration files.
Their installation and availability depend on Backdrop's configuration handling.
Confirm that the required configuration is available before running setup operations that depend on it.
Create the settings-content directory and add the JSON files needed by your theme.
You do not need to use every available operation.
For example, a simple theme might only need:
settings-content/
├── taxonomy/
│ └── terms.json
└── content/
└── content.json
A more advanced theme may also configure menus, Views filters, and Layouts.
Each operation reads its corresponding JSON file.
Backdrop provides a theme settings form that can be extended with custom controls.
For a theme named my_theme, a theme-specific form alter function can use:
function my_theme_form_system_theme_settings_alter(&$form, &$form_state) {
// Add the theme setup controls here.
}The submit handler can load the library and execute selected operations.
For example:
function my_theme_setup_submit($form, &$form_state) {
$theme = 'my_theme';
$library = backdrop_get_path('theme', $theme) . '/includes/theme-setup.inc';
require_once $library;
// Execute only the operations selected by the administrator.
}This is an integration outline, not a complete replacement for the example project's theme-settings.php.
Use the example implementation as a reference for its form elements, validation, and submit behavior.
Import operations should be explicitly selected by an administrator.
Avoid automatically importing sample content simply because a theme is enabled.
Recommended behavior:
- Provide clearly labeled setup options.
- Allow individual operations to run independently.
- Explain operations that modify existing data.
- Avoid repeating imports unnecessarily.
- Display useful success and error messages.
- Keep setup action checkboxes separate from persistent appearance settings.
This makes theme setup more predictable and gives administrators greater control.
A typical setup sequence is:
- Install the theme and required modules.
- Make required native configuration available.
- Import taxonomy terms.
- Import sample content and managed files.
- Import menu links.
- Update Views taxonomy filters.
- Apply Layout settings.
- Configure Layout blocks.
- Flush selected image styles if needed.
Not every theme requires all these operations.
Before publishing your theme:
- Install it on a clean Backdrop site.
- Verify that required native configuration is available.
- Run each setup operation separately.
- Check imported content and files.
- Verify menu links.
- Inspect Views filters.
- Check Layout regions and block positions.
- Repeat selected operations to test duplicate handling.
- Review Backdrop log messages.
Also test what happens when required configuration is missing.
When distributing your theme, document:
- Required Backdrop version.
- Required modules.
- Required native configuration.
- Available sample content.
- Optional setup operations.
- Known limitations.
- Any changes the setup may make to existing Layouts or content.
Do not describe setup operations as automatically reversible unless rollback behavior has been implemented and tested.
The reference implementation is available at:
https://github.com/shabib-m/backdrop_theme_setup
Theme developers are welcome to adapt the integration approach and suggest improvements.
Backdrop Theme Setup is experimental. Review and test its implementation before using it on production websites.