If you’re working with HubSpot Content Hubyou’ll eventually run into HubL (HubSpot Markup Language) — the engine behind dynamic templates, modules, and content rendering.
Instead of searching documentation every time, this HubL cheat sheet gives you practical, ready-to-use snippetsthat you can plug directly into your templates and modules.
HubL is HubSpot’s templating language used inside:
It allows you to:
Display Page Name
{{ content.name }}
Display Page Title
{{ page_meta.html_title }}
Display Current URL
{{ request.path }}
Simple If Condition
{% if contact.firstname %}
Hello {{ contact.firstname }}
{% endif %}
If / Else
{% if contact.firstname %}
Hi {{ contact.firstname }}
{% else %}
Hi there!
{% endif %}
Multiple Conditions
{% if contact.lifecycle_stage == "customer" %} Welcome back!
{% elif contact.lifecycle_stage == "lead" %} Check out our demo
{% endif %}
Loop Through Blog Posts
{% for post in blog_recent_posts %}Loop with Limit
{% for post in blog_recent_posts limit=3 %}Get Table Rows
{% set rows = hubdb_table_rows(123456) %}
Loop Through HubDB Rows
{% for row in rows %}
<h3>{{ row.name }}</h3>
{% endfor %}
Filter HubDB Rows
{% set rows = hubdb_table_rows(123456, "city=Delhi") %}
Internal Page Link
<a href="{{ content.absolute_url }}">View Page</a>
File Link
<a href="{{ file_by_id(123).url }}">Download</a>
Access Text Field
{{ module.heading }}
Image Field
<img src="{{ module.image.src }}" alt="{{ module.image.alt }}">
Link Field
<a href="{{ module.link.url }}">{{ module.link.text }}</a>First Name Token
{{ contact.firstname }}
Fallback Value
{{ contact.firstname|default("there") }}
Uppercase
{{ "hello"|upper }}
Lowercase
{{ "HELLO"|lower }}
Truncate Text
{{ post.summary|truncate(100) }}
{{ post.publish_date|datetimeformat('%b %d, %Y') }}
Get Query Parameter
{{ request.query_dict.search }}
Detect Device (basic)
{{ request.user_agent }}Include Another File
{% include "custom/header.html" %}
{% for item in module.features %}
<h3>{{ item.title }}</h3>
{% endfor %}
{{ site_settings.company_name }}
{{ module.rich_text|safe }}
Print Variable
{{ variable|pprint }}
{% if blog_page_has_next_page %}
<a href="{{ blog_next_page_url }}">Next</a>
{% endif %}
{{ content.slug }}
HubL is the backbone of dynamic websites in HubSpot Content Hub. By mastering a small set of powerful snippets, you can build scalable, flexible, and highly customized websites without reinventing the wheel every time.