Please note: creating modules requires knowledge of HTML, CSS, HubL and the HubSpot design manager. It's recommended to work with a designer to create coded modules.
Create a new module
- In your HubSpot account, navigate to Marketing > Files and Templates > Design Tools.
- At the top of the finder, click the File dropdown menu and select New file.
- In the dialog box that appears, select Module.
- Choose whether you want to use this module in page templates, blog templates, and/or email templates.
- Select if you'd like the content scope of the module to be a local module or global module. If you create a global module, editing this module's content will update every location where the module is used. Learn how to work with smart content in a global module.
- Give the module a file name, then click Create.
Add fields to your module
- In the module inspector on the right, click the Add field
dropdownin the Fields section, then select a field to add to your module.
- You can edit the name of your field by clicking the pencil icon edit next to the field name. To edit the HubL variable name, make your changes in the HubL variable name text field.
Add field default content
In the Content Options section, you can add default content that appears when the module is used in templates and content editors. The options for default content will differ depending on the field type.
In the example below, the field type is an image field, so the default content options are to select a default image and hide size controls.
Set field editor options
In the Editor Options section, you can enable the following options:
- Make this field required: the user will not be able to leave this field blank.
- Prevent editing in content editors: the field content cannot be edited by end users when the module is selected in the content editor. The field content is still editable at the template level. This option is not available for global modules, which cannot be edited on the page level.
- Help text: add help text to the field to give users context or instruction.
Set field display conditions
You can customize a module field to only appear if another field meets certain criteria with field display conditions.
- In the Display Conditions section, click the HubL variable
dropdownmenu to select a module field, then click the is not empty dropdown to choose the condition for that field.
- If you select the condition is equal to, enter a value or regex.
In the example below, display conditions are being set for an image field. The condition is that the value in image_title (a text field) must be equal to Headshot in order for the image field to appear in the module.
The display conditions will be automatically enabled once you've set a condition. To disable the display conditions, click the toggle switch on the right of Display Conditions.
Set field repeater options
Lastly, you can set repeater options for your field. Repeaters are fields and groups that can create multiple objects and display them using a
- In the Repeater options section, select a minimum and/or
maximumnumber of required instances of this field.
- You can also choose to set a default object count, which will be the number of instances of the field that will appear by default in the module.
In the example below, the image field is being set up as an image slider. The object count limits are set
The repeater options will be automatically enabled once you've modified one of the options. To disable the repeater options, click the toggle switch on the right of Repeater Options.
Learn more about field repeating and loops in the designer documentation.
Copy and paste your field snippets
- When you're ready to incorporate one of your custom fields into your module, copy and paste the field snippet into the module's HTML + HubL editor.
- If you're in the field inspector, click Copy snippet on the right of the field's HubL variable name.
- If you're in the module inspector, hover over the field and click the Actions
dropdown, then select Copy snippet.
- Click into the location you'd like to add the field in the HTML + HubL editor, then paste the snippet by pressing Ctrl+V or Cmd+V.
Write your module syntaxAs you edit your module, you can write additional module syntax in the HTML + HubL, CSS, and JS editor panes. Learn more about the module code editor and module syntax reference in the designer documentation.
Preview your module
You can preview how your module will appear and work in a content editor by clicking the Preview button at the upper right of the module editor. The preview of your module will open in a new tab. This preview is synced to the editor and will automatically refresh as you work.
Publish your module
Once you're done adding fields, writing your module syntax, and are satisfied with how the module appears and works in the preview, you can proceed to publish your module. In the upper right, click Publish changes.
Make your module available for templates
- Switch the Make available for templates toggle on at the top of the editor to make this module available to add to your templates.
- Switch this toggle off to make changes or test the module's functionality. If this toggle is disabled, your team will see an alert that this module is not available for templates.
Add your module to a template
- In the template layout editor, click the Add tab at top of the layout inspector, then search for your module. Custom modules that you've created can be identified by the custom module icon
- Drag and drop the module into your template.
Add or purchase a module from the Marketplace
In addition to creating your own modules, you can add or purchase custom modules that other users or providers have created in the HubSpot Marketplace.
- In your HubSpot account, navigate to Marketing > Files and Templates > Template Marketplace.
- In the Filter products section on the left, click the All products dropdown under Category and select Modules.You can filter the available modules according to:
- Price: select if the module is free or paid
- Function: select the type of function(s) the module includes (e.g. calculator, gallery, map)
- Works with: select the template type(s) the module can be used in
- Provider: select the provider(s) the module is offered by
- Once you've decided on a module, hover over it and click View details.
- On the module details page, click Test this module at the upper right to test the module functionality before you add it to your design manager. For example, you can add your own custom content to see if this module will work for your site design.
- Click Get module for free or Buy module for $x at the upper right. If the module is free, it will automatically be added to your design manager. If the module is paid, proceed to enter your payment details.
- Once payment has been processed, the module will be added to your design manager.