Skip to main content

Functions in HubL are similar to filters in that they accept parameters and generate a value. However, not all functions need to be applied to an initial template value, and instead they interact with other areas of your HubSpot environment.

If you maintain an older website, you may also want to check out the list of deprecated HubL functions.

Below, learn more about each HubL function and its syntax.

Adds a single item to the end of a list.

ParameterTypeDescription
itemAnyItem to be appended to the list.

The blog_all_posts_url function returns a full URL to the listing page for all blog posts for the specified blog.

The example below shows how this function can be used as an anchor's href.

ParameterTypeDescription
selected_blogBlog id or "default"Specifies which blog to use. The blog id is returned by the module blog field.

The blog_author_url function returns a full URL to the specified blog author's listing page.

The example below shows how this function can be used as an anchor's href. This can be combined with blog_authors as shown in that function's examples.

ParameterTypeDescription
selected_blogBlog ID or "default"Specifies which blog the author's listing page exists in. You can specify a blog by ID or use "default" to select the default blog. The blog ID is returned by the module blog field.
author_slugString or HubL VarSpecifies which author to link to. Can use either content.blog_post_author.slug or a lowercase hyphenated name. Example: "jane-doe".

The blog_authors function returns a sequence of blog author objects for the specified blog, sorted by slug ascending. This sequence can be stored in a variable and iterated through to create custom author post filters.

The number of live posts by each author can be accessed with author.live_posts.

The first line of the example below shows how the function returns a sequence of author objects. The rest of the example shows a use case of saving a sequence into a variable and then iterating though the author objects, printing a set of author listing links. The example assumes that the blog has 4 authors.

ParameterTypeDescription
selected_blogBlog ID or "default"Specifies which blog to use, either a specific blog by its ID or the default blog by "default". The blog ID is returned by the module blog field.
limitIntegerSets the limit on the number of authors fetched.

The blog_by_id function returns a blog by ID. The below example code shows this function in use to generate a hyperlinked list item.

ParameterTypeDescription
selected_blogBlog ID or "default"Specifies which blog to use, either a specific blog by its ID or the default blog by "default". The blog ID is returned by the module blog field.

The blog_page_link function generates the URL of a paginated view of your blog listing. The function takes a numeric parameter, which allows you to generate links for current, next, previous, or a specific page. This function is generally used in the href attribute of pagination anchor tags and must be used on your blog listing template.

The examples below show this function in use as an anchor href. The first example outputs the current page. The second example takes the number 7 parameter to specify the seventh page. The third example uses the next_page_num variable to generate a link that is relative to the current page number (you can also use the last_page_num variable for the previous page). The final example uses the current_page_num variable and a + operator to create a link that is 4 greater than the current page.

ParameterTypeDescription
pageNumber or HubL variablePage number used to generate URL or HubL variable for page number.

This function renders a set number of popular posts into a sequence. The sequence can then be saved into a variable and iterated through with a for loop, creating a custom post listing of your most popular posts.

Results from this function are cached for six hours. To retrieve blog posts using HubL in a way that avoids caching, you may want to use blog_recent_tag_posts instead.

In the example code below, the first line shows how the function returns a sequence. The sequence is saved as a variable which is then used in a for loop. Any blog post variables should use the name of the individual loop item rather than content.. In the example, pop_post.name is used. This technique can be used on blog templates and website pages.

ParameterTypeDescription
selected_blogBlog ID or "default"Specifies which blog to use, either a specific blog by its ID or the default blog by "default".
limitIntegerSpecifies the number of posts to add to the sequence up to a limit of 200. If not specified, defaults to 10.
tag_slugArrayOptional list of tags to filter posts by.
time_frameStringOptional timeframe of analytics to filter posts by. Default is "popular_past_year". Must be one of:
  • "popular_all_time"
  • "popular_past_year"
  • "popular_past_six_months"
  • "popular_past_month"
This parameter is required when including the logical_operator parameter.
logical_operatorStringWhen tag_slug contains multiple tags, use this operator to filter results with AND or OR logic. By default, this function uses OR logic to return posts tagged with any of the specified tags.When including this parameter, time_frame is required.

The blog_post_archive_url function returns a full URL to the archive listing page for the given date values on the specified blog. This function has two required parameters and two optional parameters. The first parameter is a blog ID or simply the keyword "default". The second is the year of archived posts you'd like to display.

The optional parameters include the month and day of archived posts you'd like to display, respectively.

The example below shows how this function can be used as an anchor's href.

ParameterTypeDescription
selected_blogBlog ID or "default"Specifies which blog to use, either a specific blog by its ID or the default blog by "default".
yearIntegerThe year.
monthIntegerThe optional month.
dayIntegerThe optional day.

The blog_recent_author_posts function returns a sequence of blog post objects for the specified author, sorted by most recent. This sequence of posts can be saved into a variable and iterated through with a for loop, creating a custom post listing of posts by a particular author.

The function takes three parameters. The first parameter specifies which blog to collect posts by an author from. The value should be "default" or the blog ID of a particular blog (available in the URL of the Blog dashboard). The second parameter specifies which author to use. This parameter can use the content.blog_post_author.slug to use the author of the current post or accepts a lowercase hyphenated name such as "brian-halligan". The third parameter specifies how many posts are retrieved.

The first line of the example below demonstrates how the function returns a sequence of posts by an author. In this example, rather than specifying an exact author name, the current post author is used. The sequence is saved in a variable and looped through. Any blog post variables should use the name of the individual loop item rather than content.. In the example, author_post.name is used. This technique can be used on blog and page templates.

ParameterTypeDescription
selected_blogBlog ID or "default"Specifies which blog to use. The blog ID is returned by the module blog field.
author_slugStringSpecifies which author to filter on.
limitIntegerSpecifies the number of posts to add to the sequence up to a limit of 200.

The blog_recent_posts function returns a sequence of blog post objects for the specified blog, sorted by most recent first. This sequence of posts can be saved into a variable and iterated through with a for loop, creating a custom post listing of your most popular posts.

The function takes two parameters. The first parameter specifies which blog to collect popular posts from. The value should be "default" or the blog ID of a particular blog (available in the URL of the Blog dashboard). The second parameter specifies how many posts are retrieved.

The first line of the example below demonstrates how the function returns a sequence. The sequence is saved in a variable and looped through. Any blog post variables should use the name of the individual loop item rather than content.. In the example, rec_post.name is used. This technique can be used, not only on blog templates, but also regular pages.

ParameterTypeDescription
selected_blogBlog ID or "default"Specifies which blog to use, either a specific blog by its ID or the default blog by "default". The blog ID is returned by the module blog field.
limitIntegerSpecifies the number of posts to add to the sequence, maximum 200.

The blog_recent_tag_posts function returns a sequence of blog post objects for a specified tag or tags, sorted by most recent first. This sequence of posts can be saved into a variable and iterated through with a for loop, creating a custom post listing of posts by a particular tag or tags.

In the example code below:

  • The first line shows how the function returns a sequence of posts by tag.
  • The second line shows how to save the function in a sequence variable. The rest of the code then uses a for loop to cycle through the variable values. Any blog post variables should use the name of the individual loop item rather than content.. In the example, tag_post.name is used. You can use this technique on both blog and website pages.
ParameterTypeDescription
selected_blogBlog ID or "default"Specifies which blog to use, either a specific blog by its ID or the default blog by "default". The blog ID is returned by the module blog field.
tag_slugStringSpecifies which tag to filter on. You can include up to 10 tags, comma separated. Tags with multiple words must be lowercase with spaces replaced by hyphens.
limitIntegerSpecifies the number of posts to add to the sequence. This parameter is required when including a logical_operator.
logical_operatorStringWhen tag_slug contains multiple tags, use this operator to filter results with AND or OR logic. By default, this function uses OR logic to return posts tagged with any of the specified tags.When including this parameter, limit is required.

The blog_tag_url function returns a full URL to the specified blog tag's listing page.

This function accepts two parameters. The first parameter specifies which blog the tag's listing page exists in. The second parameter specifies which tag to link. This parameter can use the topic.slug for a particular tag from content.topic_list or accepts a lowercase hyphenated name such as "marketing-tips".

The example below shows how this function can be used as an anchor's href.

ParameterTypeDescription
selected_blogBlog ID or "default"Specifies which blog to use, either a specific blog by its ID or the default blog by "default".
tag_slugStringSpecifies which tag to link to.

The blog_tags function returns a sequence of the 250 most blogged-about tags (based on number of associated blog posts) for the specified blog, sorted by blog post count.This sequence can be stored in a variable and iterated through to create custom tag post filters. The number of posts for each tag can be accessed with tag.live_posts.

This function accepts two parameters. The first parameter specifies which blog to fetch tags from. The second parameter sets a limit on the number of tags fetched.

The first line of the example below demonstrates how the function returns a sequence of tag objects. The rest of the example demonstrates a use case of saving a sequence into a variable and then iterating though the tag objects, printing a set of tag links. The example assumes that the blog has 4 tags.

ParameterTypeDescription
selected_blogBlog ID or "default"Specifies which blog to use. The blog ID is returned by the module blog field.
limitIntegerThe maximum amount of tags to return.

This function returns the total number of published posts in the specified blog. If no parameter is specified, it will count your default blog posts. Alternatively, you can specify "default" or a blog ID of a different blog to count. The blog ID is available in the URL of your blog dashboard for a particular blog.

ParameterTypeDescription
selected_blogBlog ID or "default"Specifies which blog to count. The blog ID is returned by the module blog field.

Removes all items from a list. Unlike pop(), it does not return anything.

This function validates color contrast based on WCAG standards. You'll need to include two colors as arguments, and you can include an optional argument to specify the rating (AA or AAA). Returns true or false based on whether the colors meet/exceed the standard.

ParameterTypeDescription
color_1RequiredColorThe first color to compare. Accepts:
  • 6-digit hex codes (#FFFFFF)
  • 3-digit hex codes (#F0A)
  • RGB color codes (rgb(12,31,1))
Can also use a variable that stores a hex or RGB color code. For example:theme.primary_color.color
color_2RequiredColorThe second color to compare against the first.
ratingStringThe WCAG standard to use for rating. Can be either AA (default) or AAA.

This function lightens or darkens a hex value or color variable by a set amount. The first parameter is the hex color (for example ("#FFDDFF") or a variable storing a hex value. The second parameter is the amount to adjust it by, from 0 to 255. This function can be used in CSS files to create a color variation. Another good use case is to use it with a color parameter of a color module, to allow users to specify a primary color that automatically generates a color variation.

In the example below, the hex color #3A539B is stored in a variable called base_color. The color is modified by -80 resulting in a darker blue (#00034B).

ParameterTypeDescription
base_colorHEX color stringThe starting color to be altered. For example, #F7F7F7.
brightness_offsetIntegerA positive or negative number used to lighten or darken the base color.

The content_by_id function returns a landing page, website page or blog post by ID. The only parameter accepted by this function is a numeric content ID.

The below example code shows this function in use to generate a hyperlinked list item.

ParameterTypeDescription
idIDThe ID of the content to look up.

Given a list of content IDs, returns a dict of landing page, website page or blog posts matching those IDs.

This function takes one parameter, a list of page or blog post IDs to look up, placed within an array. Up to 100 content objects can be passed. The below example code shows this function in use to generate a list of hyperlinked list items.

ParameterTypeDescription
idsListA list of page or blog post IDs to look up. Up to 100 content objects can be passed.

Return a shallow copy of the list. Equivalent to a[:].

A shallow copy constructs a new compound object and then (to the extent possible) inserts references into it to the objects found in the original.

Returns the number of times a variable exists in a list.

Gets a list of CRM records associated with another record by its record ID, association category, and association definition ID.

This function returns an object with the following attributes: has_more, total, offset and results.

  • has_more indicates there are more results available beyond this batch (total > offset).
  • total is the total number of results available.
  • offset is the offset to use for the next batch of results.
  • results returns an array of the specified associated objects matching the function's parameters
ParameterTypeDescription
idRequiredIDID of the record to find associations from.
association categoryRequiredStringThe category of the association definition. Possible values are HUBSPOT_DEFINED, USER_DEFINED, and INTEGRATOR_DEFINED. This parameter can be omitted for hubspot defined built-in association types.
association type idRequiredIntegerThe ID of the association definition to use. For standard HubSpot supported objects see ID of the association type to use.Otherwise, this association ID can found at the CRM Objects Schema API.
queryStringThe id of the record OR a query string, delimited by &. All expressions are ANDed together. Supported operators are:
  • eq (default)
  • neq
  • lt
  • lte
  • gt
  • gte
  • is_null
  • not_null
  • in
  • nin
  • contains (applicable for multi-valued properties or string properties, e.g., "firstname__contains=Tim")
Queries can include the following parameters:
  • limit: the maximum number of results returned in the response. For example, limit=50.
  • offset: for paging through the results if the number of returned results is higher than the limit parameter. For example, offset=51.
  • orderBy: order results by a specific property. For example, orderBy=email.
propertiesStringOptional. A comma-separated list of properties to return. By default, a small set of common properties are returned. The ID property is always returned.A full list of properties can be found using the get all contact properties and get all company properties endpoints.
formattingBooleanOptional. Format values such as dates and currency according to this portal's settings. Omit or pass false for raw strings.

Gets a single CRM record by query or by its ID. Records are returned as a dict of properties and values.

This function can also be used with custom and integrator objects.

ParameterTypeDescription
object_typeStringThe object type name. Object type names are case sensitive.The supported object types. To find the names of the account specific and integrator object types available in your account use the CRM Objects Schema API to get the type definitions and look for the name property. It contains the internal object type name that should be used in the functionFor integrator and account specific object types with the same name as the built-in objects use the objects fully qualified name (FQN).
queryStringOptional. The id of the record OR a query string, delimited by &. All expressions are ANDed together. Supported operators are:
  • eq (default)
  • neq
  • lt
  • lte
  • gt
  • gte
  • is_null
  • not_null
  • in
  • nin
  • contains (applicable for multi-valued properties or string properties, e.g., "firstname__contains=Tim").
Queries can include the following parameters:
  • limit: the maximum number of results returned in the response. For example, limit=50.
  • offset: for paging through the results if the number of returned results is higher than the limit parameter. For example, offset=51.
  • orderBy: order results by a specific property. For example, orderBy=email.
propertiesStringOptional. A comma-separated list of properties to return. By default, a small set of common properties are returned. The ID property is always returned.A full list of properties can be found using the get all contact properties and get all company properties endpoints.
formattingBooleanOptional. Format values such as dates and currency according to this portal's settings. Pass false for raw strings.

Gets a list of records for a specific object type from the HubSpot CRM.

This function returns an object with the following attributes: has_more, total, offset and results.

  • has_more indicates there are more results available beyond this batch (total > offset).
  • total is the total number of results available.
  • offset is the offset to use for the next batch of results.
  • results returns an array of the specified objects matching the function's parameters.

Results can be sorted using at least one order parameter in the query. For example, crm_objects("contact", "firstname=Bob&order=lastname&order=createdate") will order contacts with the first name "Bob" by last name and then by createdate. To reverse a sort, prepend - to the property name like order=-createdate. The CRM objects function can also be used with custom and integrator objects.

ParameterTypeDescription
object_typeStringThe type of object by name. Object type names are case sensitive. Singular and plural are accepted for standard object types (e.g., contact, contacts). Learn more about the supported object types. To find the names of the account specific and integrator object types available in your account, use the CRM objects schema API to get the type definitions and the name property.For integrator and account specific object types with the same name as the built-in objects, use the objects fully qualified name (FQN).
queryStringOptional. The ID of the record or a query string, delimited by &. All expressions are ANDed together.Supported operators are:
  • eq (default)
  • neq
  • lt
  • lte
  • gt
  • gte
  • is_null
  • not_null
  • in
  • nin
  • contains (applicable for multi-valued properties or string properties, e.g., "firstname__contains=Tim").
Example: "email=contact@company.com"
propertiesStringOptional. A comma-separated list of properties to return. By default, a small set of common properties are returned. The ID property is always returned. A full list of properties can be found using the get all contact properties and get all company properties endpoints.The record ID is always included in the returned object properties even when not explicitly added in the property list.
formattingBooleanOptional. Format values such as dates and currency according to this portal's settings. Pass false for raw strings.

Get the property definition for a given object type and property name.

Supported object types are HubSpot standard objects (e.g., contacts), portal specific objects, and integrator objects.

ParameterTypeDescription
object_typeStringThe object type name. Object type names are case sensitive. The supported object types. To find the names of the account specific and integrator object types available in your account use the CRM Objects Schema API to get the type definitions and look for the name property. It contains the internal object type name that should be used in the functionFor integrator and account specific object types with the same name as the built-in objects use the objects fully qualified name (FQN).
property_nameStringThe case-insensitive property name to retrieve the definition for.

Get the property definitions for a given object type and set of property names.

Supported object types are HubSpot standard objects (e.g. contacts), portal specific objects, and integrator objects.

ParameterTypeDescription
object_typeStringThe object type name. Object type names are case sensitive. The supported object types. To find the names of the account specific and integrator object types available in your account use the CRM Objects Schema API to get the type definitions and look for the name property. It contains the internal object type name that should be used in the functionFor integrator and account specific object types with the same name as the built-in objects use the objects fully qualified name (FQN).
property_nameStringOptional. The case-insensitive property names comma separated, to retrieve the definition for. If empty, the definitions for all the properties will be retrieved.

Because CTA modules have so many parameters that contain variations of their code, you can use the CTA function to easily generate a particular CTA in a template, page, or email. This function is what the rich text editor uses when you add a CTA via the editor.

ParameterTypeDescription
guidStringThe ID of the CTA to render. Can be found in the URL of the details screen of the CTA.
align_optEnumerationAdjusts alignment of CTA. Values include justifyleft, justifycenter, justifyright, justifyfull.

Extend a list by appending all items from an iterable. In other words, insert all list items from one list into another list.

This function returns the metadata of a file by ID. It accepts a single parameter, the numeric ID of the file to look up. To retrieve multiple files at once, use the files_by_ids function instead.

ParameterTypeDescription
file_idNumberThe ID of the file to look up.

Returns the metadata of multiple files by ID. It accepts an array of file IDs.

ParameterTypeDescription
file_idNumberThe IDs of the files to look up, separated by commas (up to 100).

For example, you can use this function, to loop through a contact's uploaded files. To loop through results, you'll need to use the split HubL filter, as the CRM property will be returned as a semicolon-separated string.

When a blog post is configured for self-registration access, visitors will need to register or log in to view the full post content. HubSpot's default blog listing assets automatically include this functionality, and will also include a lock icon indicator for posts that require self-registration to access. Learn more about building custom solutions using this function and its corresponding API.

This function checks whether a blog post can be accessed by the current visitor. When called, the function is replaced with the following attribute:

hs-member-content-access=<true/false>

A value of true indicates that the blog post requires the visitor to log in to view the full content.

ParameterTypeDescription
IDIDThe ID of the content that will be checked against the current logged in viewer.

Formats an address based on the context's locale.

ParameterTypeDescription
localeRequiredStringThe locale to format the address in.
addressRequiredStringThe street address.
address2OptionalStringThe second line of the address, such as floor or apartment number.
cityRequiredStringThe city of the address.
stateRequiredStringThe state of the address.
countryRequiredStringThe country of the address.
zipRequiredStringThe zip code of the address.

Formats a company's name by adding Japanese honorifics where appropriate.

ParameterTypeDescription
companyNameRequiredStringThe name of the company.
useHonorificIfApplicableRequiredBooleanWhen set to true and the context's language is Japanese, a Japanese company honorific will be added where appropriate.

Formats a person's name by putting the surname before the first name and adds Japanese honorifics where appropriate

ParameterTypeDescriptionDefault
firstNameRequiredStringThe person's first name.
surnameRequiredStringThe person's surname or last name.False
useHonorificIfApplicableRequiredBooleanWhen set to true and the context's language is Japanese, a Japanese honorific will be added where appropriate.

Formats both the date and time components of a date object, similar to the format_datetime HubL filter. This function replaces the deprecated datetimeformat function.

ParameterTypeDescription
formatRequiredStringThe format to use. Can be one of:
timeZoneOptionalStringThe time zone of the output date in IANA TZDB format.
localeOptionalStringThe locale to use for locale-aware formats.

This function contains 4 parameters and calculates the ellipsoidal 2D distance between two points on Earth. Use this function as a filter query for getting HubDB data.

ParameterTypeDescription
point1Locationlocation from a HubDB column.
point2_latLatitudeLatitude of point2.
point2_longLongitudeLongitude of point2.
unitsStringUnits for the return value. Options are FT for feet, MI for miles, M for meters or KM for kilometers.

This function returns the public URL of a specified template or code file. The parameter of this function is the asset's path in the design manager. Coded file URLs update each time you publish them; therefore, by using this function your ensure you are always using the latest version of the file.

You can automatically generate this function in the app, by either right-clicking a file and selecting Copy public URL, or by clicking Actions, then selecting Copy public URL.

The example below gets the URL of a Javascript file authored in Design Manager that can be included as the src of a <script> tag.

copy-public-url

ParameterTypeDescription
pathStringThe design manager file path to the template or file.

This function works just like get_public_template_url, returning public URL of a specified template or code file. The only difference is the parameter of this function is the template ID (available in the URL of the template or coded file), instead of the design manager path.

ParameterTypeDescription
template_idIDThe ID number of the template of file.

HubDB is a feature available in Content Hub Professional and Enterprise.

The hubdb_table function can be used to get information on a table including its name, columns, last updated, etc.

The following pieces of information can be pulled by calling the appropriate attributes:

  • ID: the ID of the table.
  • name: the name of the table.
  • columns: a list of column information.
  • created_at: the timestamp of when this table was first created.
  • published_at: the timestamp of when this table was published.
  • updated_at: timestamp of when this table was last updated.
  • row_count: the number of rows in the table.
ParameterTypeDescription
table_idStringID or name of the table.

HubDB is a feature available in Content Hub Professional and Enterprise.

The hubdb_table_column function can be used to get information on a column in table such as its label, type and options. This function accepts two parameters.

These pieces of information about the column can be pulled by calling the appropriate attributes:

  • ID: the ID of the column.
  • name: the name of the column.
  • label: the label to be used for the column.
  • type: the type of the column.
  • options: for columns of type select, a map of optionId to option information.
  • foreignIds: for columns of type "foreignId", a list of foreignIds (with id and name properties).

In addition to the above attributes, there is also a method which can be called: getOptionByName("&lt;option name&gt;") whereby for columns of type "select", this will get option information by the option's name.

ParameterTypeDescription
table_idStringID or name of the table.
columnStringID or name of the column.

HubDB is a feature available in Content Hub Professional and Enterprise.

The hubdb_table_row function can be used to pull a single row from a HubDB table. From this row, you can pull information from each table cell by calling on the corresponding attribute:

  • hs_id: the globally unique id for this row.
  • hs_created_at: a timestamp representing when this row was created.
  • hs_path: when used with dynamic pages, this string is the last segment of the url's path for the page.
  • hs_name: when used with dynamic pages, this is the title of the page.
  • <column name> or ["<column name>"]: get the value of the column for this row by the name of the column.
ParameterTypeDescription
table_idStringID or name of the table.
row_idIntegerID of the row of the table.

HubDB is a feature available in Content Hub Professional and Enterprise.

The hubdb_table_rows function can be used to list rows of a HubDB table, to be iterated through. A single call of hubdb_table_rows() is limited to 10 table scans per page and per email.

By default, this function will return a maximum of 1,000 rows. To retrieve more rows, specify a limit in the query, as shown in the code below.

ParameterTypeDescription
table_idStringID or name of the table to query.
queryStringA query in the same format as a URL query string. If not passed, returns all rows. Learn more about the available filters for querying HubDB table rows.You can reverse the sort by adding a - to the column name: orderBy=-bar. You can include this parameter multiple times to sort by multiple columns.In addition to ordering by a column, you can also include the following functions:
  • geo_distance(location_column_name, latitude, longitude):takes the name of a location column and coordinates, returns the rows ordered by how far away the value of the specified location column are from the provided coordinates.
  • length(column_name):takes the name of a column, returns the rows ordered by the length of the column value (calculated as a string)
  • random():returns the rows in random order.
These functions also support reverse ordering. For example, orderBy=-geo_distance(location_column,42.37,-71.07)returns the items that are the farthest away first.

This function generates a link tag that references the Primary CSS file (default_custom_style.min.css). This file is designed to be a global CSS file that can be added to all templates. To render, the function requires a boolean parameter value of True.

Returns the location of the first matching item in a 0-based array.

This function accepts 3 parameters, The first parameter is required. The first parameter is the item you are trying to find in the array. The second (start) and third (end) enable you to find that item in a slice of the array.

Places an element into a list at the specific index provided.

This function accepts two parameters:

  • Index: the position where an element is to be inserted.
  • Element: the item to be inserted.

Returns a human-readable string representation of a language code, optionally translated to a target language.

ParameterTypeDescription
language_codeStringThe language code.
target_language_codeStringThe language that the output will be translated to.

Loads translations from a given _locales folder path and returns a map of the values.

ParameterTypeDescription
pathStringThe file path to the _locales directory of the translations.
language_codeStringThe language code.
language_code_fallbackStringThe language code fallback if the specified language_code isn't present.

Returns the nested link structure of an advanced menu. Menu nodes have a variety of properties that can be used on objects that are returned. If you pass null to the menu function it will return an empty pylist. You can also specify a menu by name. In most cases it's safer to use the menu id, as a menu being renamed won't affect the id. If building for the marketplace it makes sense to default to "default" if menu is null.

ParameterTypeDescription
menu_idIdRequired. The id of the menu passed as a number.
root_typeEnumerationRoot type of the menu ("site_root", "top_parent", "parent", "page_name", "page_id", "breadcrumb").
  • "site_root" denotes static - Always show top-level pages in menu.
  • "top_parent" denotes dynamic by section - Show pages in menu that are related to section being viewed.
  • "parent" denotes dynamic by page - Show pages in menu that are related to page being viewed.
  • "breadcrumb" denotes breadcrumb style path menu (uses horizontal flow).
root_keyStringRoot key (id or name) when using "page_name" or "page_id".

Gets the URL for an asset attached to a custom module via Linked Files > Other Files.

ParameterTypeDescription
nameStringThe name of the asset.

Creates a namespace object that can hold arbitrary attributes. It can be initialized from a dictionary or with keyword arguments.

ParameterTypeDescription
dictionaryMapThe dictionary to initialize with.
kwargsStringKeyword arguments to put into the namespace dictionary.

Returns OEmbed data dictionary for given request. Only works in emails.

ParameterTypeDescription
requestStringRequest object, {url: string, max_width: long, max_height: long}.

Returns the value of a contact or contact related property, or a default.

ParameterTypeDescription
expressionStringAn expression for the object and property to render.
defaultStringOptional. A default value to use if the expression has no value.

Removes the item at the index from the list. Also returns the removed item if printed.

The postal_location function returns the latitude/longitude location pair for a given postal code and country code (limited to US, CA, and GB).

ParameterTypeDescription
postal_codeStringPostal code of the location.
country_codeStringCountry code for the postal code. If not provided, the country will try to be inferred from the postal code.

Similar to the update function, which updates a dict with the elements from another dict object or from an iterable of key-value pairs, except that put supports variable names in dicts.

Returns a list containing an arithmetic progression of integers. With one parameter, range will return a list from 0 up to (but not including) the value. With two parameters, the range will start at the first value and increment by 1 up to (but not including) the second value. The third parameter specifies the step increment. All values can be negative. Impossible ranges will return an empty list. Ranges can generate a maximum of 1000 values.

Range can be used within a for loop to specify the number of iterations that should run.

This function enqueues a CSS file to be rendered in the head element. All CSS link tags are grouped together and render before any JavaScript tags. The HubL is replaced with an empty line and then a link tag is added to {{ standard_header_includes }}. This method requires an absolute URL; CMS content with a known relative URL can be required by using the get_asset_url() function.

To enqueue an inline style to be rendered in the head via a style tag element, use the {% require_css %} and {% end_require_css %} tag instead with your style tags and CSS inside of that.

The second parameter is a dictionary of options to modify generated tag. Supports async (true/false) a technique described on web.dev and any other key-value pair will be added as HTML attributes to the style tag.

Specifies whether a script should be enqueued to render in the head or footer (default). Specify the render location by including the head or footer parameter. The HubL will be replaced by an empty line, and included in either the header or footer includes.

To enqueue an inline script to be rendered in the footer via a script element, wrap your <script> tags with {% require_js %} and {% end_require_js %}.

You can also include additional render options in this function. These will be added as HTML attributes in the script tag. Render options include:

  • position: head/footer
  • defer: true/false
  • async: true/false
  • type: string

Rewrites the URL of image stored in File Manager to a URL that will resize the image on request. The function accepts one required parameter, and five optional parameters. At least one optional parameter must be passed.

Required

  • URL: string, URL of a HubSpot-hosted image.

Optional

  • width: number, the new image width in pixels.
  • height: number, the new image height in pixels.
  • length: number, the new length of the largest side, in pixels.
  • upscale: boolean, use the resized image dimensions even if they would scale up the original image (images may appear blurry).
  • upsize: boolean, return the resized image even if it is larger than the original in bytes.
ParameterTypeDescription
urlStringURL of a HubSpot-hosted image.
widthInteger (px)The new image width, in pixels.
heightInteger (px)The new image height, in pixels.
lengthInteger (px)The new length of the largest side, in pixels.
upscaleBooleanUse the resized image dimensions even if they would scale up the original image (images may appear blurry).Default value is false.
upsizeBooleanReturn the resized image even if it is larger than the original in bytes.Default value is false.

Reverses the order of items in a list. Doesn't take any parameters. To reverse an object or return an iterator to iterate over the list in reverse, use |reverse

Set the response code as the specified code. 404 is the only supported code for now. When using this, your page will return a 404 error.

ParameterTypeDescription
codeIntegerThe HTTP response code. Currently, 404 is the only supported code.

This function prints content from the parent template into a child template using the extends tag.

For example, in the code below, a basic HTML template has been created with a HubL block named sidebar and saved as parent.html. A second template file is created that will extend that parent file. Normally, the <h3> would be printed in the parent HTML's sidebar block. But by using super, content from the parent template sidebar block is combined with the content from the child template.

Returns the start of today (12:00am). Optionally you can add a parameter to change the timezone from the default UTC.

Converts a UNIX timestamp to the local time, based on your HubSpot Report Settings. You can then apply a datetimeformat filter to format the date.

ParameterTypeDescription
dateDatetimeUNIX timestamp to convert to local time.

Returns a HubL dict representing the topic cluster associated with a piece of content (determined by the passed content id), including metadata about the associated pillar page, core topic, and subtopics. Can be used to "auto-link" a piece of content with its associated pillar page [if it exists].

Available metadata can be found in: attachableContent (the current content's metadata), topic (the current content's associated topic metadata), coreTopic (the associated cluster's core topic metadata), and pillarPage (the associated pillar page's metadata).

Use {{ topicCluster|pprint }} to see a full a display of available properties/attributes.

ParameterTypeDescription
content_idIdThe id of the page to look up.

The truncate function works just like the truncate filter, but uses function syntax instead of filter syntax. The first parameter specifies the string. The second parameter specifies the length at which to truncate. The final parameter specifies the characters to add when the truncation occurs.

ParameterTypeDescription
string_to_truncateStringString that will be truncated.
lengthintegerSpecifies the length at which to truncate the text (includes HTML characters).
killwordsbooleanIf true, the string will cut text at length, regardless of if it's in the middle of a word.
endStringThe characters that will be added to indicate where the text was truncated.

This function accepts one argument and returns the type of an object. The return value is one of: "bool", "datetime", "dict", "float", "int", "list", "long", "null", "str" or "tuple".

This function returns a unix timestamp when you supply a datetime object.

Updates the dict with the elements from another dict object or from an iterable of key-value pairs. Use this function to combine or merge objects.