EcoWeb -Website design Services

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.html

{% macro my_macro(title) %}
  {# add your code here #}
<h1>{{title}}</h1>
{% 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">
{{macros.my_macro}}
</div>