Skip to content

HubL essentials ​

Everyday Classic CMS building blocks.

Require assets ​

jinja
{{ require_css(get_asset_url('/css/main.css')) }}
{{ require_js(get_asset_url('/js/main.js'), { position: 'footer', defer: true }) }}

CDN example (footer, defer):

jinja
{{ require_js("https://cdnjs.cloudflare.com/ajax/libs/plyr/3.7.8/plyr.min.js", { position: "footer", defer: true }) }}
{{ require_css("//cdnjs.cloudflare.com/ajax/libs/plyr/3.7.8/plyr.min.css", { async: true }) }}

Variables & defaults ​

jinja
{% set title = module.title|default('Hello') %}
{{ title|escape_html }}

Conditionals ​

jinja
{% if module.show_banner %}
  <div class="banner">{{ module.banner_text }}</div>
{% endif %}

Loops ​

jinja
{% for item in module.cards %}
  <article>{{ item.heading }}</article>
{% endfor %}

Macros ​

jinja
{% macro button(label, href) %}
  <a class="btn" href="{{ href }}">{{ label }}</a>
{% endmacro %}

{{ button('Contact', '/contact') }}

Escape & safety ​

Prefer filters like escape_html, escapeattr, and HubSpot’s sanitization guidance for user-influenced content.

Editor detection ​

Useful for editor-only UI (patterns vary by theme generation) — keep presentation logic in modules, not random globals.

  • Full historical notes lived in the old helpers repo under hubl/
  • New builds: prefer CMS React when greenfield allows