Building Custom CMS Templates with HubSpot

Table of Contents

  1. Introduction
  2. Accessing HubSpot's Design Manager
  3. Setting Up Your Templates
  4. Adding Modules
  5. Making the Most of Your Grid Layout
  6. Providing Options in the Front-End Template Module Editor
  7. Setting User-Defined Background Images
  8. Conclusion
  9. FAQs
Shopify - App image

Introduction

In the rapidly evolving landscape of digital marketing, a robust, customizable content management system (CMS) can provide a significant advantage. One such platform that has proven its mettle is HubSpot's Content Optimization System (COS). HubSpot COS enables users to create mobile-optimized websites, blogs, landing pages, and emails, fully integrated with HubSpot’s array of inbound marketing tools.

In this blog post, we will explore the key aspects of building custom templates within HubSpot’s COS. We’ll delve into setting up your template layout, integrating dynamic modules, and leveraging advanced features like tokens and conditional logic to deliver tailored content experiences.

By the end of this guide, you'll have a thorough understanding of how to utilize HubSpot’s tools to develop custom CMS templates that are both functional and adaptable to your specific needs.

Accessing HubSpot's Design Manager

To begin creating custom templates, we first need to access HubSpot's Design Manager. This can be done by logging into your HubSpot account and navigating to Content > Design Manager in the top navigation bar.

Setting Up Your Templates

Initial Steps

  1. Creating a New File: Within the Design Manager, initiate a new file by selecting "New File." A lightbox will appear, prompting you to choose the type of template.
  2. Choosing the Code Editor Option: For building custom templates, select the HTML & HubL option under the Code Editor. This will generate a basic markup to get you started with building your page template.

Template Builder vs. Coding From Scratch

HubSpot offers a Template Builder to create a basic layout efficiently. If preferred, you can clone this template to a new file by selecting Actions > Clone to File, which will generate an HTML file with the needed HubL code. While using the Template Builder can save time, it may become unwieldy without careful management. Alternatively, you can code from scratch by incorporating the necessary module tags and standard header and footer tokens.

Adding Modules

Dynamic modules are key to creating versatile templates. In HubSpot, you can choose from standard modules or create custom ones from scratch. The standard module syntax is user-friendly and supports a variety of content types.

Two Important Module Parameters

  1. Export_to_template_context=True: This parameter allows exporting data from the module to the template. It's particularly useful when building templates with more custom features.

  2. No_wrapper=True: By default, HubSpot wraps module content in div or span tags. Including no_wrapper=True can disable this, depending on your template requirements.

Making the Most of Your Grid Layout

HubSpot uses a 12-column grid system based on Bootstrap 2 (though Bootstrap 4 is the latest version). You can adhere to this framework or develop a custom grid layout for more complex designs.

Providing Options in the Front-End Template Module Editor

Using the Code Editor offers greater control over template design and functionality. Users unfamiliar with HTML can still make adjustments directly in the front-end template editor by using modules and conditional logic.

Setting Up the Choice Module

The choice module provides a list of pre-determined values for end-users. The module tag typically looks like this:

{% module "optional_content_block" choice_value="No,Yes" export_to_template_context=True %}

In the template module editor, this will render as a drop-down list allowing users to select "No" or "Yes" for optional content.

Conditional Logic Integration

HubSpot's conditional logic tags enable dynamic content based on module choices. For instance:

{% if optional_content_block == "Yes" %}
  <!-- Your content here -->
{% endif %}

This code ensures the content block only displays if "Yes" is selected, providing flexibility and control over what users see.

Setting User-Defined Background Images

Adding dynamic background images can enhance your templates significantly. The process involves incorporating an image module and setting up CSS with the appropriate token.

Steps:

  1. Add an Image Module: Positioning higher in the template is recommended.
  2. Configure CSS: Embed the image module's token within your CSS for custom background images.

Conclusion

Creating custom CMS templates within HubSpot’s COS allows for impressive versatility and functionality. By understanding how to set up initial templates, integrate dynamic modules, and use advanced features like conditional logic and custom background images, you can build robust, user-friendly templates tailored to your specific needs.

Building applications with templates doesn’t have to be a complex process with the correct tools and approaches. By following the outlined steps and exploring further advanced features, you can harness the full power of HubSpot’s Content Optimization System.

FAQs

Q: Can I create custom modules from scratch in HubSpot's Design Manager?
A: Yes, you can create custom modules using HubSpot’s Code Editor. The platform allows you to define module types and integrate them into your templates seamlessly.

Q: What is the benefit of using the 'export_to_template_context=True' parameter?
A: This parameter enables you to export module data into the template, providing greater flexibility and control over your template’s functionality.

Q: Is coding knowledge required to use HubSpot’s Template Builder?
A: Although coding knowledge allows for more advanced customizations, HubSpot’s Template Builder provides a user-friendly interface for creating basic layouts without requiring extensive coding skills.

Q: How does HubSpot’s grid system work?
A: HubSpot uses a 12-column grid system based on Bootstrap 2. You can either follow this framework or customize your grid layout according to your design needs.

Q: Can I disable the default wrapping of module content in HubSpot?
A: Yes, by including the parameter 'no_wrapper=True' in your module’s syntax, you can prevent HubSpot from wrapping content in div or span tags.


This comprehensive guide aims to provide actionable insights into building custom CMS templates with HubSpot, ensuring you're well-equipped to create dynamic and functional web assets tailored to your brand's needs. Happy designing!