Building HubSpot CMS themes that allow developers to build design systems for content creators work within.
fields.json
file.
theme.json
and fields.json
. These files should be included at the root theme folder.
To start from an example, see the HubSpot CMS Boilerplate.
theme.json
file contains the meta-information for your theme directory, such as the themes readable label, its preview screenshot and various configurations for how the theme should behave. Your theme.json
file will look similar to the following:
Parameter | Type | Description |
---|---|---|
label | String | The readable label of the theme, used in various places the theme is shown throughout the HubSpot app, like the template selection screen and the theme editor. |
preview_path | String | A relative path to a template file in the theme which should be the default template, used when previewing a theme in the theme editor. |
screenshot_path | String | A relative path to an image file that is used to give a snapshot of what the theme looks like in various places theme selection occurs, such as in the template selection screen. |
enable_domain_stylesheets | Boolean | Enabling or disabling stylesheets attached to domains in Website Settings getting included on templates within the theme. The default value is false . |
version | String | Integer version number supporting . versions. |
Author | object | Object to provide information about yourself as the theme provider.name The provider’s name. email The provider’s support email address. url The provider’s website. |
documentation_url | String | The theme documentation link. |
example_url | String | The theme live example link. |
license | String | A valid SPDX Identifier or the relative path to the license within your theme.This license dictates what use and modification is permitted by the creator of the theme. Useful when submitting to the marketplace. |
is_available_for_new_content | Boolean | Boolean that determines if a theme shows up in the content creator page for selection. The default value is true . |
fields.json
file controls the available fields and field groups in the theme editor, including style fields. The fields you include will depend on how much control you want content creators to have in the page editor. The number of fields available for themes is more limited than for modules, as theme fields are best for styling options, while global content is better for theme content.
For example, rather than adding a text field to the theme’s field.json
for your site’s tagline, it should add it as a global module so that content creators can update the tagline from the page editor rather than the theme editor.
The fields that are available for use in themes are:
For comprehensive documentation on the possible options for theme fields, see the module and theme fields documentation.
fields.json
with theme. You can use a themes fields value in your stylesheets using syntax like {{ theme.path.to.value }}
. For example, the font field outlined below:
?testmode=true
to the URL, then hit enter. You’ll then be in test mode.?testmode=true
to the URL in your address bar.