Quickly find the HubL syntax you need! This comprehensive cheat sheet provides a handy reference for HubSpot’s templating language, including functions, filters, variables, and tags. This will save you time combing through the HubSpot CMS developer docs navigation or performing Google searches. You can learn more about HubSpot here.
I provide freelance HubSpot development support. Stop wasting hours debugging and get it fixed today.
What is HubL?
HubL (HubSpot Markup Language) is the server-side templating language used to build dynamic assets in the HubSpot CMS. Based on Jinja (Python), HubL allows you to create custom modules, write conditional logic, and pull live CRM data directly into your HTML.
Top 3 Most Used HubL Snippets
If you are developing custom templates, you will use these three HubL structures daily. Copy and paste them directly into your Design Manager.
1. HubL If-Statements (Conditional Logic)
Use if-statements to show or hide HTML based on user data, module settings, or CRM properties.
{% if module.show_button %}
<a href="{{ module.button_link }}" class="btn">{{ module.button_text }}</a>
{% elif module.show_secondary_text %}
<p>Secondary option selected.</p>
{% else %}
<p>Default text rendered here.</p>
{% endif %}
2. HubL For-Loops (Iterating Data)
Loops are essential for rendering blog posts, repeating module fields, or parsing HubDB rows.
<ul>
{% for item in module.repeated_list %}
<li>{{ item.name }} - {{ item.price | format_currency("en-US") }}</li>
{% endfor %}
</ul>
3. Common HubL Filters
Filters modify how a variable is displayed. You apply a filter by adding a pipe ( | ) after the variable name.
{{ variable_name | upper }}– Converts text to UPPERCASE.{{ variable_name | strip_tags }}– Removes all HTML tags from a string (useful for meta descriptions).{{ variable_name | truncate(150) }}– Cuts off text after 150 characters.
Full HubL Reference Directory
Looking for a specific tag or function? Browse the complete HubL reference below.