What are Hubspot Themes and Modules and how to make one

What Are Hubspot Themes And Modules And How To Make One

In 2006, HubSpot was founded to help companies shift to grow better with inbound marketing. Since then Hubspot has grown and continues to grow both in the number of customers and the number of products/services they have to provide. To align with the “inbound marketing” principle that Hubspot was built on, Hubspot released its CMS Hub in April 2020 with the aim of making it easier for marketers to manage website content without the pain of writing code and any additional overhead.

The addition of the CMS hub provided a platform for marketers to deliver delightful website experiences without the necessary burden of writing any “code” (HTML, CSS & javascript the core building blocks of the web). The Core technology behind the CMS hub is defined as the following:

Website Hubspot Theme: A set of templates, modules, global content, and style settings that can be used to create a website. A Website Hubspot Theme Includes a set of files & Folders for your website on Hubspot, these files and folders include:

  • Coded templates: Templates for your website, including a homepage, about page, landing page, and blog templates. These templates are custom coded by a developer, but the content and layout can be customised.
  • Modules: A set of unique theme modules you can add to content using that theme.
  • Global content: Content repeated on multiple pages, such as a website header or footer.
  • Theme settings: Style settings for templates using a theme, including fonts, spacing, and colours.

While these themes and their associated resources are powerful and provide a no-code experience the underlying technology remains consistent with traditional web development (HTML, CSS, JS) with some additional Hubspot spices so to speak.

template Hubspot Theme Structure

These files will include some HTML, CSS, Javascript and Hubspot’s custom templating language i.e. Hubspot Markup Language also known as HubL (Hubspot “spices” so to speak), the combination of these technologies provides core fundamentals to enable marketers to add, edit and update content with ease. In the following, section we will explore the role these languages play to be able understand the Hubspot content ecosystem and further build/edit modules & Themes to provide custom functionality.

Now that we have a general understanding of what a Hubspot Theme and its elements look like, let us try and understand on a high level how Themes work and how they enable marketers to quickly and freely update content/styling and responsive elements* as they please.

With the rapid growth of any business comes the need to maintain relationships at scale via creating content and communicating quickly and correctly to the right audiences via a general forum (in this case websites), in larger organisations smaller changes websites can include multiple teams and respective elements from each team. For example, even a small website change might require content from marketers, oversight from IT teams, and implementation from developers, this process grows exponentially as changes get more complex and more frequent.

Hubspot’s Themes address this issue by bottling up the required “code”(HTML, CSS and JS) to cater to a multitude of “Layouts” or “Templates” using Hubl for the “content” or “data” that a marketer would like to add in a quick and easy manner. (Hubspot also provides a larger number of other benefits like Speed, Security, Scalability and the benefits it gains from being an all-on-one connected platform however since they are out of scope for this post we will not discuss them further.).

Based on the previous excerpt it is easy to see that even though these themes provide the ability to cater to a larger number of use cases, no single theme is a solution to all your possible web problems. However, since we know all the ingredients to bake a theme, logic suggests that we would be able to use traditional web development tools/languages like HTML, CSS & Javascript with Hubspot's HubL to technically create exactly what we could ever need. This is the exact thinking behind custom modules and the Hubspot Marketplace where technically driven individuals and companies create custom modules for a price or for free to help marketers achieve their goals and deliver complex web components without really having to touch any code.

Further to enable this completely customizable website experience hubspot provides us with modules, these modules are reusable components that can be used in templates or added to Hubspot pages through drag and drop areas.

These modules (web modules) use the following file structure to bottle the required “code” to function:

  • Module.html: Contains HubL and HTML to create a template structure.
  • Module.css: Contains the required styling for the module.
  • Module.js: Contains the required javascript for the module to perform.
  • Fields.json: A file used by Hubspot to provide content creators with the required control over the module in terms of styling and functionality.
  • Meta.json: A JSON file to hold the module's configuration.

At a glance we can articulate that the core building blocks of web dev still exist in the module i.e .html, .css & .js files and its nothing new, the true power of these modules are present in how HubSpot parses the information from the meta.json for its initial configuration and fields.json to interpret the required HubL and output the desired page that the content creator designed and a user views.

To understand the relationship between these files lets look into meta.json, field.josn and the HubL (stored mostly in module.html),

Meta.json:

This file contains core elements about what the module is like the modules icon, name, id etc and further this file contains where this module will be made available for content creators by defining elements like module content type (“LANDING_PAGE”, ”SITE_PAGE”, ”KNOWLEDGE_BASE” and more). A more detailed description of what options are available in this file is available here.

Fields.json:

This file defines the “fields” that the content creator will have access to be able to control the webpage in terms of content, style and more. Each field has a name, type, and default value, these fields and their values are the enable the bottled up HubL, HTML, CSS, JS to be rendered into the webpage/module to the end user.

Module.html [HubL]:

HubL is HubSpot’s unique templating engine language, this enables you to write “Templates” or “Layouts” so to speak, to then further fill in the required data/content/images/colours when the content creator has added the required into Hubspot via the fields provided (previously set in field.json).

Templating if done well, makes content creation and deployment easier, smoother, faster and scalable. This type of website/page building further and has a very low barrier of entry when compared to traditional web development which is another major plus point that adds to Hubspot’s CMS hubs capabilities.

A more detailed view of the capabilities of HubL is provided here.

Relationship between the Elements of a Hubspot Module

To implement and further build on our understanding of modules, let's create a simple module using Hubspot’s editor.

Creating a Module:

[While you have the option to write modules in your local environment, we will only cover creating modules via the Hubspot Design Manager to try and keep it simple ]

Creating the files:

1.Once Logged into Hubspot go to Content > Design Manager.

2.On the top of the menu click on the File drop down and then select “New File”

3.Select the “Module” when provided the option.

4.Click “Next” To proceed.

5.On this menu you will be able to update options that define the name and the type of module you would like to create, this menu also defines how and where the content creator would be able to view and add the module when designing and updating content.

6.Once the above steps have been completed, we will be provided with a blank canvas for the HTML + HubL, CSS and JS files for the modules.

7.The window on the right provides us with the ability to add and create fields that we would like the content creator to use to be able to add and update content.

8.This window also provides us an easy way for developers to provide the content creator to add and update the style of the content via the style fields.

Writing the Code:

Now that we have the required files let us write some code to create a simple module that creates a simple text card to display content from the content creator with a button that can be clicked to enable some user interaction.

1. In the module.html file create a simple HTML card with a h3, p and button element with some placeholder text to understand the look and feel of the button, something like this will suffice for now:

			<div class="module-card-container">
				<div class="module-card-content-container">
					<h3>Placeholder Header</h3>
					<p>Placeholder Body</p>
					<button>Placeholder Button</button>
				</div>
			</div>
		

2. In the module.css file add some styles that add some basic styles for a simple card, example code below:

			.module-card-container{
				max-width:300px;
				max-height:300px;
			}
			.module-card-content-container{
				display:flex;
				flex-direction:column;
				border:1px solid #000;
				margin:10px 0px;
				padding:10px 5px;
			}
			.module-card-content-container h3,
			.module-card-content-container p{
				color:#000;
				width:100%;
				height:100%;
			}
			.module-card-content-container p{
				overflow-y:scroll;
				height:150px;
			}
			.module-card-content-container button{
				width:150px;
				margin:auto;
			}
		

3. If you are following along, you can render the card by clicking the “Preview” button on the top right of your module development screen, your card should look similar to the image.

Initial hubspot module with placeholder values

4.Now that we have created a simple template, let's add 3 fields to enable the content creator to edit and update content into the card. Let's create 3 text fields to provide the content creator the ability to update and edit content on the card and Name and update the required fields appropriately for the header, body and button. Once you have created these fields the fields section should look something like the image below

Creating text fields in the hubspot modules

5.Once we have these fields in Hubspot we will be able to use HubL to directly pull the required content from the Hubspot editor into the HTML, by using the required HubL syntax to like “{{module.field_name}}”, depending on what you had set your field name you would add the required to your html to create your Template.

The updated HTML code with the HubL elements will look similar to the code below.

			<div class="module-card-container">
				<div class="module-card-content-container">
					<h3> {{module.header_text_field}} </h3>
					<p> {{module.body_text_field}} </p>
					<button> {{module.button_text_field}} </button>
				</div>
			</div>
		

6.Once that is done you will be able to see the editable fields on the side bar of the preview tab, any changes to the text here will directly update the card that was

Updated fields hubspot module

7. Now that we have a skeleton, let's look at how to implement a bit more HubL to provide the content creator with the ability to update the presets and toggle CSS class on the fly with simple settings.

8. Lets add duplicate the “module-card-content-container” and create 2 new variations “module-card-content-container-style-one” and “module-card-content-container-style-two” , this will enable us to conditionally apply the required styles to the module as we see fit. If you are Following along your CSS should look like this..

		.module-card-container{
			max-width:300px;
			max-height:300px;
			transition: all 1s ease-in-out;
		}
		.module-card-content-container-style-one{
			display:flex;
			flex-direction:column;
			border:1px solid #000;
			margin:10px 0px;
			padding:10px 5px;
		}
		.module-card-content-container-style-one h3,
		.module-card-content-container-style-one p{
			color:#000;
			width:100%;
			height:100%;
		}
		.module-card-content-container-style-one p{
			overflow-y:scroll;
			height:150px;
		}
		.module-card-content-container-style-one button{
			width:150px;
			margin:auto;
			cursor:pointer;
		}

		.module-card-content-container-style-two {
			display:flex;
			background-color:#000;
			box-shadow: 10px 5px 5px #808080;
			flex-direction:column;
			border:1px solid #fff;
			margin:10px 0px;
			padding:10px 5px;
		}
		.module-card-content-container-style-two h3,
		.module-card-content-container-style-two p{
			color:#fff;
			width:100%;
			height:100%;
		}
		.module-card-content-container-style-two p{
			overflow-y:scroll;
			height:150px;
			scrollbar-color: white black;
			scrollbar-width: thin;
		}

		.module-card-content-container-style-two button {
			box-shadow: 4px 2px 2px #fff;
			width:150px;
			margin:auto;
			cursor:pointer;
		}
		

9.Let's create an additional field in the fields section under styles, to control overarching card style and add additional style fields to update background colour and text colours and button style.

Hubspot Style Field on the Style Tab of the online editor

10. Let's add the required additional HubL to dynamically update our card with the new class names defined in the CSS and Hubspot Style Fields section display the changes for the card when the content creator updates the same.

			<div class="module-card-container">
				<div class="{{module.card_style.CardstyleChoice}}">
					<h3> {{module.header_text_field}} </h3>
					<p> {{module.body_text_field}} </p>
					<button> {{module.button_text_field}} </button>
				</div>
			</div>
		

11. Once your code has been updated you will be able to see the additional fields in the styles menu on the preview tab and will now be able to update the styles of the card.

You have now created a simple card module where a content creator can update the content and the styles, there are a plethora of complex tasks that can be achieved with the power of themes and modules and the fundamentals have been discussed here.

I would urge you to build and explore the Hubspot theme space to find better and more elements to add and create based on your needs/wants, as with these fundamentals and with the resources available online the possibilities are endless.

Conclusion:

In this article we went through on a high level what the Hubspot CMS hub is, what are Hubspot Themes and we built our own small functional Hubspot module that we can use.

Further, we explored how by adding abstractions to the traditional ways of web development i.e. HubL (Hubspot markup language), we are can develop tools that empower content creators to update elements like web pages, styles and more with little to no barrier when it comes to the ability to write code.

While there is so much more to be explored in this space, we have seen how easy it is to be able to create new modules from scratch and provide content creators with the ability to update content for these modules, including styling changes, content changes and more.