Latest CMS Developer Posts

HubSpot CMS Blog

Custom Modules now accessible by path

Written By Michele Herzog on Feb 8, 2019 11:10:18 AM

Most of the development world relies on a system of referencing a file by its path. Developers organize and reference their assets based on where they live.

Until now, developers have had to reference custom modules based on a HubSpot id, which is completely removed from their folder structure. Now, developers can utilize their own organization patterns to reference their custom modules, creating a more seamless, consistent workflow.

Usage 

The following methods can be used as a module tag.

Module ID

This is the default method to include a module in a coded file.

{% module "module" module_id=123 %}

 

Absolute Path NEW

This is the recommended method. To get a module by absolute path, start the path with a slash:

{% module "module" path="/absolute/path/to/Module" %}

 

Relative Path NEW

You can also get a module by path relative to the template by leaving out the slash:

{% module "module" path="relative/path/to/Module" %}

We support the ".." and "." delimiters in relative paths. Use ".." to go up a level, and "." to stay in the current level:

{% module "module" path="../ModuleName" %}
{% module "module" path="./ModuleName" %}

 

HubSpot Default NEW

To reference a HubSpot default module, use the "@hubspot" syntax:

{% module "module" path="@hubspot/rich_text" %}

 

Parameters

PARAMETER TYPE DESCRIPTION
module_id String The id of the module to render
path String The path of the module to render. Include leading slash for absolute path, otherwise path is relative to template. Reference HubSpot default modules with paths corresponding to their HubL tags such as @hubspot/rich_text, @hubspot/linked_image, etc.

 

This feature is now live to all Marketing Hub Professional and Enterprise users, as well as users of HubSpot CMS.

Topics: Product Updates, Website Development, CMS

Michele Herzog

Michele is a Product Expert for design and development tools at HubSpot. Tell your dog they say hello.

Stay Up To Date 👇

Learn how to code on HubSpot CMS
  • There are no suggestions because the search field is empty.
 
Join the HubSpot CMS Developer Slack

Ask questions in the CMS Developer Forum

Join the free CMS for Developers Course

View the HubSpot API Documentation

Recommended Posts