Learn how to use HubL variables & macros to build dynamic pages on HubSpots CMS and emails.
}}
. The basic syntax of variables is as follows:
content.absolute_url
prints the URL of the specific piece of content.
HubSpot has many predefined variables that can be used throughout your page, blog, and email templates. We have a reference list of variables, you can also view the developer info when browsing any page from your account to see the variables available within that page..
In addition to printing the values of variables and dictionary attributes in a template, you can also define your own variables. You can store strings, booleans, integers, sequences, or create dictionaries within a single variable. Variables are defined within statement delimiters using the word “set”. Once stored, variables can then be printed by stating the variable name as an expression. Below you can see various types of information stored in variables and then printed.
Variables should either be single words or use underscores for spaces (ie my_variable). HubL does not support hyphenated variable names.
-
) to the start or end of a block, a comment, or a variable expression, the whitespaces before or after that block will be removed.
max recursion limit of 20 reached for macro <your macro name>
<p>
is added into a macro in addition to the two arguments.
my_macros.html
.
my_macros.html
file. It also names the group of macros (in this example header_footer
). Macros can then be executed by appending the macro name to the name given to the imported template. See the example below.
my_macros.html
file from the previous section of this article. But this time instead of importing all macros, it accesses only the footer macro.
.update
list operation: