Import HubSpot Macros Into Any File

If you don’t know about the macro read this article ALL ABOUT HUBSPOT MACROS Keeping macros in single file and  Importing them into other files will keep your codebase cleaner.

Import Macros Into Other Files

First of all create a HTML file


{% macro my_macro(title) %}
  {# add your code here #}
{% endmacro %}


You can import your macro file into the project file you are working on. It could be a templatemodule.html, or CSS + hubl Stylesheet (not module.css)

{% import '../path/to/macros.html' as macros %}
<div class="macro-container">

Read More