Create and edit modules
Last updated: October 13, 2020
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.
Label your module
The module label is what displays in the design manager and content editor when adding the module to your page or email. You can search for a module in the design manager and content editor by its module name or its label. If left blank, the module will display the module name instead.
Add fields to your module
- In the module inspector on the right, click the Add field
dropdownmenu in the Fields section, then select a field to add to your module.
- 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.
- Tooltip help text: add help text to the field to give users context or instruction. This help text will appear in a tooltip when a user hovers over the field while editing.
- Inline help text: add help text to the field to give users context or instruction. This help text will appear below the field when a user is editing the module.
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 HubSpot's designer documentation.
Add help text to your module
In the Editor options section, add help text to give users context when editing the module. Help text can be no longer than 300 characters.
When a user edits the module in a content editor, the help text will appear above the module fields.
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 syncs with 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, click the Marketplace icon marketplace in the main navigation bar.
- 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.
- 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.
Personalize your content
With personalization tokens, you can show personalized content to contacts in your CRM database....Knowledge Base
Add smart content to your emails, website pages, landing pages, and templates
With smart content, a module can display different versions of your content based on certain viewer criteria.Knowledge Base
Build a custom coded template
In your design manager tool, designers can build templates with HTML from scratch. For Marketing Hub ...Knowledge Base