HubL Reference

Table of contents
Close

HubL supported functions

Functions 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. Instead they interact with other areas of your HubSpot environment.

append

Adds a single item to the end of a list.


{% set numbers_under_5 = [1,2,3] %}
{% do numbers_under_5.append(4) %}
{{numbers_under_5}}


[1, 2, 3, 4]

blog_all_posts_url

The blog_all_posts_url function returns a full URL to the listing page for all blog posts for the specified blog. This function accepts one parameter, a blog id or simply the keyword "default".

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


<a href="{{ blog_all_posts_url('default') }}">All Marketing blog posts</a>


<a href="http://www.hubspot.com/marketing/all">All Marketing blog posts</a>

blog_author_url

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

This function accepts two parameters. The first parameter specifies which blog the author's listing page exists in. The second parameter specifies which author to link to. 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 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.


<a href="{{ blog_author_url('default', 'brian-halligan') }}">Brian Halligan</a>


<a href="http://blog.hubspot.com/marketing/author/brian-halligan">Brian Halligan</a>

blog_authors

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. 

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

The first line of the example below demonstrates how the function returns a sequence of author objects. The rest of the example demonstrates 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.

This function has a limit of 250 authors.

{{ blog_authors('default', 250) }}

{% set my_authors = blog_authors('default', 250) %}
<ul>
{% for author in my_authors %}
<li><a href="{{ blog_author_url(group.id, author.slug) }}">{{ author }}</a></li>
{% endfor %}
</ul>

[ Brian Halligan, Dharmesh Shah, Katie Burke, Kipp Bodnar]

<ul>
    <li><a href="http://blog.hubspot.com/marketing/author/brian-halligan">Brian Halligan</a></li></li>
    <li><a href="http://blog.hubspot.com/marketing/author/dharmesh-shah">Dharmesh Shah</a></li></li>
    <li><a href="http://blog.hubspot.com/marketing/author/katie-burke">Katie Burke</a></li></li>
    <li><a href="http://blog.hubspot.com/marketing/author/kipp-bodnar">Kipp Bodnar</a></li></li>
</ul>

blog_page_link

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.

 


<a href="{{ blog_page_link(current_page_num) }}">Current page</a>
<a href="{{ blog_page_link(7) }}">Page 7</a>
<a href="{{ blog_page_link(next_page_num) }}">Next</a>
<a href="{{ blog_page_link(current_page_num + 4) }}">Page Plus 4</a>


<a href="http://designers.hubspot.com/blog/page/1">Page 1</a>
<a href="http://designers.hubspot.com/blog/page/7">Page 7</a>
<a href="http://designers.hubspot.com/blog/page/2">Next</a>
<a href="http://designers.hubspot.com/blog/page/5">Page Plus 4</a>

blog_popular_posts

The blog_popular_posts function renders a set number of popular posts into a sequence. 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 up to 3 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 (optional) parameter specifies how many posts to retrieve - if not specified, defaults to 10.  The third (optional) parameter specifies a topic by which to filter the results - if specified, only popular posts associated with this topic will be returned.

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,  "pop_post.name" is used. This technique can be used, not only on blog templates, but also regular pages.

This function has a limit of 200 posts.


{% set pop_posts = blog_popular_posts('default', 5, 'marketing-tips') %}
{% for pop_post in pop_posts %}
    <div class="post-title">{{ pop_post.name }}</div>
{% endfor %}


[Popular post title 1, Popular post title 2, Popular post title 3, Popular post title 4, Popular post title 5]

<div class="post-title">Popular post title 1</div>
<div class="post-title">Popular post title 2</div>
<div class="post-title">Popular post title 3</div>
<div class="post-title">Popular post title 4</div>
<div class="post-title">Popular post title 5</div>

blog_post_archive_url

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, respectivelty.

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


<a href="{{ blog_post_archive_url('default', 2017, 7, 5) }}">Posts from July 5th, 2017</a>


<a href="http://blog.hubspot.com/marketing/archive/2017/07/05">Posts from July 5th, 2017</a>

blog_post_by_id

This function is being deprecated. Please use content_by_id()

The blog_post_by_id function returns a single blog post based a blog post ID provided. The only parameter accepted by this function is a numeric blog id. 

The examples below show this function in use to generate a hyperlinked list item.


{% set my_post = blog_post_by_id(4715624297) %}
<ul>
    <li>
        <a href="{{ my_post.absolute_url }}">{{my_post.title}}</a>
    </li>
</ul>


<ul>
    <li>
        <a href="//www.hubspot.com/blog/articles/kcs_article/email/how-do-i-create-default-values-for-my-email-personalization-tokens">How do I create default values for my email or smart content personalization tokens?</a>
    </li>
</ul>

blog_recent_author_posts

The blog_recent_author_posts function returns a sequence of blog post objects for the specified author, 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 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 to retrieve. 

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, not only on blog templates, but also regular pages. 

This function has a limit of 200 posts.


{{ blog_recent_author_posts('default', content.blog_post_author.slug, 5 ) }}
{% set author_posts = blog_recent_author_posts('default', content.blog_post_author.slug, 5) %}
{% for author_post in author_posts %}
    <div class="post-title">{{ author_post.name }}</div>
{% endfor %}


[Post by author title 1, Post by author title 2, Post by author title 3, Post by author title 4, Post by author title 5]

<div class="post-title">Post by author title 1</div>
<div class="post-title">Post by author title 2</div>
<div class="post-title">Post by author title 3</div>
<div class="post-title">Post by author title 4</div>
<div class="post-title">Post by author title 5</div>

blog_recent_posts

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 to retrieve. 

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. 

This function has a limit of 200 posts.


{{ blog_recent_posts('default', 5) }}
{% set rec_posts = blog_recent_posts('default', 5) %}
{% for rec_post in rec_posts %}
    <div class="post-title">{{ rec_post.name }}</div>
{% endfor %}


[Recent post title 1, Recent post title 2, Recent post title 3, Recent post title 4, Recent post title 5]

<div class="post-title">Recent post title 1</div>
<div class="post-title">Recent post title 2</div>
<div class="post-title">Recent post title 3</div>
<div class="post-title">Recent post title 4</div>
<div class="post-title">Recent post title 5</div>

blog_recent_tag_posts

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.

The function takes three parameters. The first parameter specifies which blog to collect 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 which tags to use, either a single tag or an array of up to 10 tags separated by commas. This parameter can use the tag.slug for a particular tag from content.tag_list or accepts a lowercase hyphenated name such as 'marketing-tips'. 

The third parameter specifies how many posts to retrieve. 

The first line of the example below demonstrates how the function returns a sequence of posts by a tag. The second line shows the function used to save a sequence in a variable which is then looped through. Any blog post variables should use the name of the individual loop item rather than "content." In the example,  "tag_post.name" is used. This technique can be used, not only on blog templates, but also regular pages. 

You can use this function as the foundation for a related posts section of an individual blog post layout. To learn more about creating a related posts section, check out this tutorial.

There is a limit of 100 most recent posts.


{{ blog_recent_tag_posts('default', 'marketing-tips', 5 ) }}
{% set tag_posts = blog_recent_tag_posts('default', ['marketing', 'fun', 'inbound'], 3) %}
{% for tag_post in tag_posts %}
    <div class="post-title">{{ tag_post.name }}</div>
{% endfor %}


[Post about Marketing 1, Post about Marketing 2, Post about Marketing 3, Post about Marketing 4, Post about Marketing 5]

<div class="post-title">Post about Marketing</div>
<div class="post-title">Post about Fun</div>
<div class="post-title">Post about Inbound</div>

blog_tag_url

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 to.  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 hrefThis can be combined with blog_topics as shown in that function's examples.


<a href="{{ blog_tag_url('default', 'inbound-marketing') }}">Inbound Marketing</a>


<a href="http://blog.hubspot.com/marketing/tag/inbound-marketing">Inbound Marketing</a>

blog_topics

(This function has been renamed to 'blog_tags'.)

blog_tags

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 author tag links. The example assumes that the blog has 4 tags. 

This function has a limit of 250 tags.

{{ blog_tags('default', 250) }}

{% set my_tags = blog_tags('default', 250) %}
<ul>
{% for item in my_tags %}
<li><a href="{{ blog_tag_url(group.id, item.slug) }}">{{ item }}</a></li>
{% endfor %}
</ul>

[ Blogging, Inbound Marketing, SEO, Social Media]

<ul>
    <li><a href="http://blog.hubspot.com/marketing/tag/blogging"></a></li></li>
    <li><a href="http://blog.hubspot.com/marketing/tag/inbound-marketing">Inbound Marketing</a></li></li>
    <li><a href="http://blog.hubspot.com/marketing/tag/seo">SEO</a></li>
    <li><a href="http://blog.hubspot.com/marketing/tag/social-media">Social Media</a></li></li>
</ul>

blog_total_post_count

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.

{{ blog_total_post_count }} 


{{ blog_total_post_count(359485112) }}

16

54

clear

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


{% set words = ["phone","home"] %}
{% do words.clear() %}
{{words}}


[]

color_variant

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 than modified by -80 resulting in a darker blue (#00034b).

{% set base_color ="#3A539B" %} 


{{ color_variant(base_color, -80) }}
#00034b

content_by_id

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. 

This function has a limit of 10 calls per page. 

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


{% set my_content = content_by_id(4715624297) %}
<ul>
    <li>
        <a href="{{ my_content.absolute_url }}">{{my_content.title}}</a>
    </li>
</ul>


<ul>
    <li>
        <a href="http://www.hubspot.com/blog/articles/kcs_article/email/how-do-i-create-default-values-for-my-email-personalization-tokens">How do I create default values for my email or smart content personalization tokens?</a>
    </li>
</ul>

content_by_ids

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. This function has a limit of 10 calls per page. 

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


{% set contents = content_by_ids([4715624297, 4712623297, 5215624284]) %}
<ul>
{% for content in contents %}
    <li>
        <a href="{{ content.absolute_url }}">{{content.title}}</a>
    </li>
    {% endfor %}
</ul>


<ul>
    <li>
        <a href="http://www.hubspot.com/blog/articles/kcs_article/email/how-do-i-create-default-values-for-my-email-personalization-tokens">How do I create default values for my email or smart content personalization tokens?</a>
    </li>
    <li>
        <a href="https://blog.hubspot.com/marketing/content-marketing-strategy-guide">Content Marketing Strategy: A Comprehensive Guide for Modern Marketers</a>
    </li>
</ul>

copy

Return a shallow copy of the list. Equivalent to 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.


{% set a = ["ham"] %}
{% set b = a.copy() %}
a: {{a}}

b: {{b}}

  After Append
{% do a.append("swiss") %}
a: {{a}}

b: {{b}}



a: [ham]

b: [ham]

After Append

a: [ham, swiss]
b: [ham]

count

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


{% set attendees = ["Jack","Jon","Jerry","Jessica"] %}
{% set jon_count = attendees.count("Jon") %}
There are {{jon_count}} Jon's in the list.
<p>After append:</p>
{% do attendees.append("Jon") %}
{% set jon_count_after_append = attendees.count("Jon") %}
There are now {{jon_count_after_append}} Jon's in the list.




There are 1 Jon's in the list.
<br>


There are now 2 Jon's in the list.

crm_associations

Gets a list of CRM objects associated to an object from the HubSpot CRM. This function returns an object with the following attributes: has_more, total, offset and results.

results returns an array of the specified associated objects matching the function's parameters. 
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.

For security purposes, only Product objects can be retrieved on a publicly accessible page. Any other object type must be hosted on a page which is either password protected or requires a CMS Membership login. Objects in the results array are returned as a dict of properties and values.

The first parameter (required) is the id specifying the id of object to find associations from.

The second parameter (required) is the id of the association type to use. The ID’s are defined here: https://developers.hubspot.com/docs/methods/crm-associations/crm-associations-overview

The third parameter is an optional string delimited by '&'. All expressions are ANDed together. Results can be sorted using at least one order parameter in the query (orderBy=). Supported operators are eq (default), neq, lt, lte, gt, gte, is_null and not_null.

The fourth parameter is an optional string that is a comma-separated list of properties to return. By default, a small set of common properties are returned. The id property is always returned.

The fifth parameter is an optional boolean value. Passing true will format values such as dates and currency according to this portal's settings. Omit or pass 'false' for raw strings.

NOTE: This function can be called a maximum of 10 times per page. Each crm_objects call can return at most 100 objects. The default limit is 10 objects.

{% set associated_contacts = crm_associations(847943847, 2, 'limit=3&years_at_company__gt=2&orderBy=email', 'firstname,email', false) %} 


{{ associated contacts }}

{has_more=true, offset=3, total=203, results=[{firstname=Aimee, id=905, email=abanks@company.com}, {firstname=Amy, id=1056, email=abroma@company.com}, {firstname=Abigael, id=957, email=adonahu@company.com}]}

crm_object

Gets a single object from the HubSpot CRM.

For security purposes, only Product objects can be retrieved on a publicly accessible page. Any other object type must be hosted on a page which is either password protected or requires a CMS Membership login. Objects are returned as a dict of properties and values.

The first parameter (required) is a string specifying the CRM object type to get (contact, product, company, deal, ticket or quote).

The second parameter (required) specifies which CRM object to get. This parameter can either be a number, or a string. If you wish to get a specific crm object by id, pass a number of the id of the object. If you wish to get a crm object by querying crm objects, pass a query string, delimited by &. All expressions are ANDed together. Supported operators are eq (default), neq, lt, lte, gt, gte, is_null and not_null

The third parameter is a comma-separated list of properties to return. By default, a small set of common properties are returned. 

The final parameter specifies if values such as dates and currency should be formatted according to the portal's settings. Pass 'false' for raw values. 

NOTE: This function can only be called a maximum of 10 times on a single page. 

      

<!-- by query -->
{% set contact = crm_object("contact", "email=contact@company.com", "firstname,lastname", false) %}
<!-- by id -->
{% set contact = crm_object("contact", 123) %}
{{ contact.firstname }}
{{ contact.lastname }}
      
    
      


Brian
Halligan




      
    

crm_objects

Gets a list of objects from the HubSpot CRM.

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

results returns an array of the specified objects matching the function's parameters. 
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 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.

For security purposes, only Product objects can be retrieved on a publicly accessible page. Any other object type must be hosted on a page which is either password protected or requires a CMS Membership login. Objects in the results array are returned as a dict of properties and values.

The first parameter (required) is a string specifying the CRM object type to get (contact, product, company, deal, ticket or quote).

The second parameter (required) specifies which CRM objects to get: pass a query string, delimited by &.  All expressions are ANDed together. Supported operators are eq (default), neq, lt, lte, gt, gte, is_null and not_null

The third parameter is a comma-separated list of properties to return for each object in the results attribute value. By default, a small set of common properties are returned. 

The final parameter specifies if values, returned for each object in the results attribute value, such as dates and currency should be formatted according to the portal's settings. Pass false for raw values. 

NOTE: This function can be called a maximum of 10 times per page. Each crm_objects call can return at most 100 objects. The default limit is 10 objects.

{% set objects = crm_objects("contact", "firstname__not_null=&limit=3", "firstname,lastname") %} 


{{ objects }}
{has_more=true, offset=3, total=331, results=[{firstname=Brian, id=44151, lastname=Halligan}, {firstname=Dharmesh, id=44051, lastname=Shah}, {firstname=George, id=88551, lastname=Washington}]}

cta

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.

The function accepts two parameters. The first parameter is the GUID of the CTA. This unique ID can be found in the URL of the Details screen of a particular CTA. The second parameter accept the following enumeration values:

  • justifyleft - adds text-align: left to the CTA wrapper.
  • justifycenter- adds text-align: center to the CTA wrapper.
  • justifyright - adds text-align: right to the CTA wrapper.
  • justifyfull - adds no justification to the CTA wrapper.
{{ cta('ccd39b7c-ae18-4c4e-98ee-547069bfbc5b')  }} 


{{ cta('ccd39b7c-ae18-4c4e-98ee-547069bfbc5b', 'justifycenter') }}

<span class="hs-cta-wrapper" id="hs-cta-wrapper-ccd39b7c-ae18-4c4e-98ee-547069bfbc5b"> <span class="hs-cta-node hs-cta-ccd39b7c-ae18-4c4e-98ee-547069bfbc5b" id="hs-cta-ccd39b7c-ae18-4c4e-98ee-547069bfbc5b" style="visibility: visible;"><a id="cta_button_158015_19a9097a-8dff-4181-b8f7-955a47f29826" class="cta_button " href="//cta-service-cms2.hubspot.com/ctas/v2/public/cs/c/?cta_guid=19a9097a-8dff-4181-b8f7-955a47f29826&placement_guid=ccd39b7c-ae18-4c4e-98ee-547069bfbc5b&portal_id=158015&redirect_url=APefjpH34lXcq1H4FhyHhE3DNeHPNigbBluiv6t07-N80GLkyj2Dn9PizhW8bo4ecrS47RmyslLg7QQKWLG7n2oNkvrumL9dWUjMMEjVYvStZ-IMyulMBvdU8AddI6nFXL0G_VPP_VXmnFi66RKPPjPvx6kbyPO6k566noP4CTZMyADHkGsGBf4S95YdTNtTTFabShT62cVAiV_oWlXbpfPWQc4G3IvkoDoAhmpQVW-ggUcKa4Ft_5A&hsutk=683eeb5b499fdfdf469646f0014603b4&utm_referrer=http%3A%2F%2Fwww.davidjosephhunt.com%2F%3Fhs_preview%3DNVkCLfFf-2857453560&canon=http%3A%2F%2Fwww.davidjosephhunt.com%2F-temporary-slug-63bb220d-eda6-44d0-9738-af928e787237" style="" cta_dest_link="http://www.hubspot.com/free-trial" title="Start a HubSpot trial"> Start a HubSpot trial </a> </span> <script charset="utf-8" src="//js.hscta.net/cta/current.js"></script> <script type="text/javascript">         hbspt.cta.load(158015, 'ccd39b7c-ae18-4c4e-98ee-547069bfbc5b');     </script> </span>

<span class="hs-cta-wrapper" id="hs-cta-wrapper-ccd39b7c-ae18-4c4e-98ee-547069bfbc5b"> <span class="hs-cta-node hs-cta-ccd39b7c-ae18-4c4e-98ee-547069bfbc5b" id="hs-cta-ccd39b7c-ae18-4c4e-98ee-547069bfbc5b" style="display: block; text-align: center; visibility: visible;"><a id="cta_button_158015_19a9097a-8dff-4181-b8f7-955a47f29826" class="cta_button " href="//cta-service-cms2.hubspot.com/ctas/v2/public/cs/c/?cta_guid=19a9097a-8dff-4181-b8f7-955a47f29826&placement_guid=ccd39b7c-ae18-4c4e-98ee-547069bfbc5b&portal_id=158015&redirect_url=APefjpH34lXcq1H4FhyHhE3DNeHPNigbBluiv6t07-N80GLkyj2Dn9PizhW8bo4ecrS47RmyslLg7QQKWLG7n2oNkvrumL9dWUjMMEjVYvStZ-IMyulMBvdU8AddI6nFXL0G_VPP_VXmnFi66RKPPjPvx6kbyPO6k566noP4CTZMyADHkGsGBf4S95YdTNtTTFabShT62cVAiV_oWlXbpfPWQc4G3IvkoDoAhmpQVW-ggUcKa4Ft_5A&hsutk=683eeb5b499fdfdf469646f0014603b4&utm_referrer=http%3A%2F%2Fwww.davidjosephhunt.com%2F%3Fhs_preview%3DNVkCLfFf-2857453560&canon=http%3A%2F%2Fwww.davidjosephhunt.com%2F-temporary-slug-63bb220d-eda6-44d0-9738-af928e787237" style="" cta_dest_link="http://www.hubspot.com/free-trial" title="Start a HubSpot trial"> Start a HubSpot trial </a> </span> <script charset="utf-8" src="//js.hscta.net/cta/current.js"></script> <script type="text/javascript">         hbspt.cta.load(158015, 'ccd39b7c-ae18-4c4e-98ee-547069bfbc5b');     </script> </span>

datetimeformat

The datetimeformat function works just like the datetimeformat filter, but uses function syntax instead of filter syntax. It uses the same parameters to format the date. You can see a complete list of formatting parameters, here

{{ datetimeformat(content.publish_date_local_time, '%B %e, %Y') }} 

May 13, 2015

extend

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


{% set vehicles = ["boat","car","bicycle"] %}
{% set more_vehicles = ["airplane","motorcycle"] %}
{% do vehicles.extend(more_vehicles) %}
{{vehicles}}


[boat, car, bicycle, airplane, motorcycle]

file_by_id

This functions returns the metadata of a file by ID. It accepts a single parameter, the numeric ID of the file to look up.

This function is limited to 10 calls per page. 
{% set file = file_by_id(123) %} 


{{ file.friendlyUrl }}
https://www.hubspot.com/hubfs/HubSpot_Logos/HSLogo_color.svg

geo_distance

Note: This function is for use with HubDB as a filter query. 

This function contains 4 parameters and calculates the ellipsoidal 2D distance between two points on Earth.

The first parameter is the location column for point 1 from your HubDB table (ex: row.location).
The second parameter is the latitude number of point 2.
The third parameter is the longitude number of point 2.
The fourth parameter is a string value for unit of the returned value. Options include FT for feet, MI for miles, M for meters,  or KM for kilometers.

      

{% for row in hubdb_table_rows(1234567, "geo_distance(loc,1.233,-5.678,mi)__gt=500") %}
    <!-- Values matching your filter query will be displayed here -->
    {{row.name}} <br/> 
{% endfor %}
      
    
      



Cambridge, MA
Salem, MA
San Diego, CA
Chicago, IL

      
    

get_asset_url

This function returns the public URL of a specified template or code file. The parameter of this function is the path in 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 on a file name and choosing Copy Public Url or by choosing Actions > 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>.

 

copy-public-url
{{ get_asset_url("/custom/styles/style.css") }} 

//cdn2.hubspot.net/hub/1234567/hub_generated/template_assets/1565970767575/custom/styles/style.min.css

get_public_template_url

This function is being deprecated. Please use get_asset_url()

 

{{ get_public_template_url("custom/page/Designers_2015/designer-doc-2105.js") }} 

//cdn2.hubspot.net/hub/327485/hub_generated/style_manager/1431479563436/custom/page/Designers_2015/designer-doc-2105.min.html

get_public_template_url_by_id

This function works just like get_public_template_url,  returning public URL of a specified template or code file. The only different 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. 

{{ get_public_template_url_by_id('2778457004')  }} 

//cdn2.hubspot.net/hub/327485/hub_generated/style_manager/1431479563436/custom/page/Designers_2015/designer-doc-2105.min.js

hubdb_table

For a comprehensive overview of HubDB, read our HubDB page in the CMS Developer tools section. 

The hubdb_table function can be used to get information on a table including its name, columns, last updated, etc. This function accepts one parameter, the id of the HubDB table to pull from.

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 timestamp of when this table was first created
  • published_at 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

 

{% set table_info = hubdb_table(1548215) %} 


{{ table_info.row_count }}
25

hubdb_table_column

For a comprehensive overview of HubDB, read our HubDB page in the CMS Developer tools section.

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. 

The first parameter is the id of the HubDB table to pull from. The second parameter is either the id of the column, or the name of the column as a string. 

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 colum
  • 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("<option name>") whereby for columns of type 'select', this will get option info by the option's name.

{% set column_info = hubdb_table_column(123456, 6)  %} 


{{ column_info.label }}
role

hubdb_table_row

For a comprehensive overview of HubDB, read our HubDB page in the CMS Developer tools section. 

The hubdb_table_row function can be used to pull a single row from a HubDB table; this function accepts two parameters.

The first parameter is the ID of the table to pull from. The second parameter is the ID of the row to pull. From this row, you can pull information from each table cell by calling on the corresponding attribute: 

(Built-in and custom column names are case insensitive. HS_ID will work the same as hs_id)

  • 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

 

{% set row = hubdb_table_row(1548264, 6726439331)  %} 


{{ row.role }}
CTO

hubdb_table_rows

For a comprehensive overview of HubDB, read our HubDB page in the CMS Developer tools section. 

The hubdb_table_rows function can be used to list rows of a HubDB table, to be iterated through;  this function accepts two parameters.

The first parameter specifies the ID of the HubDB table to pull rows from. The second parameter accepts a string of filters ANDed together used to filter which rows are pulled. A complete list of optional filters as well as syntax for using these filters can be found here.

There is a limit of 10 table scans per CMS page defined as a single call to hubdb_table_rows().

{% for row in hubdb_table_rows(1546258, "years_at_company__gt=3&orderBy=count") %}
  the value for row {{ row.hs_id }} is {{ row.name }}
{% endfor %}

the value for row 6726439331 is Brian Halligan

the value for row 8438997836 is Dharmesh Shah

include_css

This function is being deprecated. Please use require_css()

This function uses the Design Manager path of a CSS file to generate a link tag that references that file. The parameter is the path to the stylesheet.
{{ include_css('custom/page/Designers_2015/designers-doc-2015.css')  }} 

<link rel="stylesheet" href="//cdn2.hubspot.net/hub/327485/hub_generated/style_manager/1431477077901/custom/page/Designers_2015/designers-doc-2015.min.css">

include_default_custom_css

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 your templates. In order to render, the function requires a boolean parameter value of True.

include_javascript

This function is being deprecated. Please use require_js()

This function uses the Design Manager path of a Javacript file to generate a script tag that references that file. The parameter is the path to the Javascript file.

{{ include_javascript('custom/page/Designers_2015/designer-doc-2105.js') }} 

<script type="text/javascript" src="//cdn2.hubspot.net/hub/327485/hub_generated/style_manager/1431479563436/custom/page/Designers_2015/designer-doc-2105.min.js"></script>

index

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. 

{% set shapes = ["triangle","square","trapezoid","triangle"] %}
triangle index: {{shapes.index("triangle")}} <br>
trapezoid index: {{shapes.index("trapezoid")}}
<hr/>
adjusted start and end <br>
triangle index: {{shapes.index("triangle",1,5)}}

triangle index: 0<br>
trapezoid index: 2
<hr>
adjusted start and end<br>
triangle index: 3

insert

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

This function accepts 2 parameters:

  • Index: the position where an element is to be inserted
  • Element: the item to be inserted
{% set even_numbers = [2,4,8,10]  %}
{% do even_numbers.insert(2,6) %}
{{even_numbers}}


[2, 4, 6, 8, 10]

locale_name

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

{{ locale_name('es') }}
{{ locale_name('es', 'en') }}


Español
Spanish

menu

Returns the nested link structure of an advanced menu. The properties for the menu nodes can be found here. The 2nd argument (root_type) determines which type of menu will be returned:

  • site_root returns a node whose children are the top-level menu nodes
  • top_parent returns the top-level menu node that the page is in
  • parent returns the menu node that contains the page in its children
  • page_id returns the page node using the page ID
  • page_name returns the page node using the page name
  • breadcrumb returns the page node of the current page

Required Parameter:

menu_id: the ID of the advanced menu

Optional Parameters:

root_type: can be one of (site_root, top_parent, parent, page_id, page_name, breadcrumb)

root_key: ID/string key used to locate menu node when using page_id or page_name

menu(menu_id, root_type=site_root, root_key)


{% set node = menu(987) %}
{% for child in node.children %}
	{{ child.label }}
{% endfor %}


page1
page2
page3

module_asset_url

Gets the URL for an asset attached to a custom module via Linked Files > Other Files.
{{ module_asset_url("smile.jpg") }} 

https://cdn2.hubspot.net/hubfs/6178146/logo-black-color.png

oembed

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

{{ oembed({ url: "https://www.youtube.com/watch?v=KqpFNtbEOh8"}) }}
      
    
      

OEmbedResponse{type=video, version=1.0, html=<iframe width="480" height="270" src="https://www.youtube.com/embed/KqpFNtbEOh8?feature=oembed" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>, title=Marketing Is a Marathon — Build a Complete Customer Experience, authorName=HubSpot, authorUrl=https://www.youtube.com/user/HubSpot, providerName=YouTube, providerUrl=https://www.youtube.com/, thumbnailUrl=https://i.ytimg.com/vi/KqpFNtbEOh8/hqdefault.jpg, thumbnailWidth=480, thumbnailHeight=360}
      
    

page_by_id

This function is being deprecated. Please use content_by_id()

The page_by_id function returns a single page based the page ID provided. The only parameter accepted by this function is a numeric page id.

The examples below show this function in use to generate a hyperlinked list item.


{% set my_page = page_by_id(4715624297) %}
<ul>
    <li>
        <a href="{{ my_page.absolute_url }}">{{ my_page.title }}</a>
    </li>
</ul>


<ul>
    <li>
        <a href="//www.hubspot.com/email/how-do-i-create-default-values-for-my-email-personalization-tokens">How do I create default values for my email or smart content personalization tokens?</a>
    </li>
</ul>

personalization_token

This function takes two parameters with the first parameter being the contact or contact related property value to return and the second optional parameter of a default value to use if the expression has no value to return.
      

Hi {{ personalization_token("contact.firstname", "there") }}!
      
    
      

<!-- If the contact is known -->
Hi Dharmesh!

<!-- If the contact is unknown -->
Hi there!
      
    

pop

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

{% set even_numbers = [2,3,4,6,8,9,10]  %}
{% do even_numbers.pop(1) %}
{{even_numbers.pop(4)}}
{{even_numbers}}
9
[2, 4, 6, 8, 10]

postal_location

The postal_location function returns the latitude/longitude location pair for a given postal code and country code (limited to US, CA, and GB). The first required parameter is the postal code as a string. The optional second parameter is the country code for the postal code. If not provided, the country will try to be inferred from the postal code.

{{ postal_location("02139") }}
{% set location = postal_location("02139", "US") %}
{{ location.latitude }}
{{ location.longitude }}

LatLon{latitude=42.3647, longitude=-71.1042}
42.3647
-71.1042

range

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


{{ range(11) }}
{{ range(5, 11) }}
{{ range(0, 11, 2) }}
       
       
{% for number in range(11) %}
{{ number }}
{% endfor %}


[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
[5, 6, 7, 8, 9, 10]
[2, 4, 6, 8, 10]

012345678910

require_css

This function enqueues a css file to be rendered in the <head />. 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 /> is added to {{ standard_header_includes }}. This method requires an absolute URL; COS content with a known relative URL can be required by using the get_public_template_url() function.

To enqueue an inline style to be rendered in the head via a < style /> element, use the {% require_css %} <style>/*...*/</style>{% end_require_css %} tag instead.


{{ standard_header_includes }}
<!-- more html -->
{{ require_css("http://example.com/path/to/file.css") }}
{{ require_css(get_public_template_url("/relative/path/to/file.css")) }}


<!-- other standard header html -->
<link type="text/css" rel="stylesheet" href="http://example.com/path/to/file.css">
<link type="text/css" rel="stylesheet" href="http://example.com/relative/path/to/file.css">
<!-- more html -->

require_js

This function enqueues a script to be rendered in either the <head/> or footer. The HubL is replaced by an empty line and included in either {{ standard_footer_includes }} (the default) or {{ standard_header_includes }} if the call contains the 'head' parameter.

To enqueue an inline script to be rendered in the <head/> via  a <script/> element, use the {% require_js %}<script> // ... </script>{% end_require_js %} tag instead.


{{ standard_header_includes }}
<!-- more html -->
{{ require_js("http://example.com/path/to/footer-file.js", "footer") }}
{{ require_js("http://example.com/path/to/head-file.js", "head") }}

{{ standard_footer_includes }}


<!-- other standard header html -->
<script src="http://example.com/path/to/head-file.js"></script>

<!-- more html -->

<script src="http://example.com/path/to/footer-file.js"></script>
<!-- other standard footer html -->

resize_image_url

Rewrites the URL of image stored in File Manager to a URL that will resize the image on request. The function accepts 1 required parameter, and 5 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

{{ resize_image_url("http://your.hubspot.site/hubfs/img.jpg", 0, 0, 300) }}


http://your.hubspot.site/hubfs/img.jpg?length=300&name=img.jpg

reverse

Reverses the order of items in a list. Does not take any parameters.


{% set numbers = [1,2,3,4] %}
{% do numbers.reverse() %}
{{numbers}}


[4, 3, 2, 1]

set_response_code

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

{{ set_response_code(404) }} 

<!-- this will cause the page to result in a 404 error -->

super

Super prints content from the parent template into a child template, when you have created parent and children templates, 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. 


{% extends "custom/page/web_page_basic/parent.html" %}

{% block sidebar %}
    <h3>Table Of Contents</h3>
    {{ super() }}
{% endblock %}


<!doctype html>
<html>
    <head>
        <meta charset="utf-8">
        <title>This is the parent template </title>
    </head>
    <body>
             <h3>Table of contents</h3>
            Sidebar content from parent.
    </body>
</html>

today

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

{{ today() }}
{{ today("America/New_York") }}
{{ unixtimestamp(today("America/New_York").plusDays(1)) }}
      
    
      

2018-10-23T00:00Z
2018-10-23T00:00-04:00[America/New_York]
1540353600000
      
    

to_local_time

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.

{{ to_local_time(eastern_dt) }} 

2015-05-13 10:37:31

 

topic_cluster_by_content_id

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.

      

{{ topic_cluster_by_content_id(content.id) }}
{%- if content.id -%}
  {%- set topicCluster = topic_cluster_by_content_id(content.id) -%}
  {%- if topicCluster.pillarPage.url.value and topicCluster.pillarPage.publishState == 'PUBLISHED' -%}
    <div>Topic: <a href="{{ topicCluster.pillarPage.url.value }}">{{ topicCluster.coreTopic.phrase }}</a></div> 
  {%- endif -%}
{%- endif -%}
      
    
      

{ attachedContent, topic, coreTopic, pillarPage }
(AttachedContentWithContext:  {attachedContent=AttachedContent{id=1234,    topicId=1234,    clusterId=1234,    portalId=0,    attachable=Attachable{contentId=124,    url=ValidatedUri{https://www.hubspot.com/},  attachableType=LANDING_PAGE,  title=title,  publishState=PUBLISHED,  deletedAt=null},  isLinkedToPillarPage=null,  isPillarPage=null,  createdAt=1547238986475,  updatedAt=1547238986475,  deletedAt=null},  coreTopic=Optional[Topic{id=1234,    portalId=0,    clusterId=1234,    phrase=TOPIC PHRASE,    attachedContent=null,    isCoreTopic=false,    createdAt=1547157062081,    updatedAt=1547232313421,    deletedAt=null}],  pillarPage=Optional[AttachedContent{id=1234,    topicId=1234,    clusterId=1234,    portalId=0,    attachable=Attachable{contentId=null,    url=ValidatedUri{https://www.hubspot.com.com/},  attachableType=EXTERNAL_URL,  title=null,  publishState=PUBLISHED,  deletedAt=null},  isLinkedToPillarPage=null,  isPillarPage=null,  createdAt=1547157062086,  updatedAt=1547157062086,  deletedAt=null}],  topic=Optional[Topic{id=1234,    portalId=0,    clusterId=8345,    phrase=topic phrase,    attachedContent=null,    isCoreTopic=false,    createdAt=1547238962703,    updatedAt=1547238962703,    deletedAt=null}]})



<div>
  Topic: <a href="#-link-to-pillar-page-url">
    core topic phrase
  </a>
</div>


      
    

truncate

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.

{{ truncate('string to truncate at a certain length', 19, end='...') }} 

string to truncate ...

type

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


{{ type("Blog") }}
{% set my_type = type("Blog") %}
<p>{{my_type}}</p>


<p>str</p>

unixtimestamp

This function returns a unix timestamp. By default it will return the timestamp of now or you can optionally supply a datetime object to be converted to a unix timestamp.


{{ unixtimestamp() }}
{{ unixtimestamp(d) }}


1571478630000
1565983117000

update

Updates the dict with the elements from another dict object or from an iterable of key/value pairs.

      

{% set dict_var = {'authorName': 'Douglas Judy', 'authorTitle': 'Mastermind' } %}
{% set test = dict_var.update({'authorFriend': 'Jake'}) %}
{% set test = dict_var.update({'authorLocation': 'unknown'}) %}
{{ dict_var }}
      
    
      




{authorName=Douglas Judy, authorTitle=Mastermind, authorFriend=Jake, authorLocation=unknown}