[object Object]

HubL gets dismissed as “Jinja with extra steps.” It’s not. It has CRM-aware filters, HubDB integration, and dynamic personalization that beats client-side scripts on performance and SEO. Here are eight patterns worth memorizing.

1. Conditional CTA by lifecycle

{% if contact.lifecyclestage == "customer" %}
  {% module "support_cta" path="@hubspot/cta" cta_id="abc123" %}
{% else %}
  {% module "demo_cta" path="@hubspot/cta" cta_id="def456" %}
{% endif %}

Server-rendered. No flash, no SEO penalty.

2. Smart timezone in emails

{% set local_time = now().to_string("%I:%M %p") %}
We're sending this at {{ local_time }} {{ contact.hs_timezone }}.

Personalizes time-of-day references without a JavaScript scramble.

3. Loop a HubDB table for dynamic listings

{% set rows = hubdb_table_rows(123456, "category=pricing&orderBy=display_order") %}
{% for row in rows %}
  <li>{{ row.name }} — {{ row.price }}</li>
{% endfor %}

The query string syntax is HubSpot’s lesser-known filter API. Use it.

4. Default-fallback chain

{{ contact.firstname|default(contact.email|split("@")|first|default("there")) }}

Falls back through firstname, email username, then “there.” No nested if blocks.

5. Format currency by locale

{{ deal.amount|format_currency_value(locale="de-DE", currency="EUR") }}

Beats hand-rolling Intl.NumberFormat in a script tag.

6. Truncate with ellipsis safely

{{ blog_post.post_summary|truncate(160, true, "...") }}

Second arg true respects word boundaries. Critical for meta descriptions.

7. Inline a module’s content with module_block

{% module_block module path="@hubspot/rich_text" %}
  {% module_attribute "html" %}<p>Inline content here.</p>{% end_module_attribute %}
{% end_module_block %}

Build reusable modules with content overrides instead of one-off rich text fields.

8. Conditional require_css/js

{% if content.absolute_url contains "/pricing" %}
  {% require_css get_asset_url("../css/pricing.css") %}
{% endif %}

Ship route-scoped CSS without a build step. Lighthouse scores go up immediately.

What to do this week

Replace one client-side personalization hack on your highest-traffic page with a HubL conditional. Measure CLS before and after.

[object Object]
Share