> ## Documentation Index
> Fetch the complete documentation index at: https://developers.hubspot.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

---
id: 4bb1ebaa-0206-43f5-acc7-0cade00df1b0
---

# HubL functions

> A reference listing of all of the available HubL functions.

export const RequiredIndicator = () => {
  return <span className="required-indicator">
      required
    </span>;
};

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](/cms/versions-deprecations/deprecated/hubl/filters-functions).

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

## append

Adds a single item to the end of a list.

<Tabs sync={false}>
  <Tab title="HubL">
    ```jinja theme={null}
    {% set numbers_under_5 = [1,2,3] %}
    {% do numbers_under_5.append(4) %}
    {{numbers_under_5}}
    ```
  </Tab>

  <Tab title="Output">
    ```
    [1, 2, 3, 4]
    ```
  </Tab>
</Tabs>

| Parameter | Type | Description                      |
| --------- | ---- | -------------------------------- |
| `item`    | Any  | Item to be appended to the list. |

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

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

<Tabs sync={false}>
  <Tab title="HubL">
    ```html theme={null}
    <a href="{{ blog_all_posts_url("default") }}">All Marketing blog posts</a>
    ```
  </Tab>

  <Tab title="Output">
    ```
    <a href="http://www.hubspot.com/marketing/all">All Marketing blog posts</a>
    ```
  </Tab>
</Tabs>

| Parameter       | Type                 | Description                                                                                                                      |
| --------------- | -------------------- | -------------------------------------------------------------------------------------------------------------------------------- |
| `selected_blog` | Blog ID or "default" | Specifies which blog to use. The blog id is returned by the [module blog field](/cms/reference/fields/module-theme-fields#blog). |

## blog\_author\_url

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.

<Tabs sync={false}>
  <Tab title="HubL">
    ```jinja theme={null}
    <a href="{{ blog_author_url("default", "brian-halligan") }}">Brian Halligan</a>
    ```
  </Tab>

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

| Parameter       | Type                 | Description                                                                                                                                                                                                                               |
| --------------- | -------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `selected_blog` | Blog 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](/cms/reference/fields/module-theme-fields#blog). |
| `author_slug`   | String or HubL Var   | Specifies which author to link to. Can use either `content.blog_post_author.slug` or a lowercase hyphenated name. Example: `"jane-doe"`.                                                                                                  |

## 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`.

<Warning>
  **Please note:**

  This function has a limit of 250 authors. This function also has a limit of 10 calls per page and per email.
</Warning>

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.

<Tabs sync={false}>
  <Tab title="HubL">
    ```html theme={null}
    {{ 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>
    ```
  </Tab>

  <Tab title="Output">
    ```
    [ Tim Cramblin, Sam Duvet, Sheila Portnadi, Rhonda Devereux]

    <ul>
      <li><a href="http://blog.hubspot.com/marketing/author/tim-cramblin">Tim Cramblin</a></li>
      <li><a href="http://blog.hubspot.com/marketing/author/sam-duvet">Sam Duvet</a></li>
      <li><a href="http://blog.hubspot.com/marketing/author/sheila-portnadi">Sheila Portnadi</a></li>
      <li><a href="http://blog.hubspot.com/marketing/author/rhonda-devereux">Rhonda Devereux</a></li>
    </ul>
    ```
  </Tab>
</Tabs>

| Parameter       | Type                 | Description                                                                                                                                                                                           |
| --------------- | -------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `selected_blog` | Blog 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](/cms/reference/fields/module-theme-fields#blog). |
| `limit`         | Integer              | Sets the limit on the number of authors fetched.                                                                                                                                                      |

## blog\_by\_id

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.

<Warning>
  **Please note:**

  This function has a limit of 10 calls per page and per email.
</Warning>

<Tabs sync={false}>
  <Tab title="HubL">
    ```jinja theme={null}
    {% set my_blog = blog_by_id(47104297) %}
    <ul>
      <li>
        <a href="{{ my_blog.absolute_url }}">{{my_blog.html_title}}</a>
      </li>
    </ul>
    ```
  </Tab>

  <Tab title="Output">
    ```
    <ul>
    <li>
    <a href="http://blog.bikinginearnest.com/outdoors"
    >Outdoor biking for the earnest</a
    >
    </li>
    </ul>
    ```
  </Tab>
</Tabs>

| Parameter       | Type                 | Description                                                                                                                                                                                           |
| --------------- | -------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `selected_blog` | Blog 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](/cms/reference/fields/module-theme-fields#blog). |

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

<Tabs sync={false}>
  <Tab title="HubL">
    ```html theme={null}
    <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>
    ```
  </Tab>

  <Tab title="Output">
    ```
    <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>
    ```
  </Tab>
</Tabs>

| Parameter | Type                    | Description                                                        |
| --------- | ----------------------- | ------------------------------------------------------------------ |
| `page`    | Number or HubL variable | Page number used to generate URL or HubL variable for page number. |

## blog\_popular\_posts

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](#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](/cms/reference/hubl/loops). [Any blog post variables](/cms/reference/hubl/variables#blog-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.

<Warning>
  **Please note:**

  This function has a limit of 200 posts. This function also has a limit of 10 calls per page and per email.
</Warning>

<Tabs sync={false}>
  <Tab title="HubL">
    ```jinja theme={null}
    {% set pop_posts = blog_popular_posts("default", 5, ["marketing-tips", "sales-tips"], "popular_past_month", "AND") %}
    {% for pop_post in pop_posts %}
    <div class="post-title">{{ pop_post.name }}</div>
    {% endfor %}
    ```
  </Tab>

  <Tab title="Output">
    ```html theme={null}
    [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>
    ```
  </Tab>
</Tabs>

| Parameter          | Type                 | Description                                                                                                                                                                                                                                                                                                               |
| ------------------ | -------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `selected_blog`    | Blog ID or "default" | Specifies which blog to use, either a specific blog by its ID or the default blog by `"default"`.                                                                                                                                                                                                                         |
| `limit`            | Integer              | Specifies the number of posts to add to the sequence up to a limit of 200. If not specified, defaults to 10.                                                                                                                                                                                                              |
| `tag_slug`         | Array                | Optional list of tags to filter posts by.                                                                                                                                                                                                                                                                                 |
| `time_frame`       | String               | Optional timeframe of analytics to filter posts by. Default is `"popular_past_year"`. Must be one of:<ul><li>`"popular_all_time"` </li><li>`"popular_past_year"`</li><li>`"popular_past_six_months"` </li><li>`"popular_past_month"`</li></ul>This parameter is required when including the `logical_operator` parameter. |
| `logical_operator` | String               | When `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.                                                            |

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

<Warning>
  **Please note:**

  This function has a limit of 200 posts. This function also has a limit of 10 calls per page and per email.
</Warning>

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

<Tabs sync={false}>
  <Tab title="HubL">
    ```jinja wrap theme={null}
    <a href="{{ blog_post_archive_url("default", 2017, 7, 5) }}">Posts from July 5th, 2017</a>
    ```
  </Tab>

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

| Parameter                             | Type                 | Description                                                                                       |
| ------------------------------------- | -------------------- | ------------------------------------------------------------------------------------------------- |
| `selected_blog` <RequiredIndicator /> | Blog ID or "default" | Specifies which blog to use, either a specific blog by its ID or the default blog by `"default"`. |
| `year` <RequiredIndicator />          | Integer              | The year that the post was published.                                                             |
| `month`                               | Integer              | The month that the post was published.                                                            |
| `day`                                 | Integer              | The day that the post was published.                                                              |

## 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. 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 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](/cms/reference/hubl/variables#blog-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.

<Warning>
  **Please note:**

  This function has a limit of 200 posts and 10 calls per page and per email.
</Warning>

<Tabs sync={false}>
  <Tab title="HubL">
    ```html theme={null}
    {{ 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 %}
    ```
  </Tab>

  <Tab title="Output">
    ```
    [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>
    ```
  </Tab>
</Tabs>

| Parameter       | Type                 | Description                                                                                                                                                                               |
| --------------- | -------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `selected_blog` | Blog ID or "default" | Specifies which blog to retrieve posts from. The blog ID is returned by the [module blog field](/cms/reference/fields/module-theme-fields#blog).                                          |
| `author_slug`   | String               | Specifies which author to filter posts by. This can be the `content.blog_post_author.slug` to use the author of the current post, or a lowercase hyphenated name such as `"paul-bunyan"`. |
| `limit`         | Integer              | Specifies the number of posts to add to the sequence up to a limit of 200.                                                                                                                |

## 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 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](/cms/reference/hubl/variables#blog-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.

<Warning>
  **Please note:**

  This function has a limit of 200 posts and 10 calls per page and per email.
</Warning>

<Tabs sync={false}>
  <Tab title="HubL">
    ```html theme={null}
    {{ 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 %}
    ```
  </Tab>

  <Tab title="Output">
    ```
    [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>
    ```
  </Tab>
</Tabs>

| Parameter       | Type                 | Description                                                                                                                                                                                           |
| --------------- | -------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `selected_blog` | Blog 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](/cms/reference/fields/module-theme-fields#blog). |
| `limit`         | Integer              | Specifies the number of posts to add to the sequence, maximum 200.                                                                                                                                    |

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

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](/cms/reference/hubl/variables#blog-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.

Learn more about [creating a related blog post listing](/cms/reference/hubl/tags/related-blog-posts).

<Warning>
  **Please note:**

  This function has a limit of 100 posts and 10 calls per page and per email.
</Warning>

<Tabs sync={false}>
  <Tab title="HubL">
    ```jinja theme={null}
    {{ blog_recent_tag_posts("default", "marketing-tips", 5) }}
    {% set tag_posts = blog_recent_tag_posts("default", ["marketing", "fun", "inbound"], 3, "AND") %}
    {% for tag_post in tag_posts %}
    <div class="post-title">{{ tag_post.name }}</div>
    {% endfor %}
    ```
  </Tab>

  <Tab title="Output">
    ```
    [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>
    ```
  </Tab>
</Tabs>

| Parameter          | Type                 | Description                                                                                                                                                                                                                                               |
| ------------------ | -------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `selected_blog`    | Blog 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](/cms/reference/fields/module-theme-fields#blog).                                                     |
| `tag_slug`         | String               | Specifies 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.                                                                                             |
| `limit`            | Integer              | Specifies the number of posts to add to the sequence. This parameter is required when including a `logical_operator`.                                                                                                                                     |
| `logical_operator` | String               | When `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. |

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

<Tabs sync={false}>
  <Tab title="HubL">
    ```jinja theme={null}
    <a href="{{ blog_tag_url("default", "inbound-marketing") }}">Inbound Marketing</a>
    ```
  </Tab>

  <Tab title="Output">
    ```
    <a href="http://blog.hubspot.com/marketing/tag/inbound-marketing"
    >Inbound Marketing</a
    >
    ```
  </Tab>
</Tabs>

| Parameter       | Type                 | Description                                                                                       |
| --------------- | -------------------- | ------------------------------------------------------------------------------------------------- |
| `selected_blog` | Blog ID or "default" | Specifies which blog to use, either a specific blog by its ID or the default blog by `"default"`. |
| `tag_slug`      | String               | Specifies which tag to link to.                                                                   |

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

<Warning>
  **Please note:**

  This function has a limit of 250 tags.
</Warning>

<Tabs sync={false}>
  <Tab title="HubL">
    ```jinja theme={null}
    {{ 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>
    ```
  </Tab>

  <Tab title="Output">
    ```
    [ Blogging, Inbound Marketing, SEO, Social Media]

    <ul>
      <li><a href="http://blog.hubspot.com/marketing/tag/blogging">Blogging</a></li>
      <li><a href="http://blog.hubspot.com/marketing/tag/inbound-marketing">Inbound Marketing</a></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>
    </ul>
    ```
  </Tab>
</Tabs>

| Parameter       | Type                 | Description                                                                                                                      |
| --------------- | -------------------- | -------------------------------------------------------------------------------------------------------------------------------- |
| `selected_blog` | Blog ID or "default" | Specifies which blog to use. The blog ID is returned by the [module blog field](/cms/reference/fields/module-theme-fields#blog). |
| `limit`         | Integer              | The maximum amount of tags to return.                                                                                            |

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

<Warning>
  **Please note:**

  This function has a limit of 10 calls per page and per email.
</Warning>

<Tabs sync={false}>
  <Tab title="HubL">
    ```
    {{ blog_total_post_count }}
    {{ blog_total_post_count(359485112) }}
    ```
  </Tab>

  <Tab title="Output">
    ```
    16 54
    ```
  </Tab>
</Tabs>

| Parameter       | Type                 | Description                                                                                                                        |
| --------------- | -------------------- | ---------------------------------------------------------------------------------------------------------------------------------- |
| `selected_blog` | Blog ID or "default" | Specifies which blog to count. The blog ID is returned by the [module blog field](/cms/reference/fields/module-theme-fields#blog). |

## clear

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

<Tabs sync={false}>
  <Tab title="HubL">
    ```jinja theme={null}
    {% set words = ["phone","home"] %}
    {% do words.clear() %}
    {{words}}
    ```
  </Tab>

  <Tab title="Output">
    ```
    []
    ```
  </Tab>
</Tabs>

## color\_contrast

This function validates color contrast based on [WCAG standards](https://www.w3.org/WAI/WCAG21/Understanding/contrast-minimum). 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.

<Tabs sync={false}>
  <Tab title="HubL">
    ```jinja theme={null}
    {{color_contrast('#FFFFFF','#273749')}}
    {{color_contrast('rgb(255, 255, 255)','rgb(229, 237, 245)','AAA')}}
    <p {% if color_contrast('rgb(12,31,1)', '#F0F', 'AA') %}style="color: #FF0000;"{% else %}style="color: #00FF00"{% endif %}>Hey there</p>
    ```
  </Tab>

  <Tab title="Output">
    ```
    true false Hey there
    ```
  </Tab>
</Tabs>

| Parameter | Type   | Description                                                                                                                                                                                                                                                         |
| --------- | ------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `color_1` | Color  | The first color to compare. Accepts:<ul><li>6-digit hex codes (`#FFFFFF`)</li><li>3-digit hex codes (`#F0A`)</li><li>RGB color codes (`rgb(12,31,1)`)</li></ul>Can also use a variable that stores a hex or RGB color code. For example:`theme.primary_color.color` |
| `color_2` | Color  | The second color to compare against the first.                                                                                                                                                                                                                      |
| `rating`  | String | The WCAG standard to use for rating. Can be either `AA` (default) or `AAA`.                                                                                                                                                                                         |

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

<Tabs sync={false}>
  <Tab title="HubL">
    ```jinja theme={null}
    {% set base_color ="#3A539B" %}
    {{ color_variant(base_color, -80) }}
    ```
  </Tab>

  <Tab title="Output">
    ```
    #00034b
    ```
  </Tab>
</Tabs>

| Parameter           | Type             | Description                                                             |
| ------------------- | ---------------- | ----------------------------------------------------------------------- |
| `base_color`        | HEX color string | The starting color to be altered. For example, `#F7F7F7`.               |
| `brightness_offset` | Integer          | A positive or negative number used to lighten or darken the base color. |

## content\_by\_id

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.

<Warning>
  **Please note:**

  This function has a limit of 10 calls per page and 20 calls per email.
</Warning>

<Tabs sync={false}>
  <Tab title="HubL">
    ```jinja theme={null}
    {% set my_content = content_by_id(4715624297) %}
    <ul>
      <li>
      <a href="{{ my_content.absolute_url }}">{{my_content.title}}</a>
      </li>
    </ul>
    ```
  </Tab>

  <Tab title="Output">
    ```
    <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>
    ```
  </Tab>
</Tabs>

| Parameter | Type | Description                       |
| --------- | ---- | --------------------------------- |
| `id`      | ID   | The ID of the content to look up. |

## 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. The below example code shows this function in use to generate a list of hyperlinked list items.

<Warning>
  **Please note:**

  This function has a limit of 10 calls per page and per email.
</Warning>

<Tabs sync={false}>
  <Tab title="HubL">
    ```jinja theme={null}
    {% 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>
    ```
  </Tab>

  <Tab title="Output">
    ```
    <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>
    ```
  </Tab>
</Tabs>

| Parameter | Type | Description                                                                          |
| --------- | ---- | ------------------------------------------------------------------------------------ |
| `ids`     | List | A list of page or blog post IDs to look up. Up to 100 content objects can be passed. |

## copy

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.

<Tabs sync={false}>
  <Tab title="HubL">
    ```jinja theme={null}
    {% set a = ["ham"] %}
    {% set b = a.copy() %}
    a: {{a}}

    b: {{b}}

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

    b: {{b}}
    ```
  </Tab>

  <Tab title="Output">
    ```
    a: [ham] b: [ham] After Append a: [ham, swiss] b: [ham]
    ```
  </Tab>
</Tabs>

## count

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

<Tabs sync={false}>
  <Tab title="HubL">
    ```jinja theme={null}
    {% 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.
    ```
  </Tab>

  <Tab title="Output">
    ```
    There are 1 Jon's in the list.
    <p>After append:</p>

    There are now 2 Jon's in the list.
    ```
  </Tab>
</Tabs>

## crm\_associations

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

<Warning>
  **Please note:**

  * For security purposes, of the [HubSpot standard object types](https://knowledge.hubspot.com/get-started/manage-your-crm-database#standard-objects) only the `product`, and `marketing_event` objects can be retrieved on a publicly accessible page. Any other standard object type must be hosted on a page which is either [password protected](https://knowledge.hubspot.com/website-pages/password-protect-a-page) or requires a [membership login](https://knowledge.hubspot.com/website-pages/require-member-registration-to-access-private-content). Custom objects do not have this same restriction.
  * This function can be called a maximum of 10 times per page and per email. Each `crm_associations` call can return at most 100 objects. The default limit is 10 objects.
</Warning>

<Tabs sync={false}>
  <Tab title="HubL">
    ```jinja wrap theme={null}
    {% set associated_contacts = crm_associations(847943847, "HUBSPOT_DEFINED", 2, "limit=3&years_at_company__gt=2&orderBy=email", "firstname,email", false) %}
    {{ associated_contacts }}
    ```

    | Property               | Type    | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
    | ---------------------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
    | `id`                   | ID      | ID of the record to find associations from.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
    | `association category` | String  | The 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 id`  | Integer | The ID of the association definition to use. For standard HubSpot supported objects see [ID of the association type to use](/api-reference/latest/crm/associations/associate-records/guide).Otherwise, this association ID can found at the [CRM Objects Schema API](/cms/start-building/features/data-driven-content/crm-objects#getting-a-custom-object-type-s-details).                                                                                                                                                                                                                                                                                                                                                                                                                                         |
    | `query`                | String  | The `id` of the record OR a query string, delimited by `&`. All expressions are ANDed together. Supported operators are:<ul><li>`eq` (default)</li><li>`neq`</li><li>`lt`</li><li>`lte`</li><li>`gt`</li><li>`gte`</li><li>`is_null`</li><li>`not_null`</li><li>`in`</li><li>`nin`</li><li>`contains` (applicable for multi-valued properties or string properties, e.g., *"firstname\_\_contains=Tim"*)</li></ul>Queries can include the following parameters:<ul><li>`limit`: the maximum number of results returned in the response. For example, `limit=50`.</li><li>`offset`: for paging through the results if the number of returned results is higher than the limit parameter. For example, `offset=51`.</li><li>`orderBy`: order results by a specific property. For example, `orderBy=email`.</li></ul> |
    | `properties`           | String  | Optional. 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](/api-reference/legacy/crm/properties/v1/company-properties/get-properties-v1-companies-properties) and [get all company properties](/api-reference/legacy/crm/pipelines/get-pipelines) endpoints.                                                                                                                                                                                                                                                                                                                                                                            |
    | `formatting`           | Boolean | Optional. Format values such as dates and currency according to the account's settings. Omit or pass `false` for raw strings.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
  </Tab>

  <Tab title="Output">
    ```jinja wrap theme={null}
    {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}]}
    ```

    | Property   | Type    | Description                                                                    |
    | ---------- | ------- | ------------------------------------------------------------------------------ |
    | `has_more` | Boolean | Indicates there are more results available beyond this batch (total > offset). |
    | `total`    | Integer | The total number of results available.                                         |
    | `offset`   | Integer | The offset to use for the next batch of results.                               |
    | `results`  | Array   | The associated objects matching the function's parameters.                     |
  </Tab>
</Tabs>

## crm\_object

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](/cms/start-building/features/data-driven-content/crm-objects).

<Warning>
  **Please note:**

  * For security purposes, of the [HubSpot standard object types](https://knowledge.hubspot.com/get-started/manage-your-crm-database#standard-objects) only the `product`, and `marketing_event` objects can be retrieved on a publicly accessible page. Any other standard object type must be hosted on a page which is either [password protected](https://knowledge.hubspot.com/website-pages/password-protect-a-page) or requires a [membership login](https://knowledge.hubspot.com/website-pages/require-member-registration-to-access-private-content). Custom objects do not have this same restriction.
  * This function can only be called a maximum of 10 times on a single page.
</Warning>

<Tabs sync={false}>
  <Tab title="HubL">
    ```jinja theme={null}
    <!-- 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 }}
    ```
  </Tab>

  <Tab title="Output">
    ```
    Brian Halligan
    ```
  </Tab>
</Tabs>

| Parameter     | Type    | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| ------------- | ------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `object_type` | String  | The object type name. Object type names are case sensitive. [The supported object types](/cms/start-building/features/data-driven-content/crm-objects#supported-crm-object-types). To find the names of the account specific and integrator object types available in your account use the [CRM Objects Schema API](/cms/start-building/features/data-driven-content/crm-objects#getting-a-custom-object-type-s-details) to get the type definitions and look for the name property. It contains the internal object type name that should be used in the function. For integrator and account specific object types with the same name as the built-in objects use the objects [fully qualified name](/cms/start-building/features/data-driven-content/crm-objects#getting-a-custom-object-type-s-details) (FQN).          |
| `query`       | String  | Optional. The `id` of the record OR a query string, delimited by `&`. All expressions are ANDed together. Supported operators are:<ul><li>`eq` (default)</li><li>`neq`</li><li>`lt`</li><li>`lte`</li><li>`gt`</li><li>`gte`</li><li>`is_null`</li><li>`not_null`</li><li>`in`</li><li>`nin`</li><li>`contains` (applicable for multi-valued properties or string properties, e.g., `"firstname__contains=Tim"`).</li></ul>Queries can include the following parameters:<ul><li>`limit`: the maximum number of results returned in the response. For example, `limit=50`.</li><li>`offset`: for paging through the results if the number of returned results is higher than the limit parameter. For example, `offset=51`.</li><li>`orderBy`: order results by a specific property. For example, `orderBy=email`.</li></ul> |
| `properties`  | String  | Optional. 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](/api-reference/legacy/crm/properties/v1/company-properties/get-properties-v1-companies-properties) and [get all company properties](/api-reference/legacy/crm/pipelines/get-pipelines) endpoints.                                                                                                                                                                                                                                                                                                                                                                                     |
| `formatting`  | Boolean | Optional. Format values such as dates and currency according to the account's settings. Pass `false` for raw strings.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |

<Warning>
  **Please note:**

  When building a query, the values of `range`, `distinct`, `ndistinct`, and `startswith` are reserved keywords. To query a property that uses one of those names, you'll need to use the following format: `range__eq=` (rather than `range=`).
</Warning>

## crm\_objects

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

<Warning>
  **Please note:**

  * For security purposes, of the [HubSpot standard object types](https://knowledge.hubspot.com/get-started/manage-your-crm-database#standard-objects) only the `product`, and `marketing_event` objects can be retrieved on a publicly accessible page. Any other standard object type must be hosted on a page which is either [password protected](https://knowledge.hubspot.com/website-pages/password-protect-a-page) or requires a [membership login](https://knowledge.hubspot.com/website-pages/require-member-registration-to-access-private-content). Custom objects do not have this same restriction.
  * This function can be called a maximum of 10 times per page and per email. Each `crm_objects` call can return at most 100 objects. The default limit is 10 objects.
</Warning>

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 (e.g., `order=-createdate`). The CRM objects function can also be [used with custom and integrator objects](/cms/start-building/features/data-driven-content/crm-objects).

<Tabs sync={false}>
  <Tab title="HubL">
    ```jinja wrap theme={null}
    {% set objects = crm_objects("contact", "firstname__not_null=&limit=3", "firstname,lastname") %}
    {{ objects }}
    ```

    | Parameter                           | Type    | Description                                                                                                                                                                                                                                                                                                                                                                                                                                           |
    | ----------------------------------- | ------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
    | `object_type` <RequiredIndicator /> | String  | The object type name (case-sensitive). See [supported object types](/cms/start-building/features/data-driven-content/crm-objects#supported-crm-object-types). For custom objects, you'll need to use the Fully Qualified Name (FQN), which can be found using the [Schemas API](/api-reference/latest/crm/objects/schemas/get-schemas).                                                                                                               |
    | `query`                             | String  | The ID of the record or a query string, delimited by `&`. All expressions are ANDed together. Supported operators are:<ul><li>`eq` (default)</li><li>`neq`</li><li>`lt`</li><li>`lte`</li><li>`gt`</li><li>`gte`</li><li>`is_null`</li><li>`not_null`</li><li>`in`</li><li>`nin`</li><li>`contains` (applicable for multi-valued properties or string properties, e.g., `"firstname__contains=Tim"`).</li></ul>Example: `"email=contact@company.com"` |
    | `properties`                        | String  | A comma-separated list of properties to return. By default, a small set of common properties are returned. You can retrieve all properties for an object using the [Properties API](/api-reference/latest/crm/properties/guide).                                                                                                                                                                                                                      |
    | `formatting`                        | Boolean | Format values such as dates and currency according to the account's settings. Pass `false` for raw strings.                                                                                                                                                                                                                                                                                                                                           |
  </Tab>

  <Tab title="Output">
    ```jinja wrap theme={null}
    {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}]}
    ```

    | Property   | Type    | Description                                                                                                   |
    | ---------- | ------- | ------------------------------------------------------------------------------------------------------------- |
    | `has_more` | Boolean | Indicates there are more results available beyond this batch (total > offset).                                |
    | `total`    | Integer | The total number of results available.                                                                        |
    | `offset`   | Integer | The offset to use for the next batch of results.                                                              |
    | `results`  | Array   | The associated objects matching the function's parameters. See results properties below for more information. |
  </Tab>
</Tabs>

<Warning>
  **Please note:**

  When building a query, the values of `range`, `distinct`, `ndistinct`, and `startswith` are reserved keywords. To query a property that uses one of those names, you'll need to use the following format: `range__eq=` (rather than `range=`).
</Warning>

## crm\_property\_definition

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

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

<Tabs sync={false}>
  <Tab title="HubL">
    ```jinja theme={null}
    {% set prop = crm_property_definition("contact", "firstname") %}
    {{ prop.label }}
    {{ prop.type }}
    ```
  </Tab>

  <Tab title="Output">
    ```
    First name
    string
    ```
  </Tab>
</Tabs>

| Parameter       | Type   | Description                                                                                                                                                                                                                                                                                                                             |
| --------------- | ------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `object_type`   | String | The object type name (case-sensitive). See [supported object types](/cms/start-building/features/data-driven-content/crm-objects#supported-crm-object-types). For custom objects, you'll need to use the Fully Qualified Name (FQN), which can be found using the [Schemas API](/api-reference/latest/crm/objects/schemas/get-schemas). |
| `property_name` | String | The case-insensitive property name to retrieve the definition for.                                                                                                                                                                                                                                                                      |

## crm\_property\_definitions

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

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

<Tabs sync={false}>
  <Tab title="HubL">
    ```jinja theme={null}
    {% set props = crm_property_definitions("contact", "firstname,lastname") %}
    {{ props.firstname.label }}
    {{ props.lastname.label }}
    ```
  </Tab>

  <Tab title="Output">
    ```
    First name
    Last name
    ```
  </Tab>
</Tabs>

| Parameter       | Type   | Description                                                                                                                                                                                                                                                                                                                             |
| --------------- | ------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `object_type`   | String | The object type name (case-sensitive). See [supported object types](/cms/start-building/features/data-driven-content/crm-objects#supported-crm-object-types). For custom objects, you'll need to use the Fully Qualified Name (FQN), which can be found using the [Schemas API](/api-reference/latest/crm/objects/schemas/get-schemas). |
| `property_name` | String | Optional. The case-insensitive property names comma separated, to retrieve the definition for. If empty, the definitions for all the properties will be retrieved.                                                                                                                                                                      |

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

<Warning>
  **Please note:**

  This function has a limit of 10 calls per page and per email.
</Warning>

<Tabs sync={false}>
  <Tab title="HubL">
    ```jinja theme={null}
    {{ cta("ccd39b7c-ae18-4c4e-98ee-547069bfbc5b")  }}
    {{ cta("ccd39b7c-ae18-4c4e-98ee-547069bfbc5b", "justifycenter") }}
    ```
  </Tab>

  <Tab title="Output">
    ```html theme={null}
    <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>
    ```
  </Tab>
</Tabs>

| Parameter   | Type        | Description                                                                                             |
| ----------- | ----------- | ------------------------------------------------------------------------------------------------------- |
| `guid`      | String      | The ID of the CTA to render. Can be found in the URL of the details screen of the CTA.                  |
| `align_opt` | Enumeration | Adjusts alignment of CTA. Values include `justifyleft`, `justifycenter`, `justifyright`, `justifyfull`. |

## extend

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

<Tabs sync={false}>
  <Tab title="HubL">
    ```jinja theme={null}
    {% set vehicles = ["boat","car","bicycle"] %}
    {% set more_vehicles = ["airplane","motorcycle"] %}
    {% do vehicles.extend(more_vehicles) %}
    {{vehicles}}
    ```
  </Tab>

  <Tab title="Output">
    ```html theme={null}
    [boat, car, bicycle, airplane, motorcycle]
    ```
  </Tab>
</Tabs>

## file\_by\_id

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](#files_by_ids) function instead.

<Warning>
  **Please note:**

  This function is limited to 10 calls per page and per email.
</Warning>

<Tabs sync={false}>
  <Tab title="HubL">
    ```jinja theme={null}
    {% set file = file_by_id(123) %}
    {{ file.friendlyUrl }}
    ```
  </Tab>

  <Tab title="Output">
    ```html theme={null}
    https://www.hubspot.com/hubfs/HubSpot_Logos/HSLogo_color.svg
    ```
  </Tab>
</Tabs>

| Parameter | Type   | Description                    |
| --------- | ------ | ------------------------------ |
| `file_id` | Number | The ID of the file to look up. |

## files\_by\_ids

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

<Warning>
  **Please note:**

  This function limited to 10 calls per page and per email, and can accept up to 100 file IDs.
</Warning>

<Tabs sync={false}>
  <Tab title="HubL">
    ```jinja theme={null}
    {% set files = files_by_ids([123,456])%}
    {% for file in files %}
    URL:{{file.friendlyUrl}}
    <br>
    {% endfor %}
    ```
  </Tab>

  <Tab title="Output">
    ```html theme={null}
    URL:https://api-na1.hubspot.com/filemanager/api/v2/files/123/example-file-1
    URL:https://api-na1.hubspot.com/filemanager/api/v2/files/456/example-file-2
    ```
  </Tab>
</Tabs>

| Parameter | Type   | Description                                                       |
| --------- | ------ | ----------------------------------------------------------------- |
| `file_id` | Number | The 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](/cms/reference/hubl/filters#split), as the CRM property will be returned as a semicolon-separated string.

```jinja theme={null}
{% set objects = crm_objects("contact", "email=bh@hubspot.com", "file").results %}

{% for item in objects %}

<!-- Need to use split filter as CRM property returns a string that is semi-colon separated -->
{% set fileIDs = item.file|split(";") %}

{% set files = files_by_ids(fileIDs) %}

 {% for file in files %}
 <div>
  File name: {{file.name}}
  <br>
  Friendly Url: {{file.friendlyUrl }}
  <br>
  Url: {{file.url }}
  <hr><br>
 </div>
 {% endfor %}
{% endfor %}
```

## flag\_content\_for\_access\_check

When a blog post is [configured for self-registration access](https://knowledge.hubspot.com/blog/use-self-registration-for-private-blog-content), 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](/cms/start-building/features/memberships/overview#private-blog-posts-with-self-registration).

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.

<Tabs sync={false}>
  <Tab title="HubL">
    ```jinja theme={null}
    {% for content in contents %}
    <article {{ flag_content_for_access_check(content.id) }} >
      ...
    </article>
    {% endfor %}
    ```
  </Tab>

  <Tab title="Output">
    ```html theme={null}
    <article hs-member-content-access="true">...</article>
    ```
  </Tab>
</Tabs>

| Parameter | Type | Description                                                                      |
| --------- | ---- | -------------------------------------------------------------------------------- |
| `ID`      | ID   | The ID of the content that will be checked against the current logged in viewer. |

## follow\_me\_links

Returns the [social media account links set in account settings](https://knowledge.hubspot.com/design-manager/use-default-modules-in-the-layout-editor#add-social-accounts-to-the-follow-me-module). Used in the [default follow\_me module](/cms/reference/modules/default-modules#follow-me).

<Tabs sync={false}>
  <Tab title="HubL">
    ```jinja theme={null}
    {% set fm = follow_me_links() %}
    {{ fm }}
    ```
  </Tab>

  <Tab title="Output">
    ```html theme={null}
    [FollowMeLink{type=URL, id=5142734, altName=RSS,
    followMeUrl=http://website.com/rss.xml, iconName=rss,
    name=http://website.com/rss.xml}]
    ```
  </Tab>
</Tabs>

## format\_address

Formats an address based on the context's locale.

<Tabs sync={false}>
  <Tab title="HubL">
    ```jinja theme={null}
    {{ format_address('en-us', { address: "25 First Street", address2: "2nd Floor", city: "Cambridge", state: "MA", country: "United States", zip: "02141"}) }}
    ```
  </Tab>

  <Tab title="Output">
    ```
    [25 First Street, 2nd Floor, Cambridge, MA 02141, United States]
    ```
  </Tab>
</Tabs>

| Parameter  | Type   | Description                                                        |
| ---------- | ------ | ------------------------------------------------------------------ |
| `locale`   | String | The locale to format the address in.                               |
| `address`  | String | The street address.                                                |
| `address2` | String | The second line of the address, such as floor or apartment number. |
| `city`     | String | The city of the address.                                           |
| `state`    | String | The state of the address.                                          |
| `country`  | String | The country of the address.                                        |
| `zip`      | String | The zip code of the address.                                       |

## format\_company\_name

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

<Tabs sync={false}>
  <Tab title="HubL">
    ```jinja theme={null}
    {{ format_company_name("companyName", addJapaneseHonorifics) }}
    ```
  </Tab>

  <Tab title="Output">
    ```
    HubSpot
    ```
  </Tab>
</Tabs>

| Parameter                  | Type    | Description                                                                                                              |
| -------------------------- | ------- | ------------------------------------------------------------------------------------------------------------------------ |
| `companyName`              | String  | The name of the company.                                                                                                 |
| `useHonorificIfApplicable` | Boolean | When set to `true` and the context's language is Japanese, a Japanese company honorific will be added where appropriate. |

## format\_name

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

<Tabs sync={false}>
  <Tab title="HubL">
    ```jinja theme={null}
    {{ format_name("firstName", "surname", addJapaneseHonorifics) }}
    ```
  </Tab>

  <Tab title="Output">
    ```
    Hobbes Baron
    ```
  </Tab>
</Tabs>

| Parameter                  | Type    | Description                                                                                                                          |
| -------------------------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------ |
| `firstName`                | String  | The person's first name.                                                                                                             |
| `surname`                  | String  | The person's surname or last name.                                                                                                   |
| `useHonorificIfApplicable` | Boolean | When set to `true` and the context's language is Japanese, a Japanese honorific will be added where appropriate. Default is `false`. |

## format\_datetime

Formats both the date and time components of a date object, similar to the [format\_datetime](/cms/reference/hubl/filters#format_datetime) HubL filter. This function replaces the deprecated `datetimeformat` function.

<Tabs sync={false}>
  <Tab title="HubL">
    ```jinja theme={null}
    {{ format_datetime(content.publish_date, "short", "America/New_York", "en") }}
    ```
  </Tab>

  <Tab title="Output">
    ```
    12/31/69 7:00 PM
    ```
  </Tab>
</Tabs>

| Parameter  | Type   | Description                                                                                                                                                                                                                        |
| ---------- | ------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `format`   | String | The format to use. Can be one of:<ul><li>`short`</li><li>`medium`</li><li>`long`</li><li>`full`</li><li>a custom pattern following [Unicode LDML](https://unicode.org/reports/tr35/tr35-dates.html#Date_Format_Patterns)</li></ul> |
| `timeZone` | String | The time zone of the output date in [IANA TZDB format](https://data.iana.org/time-zones/tzdb/).                                                                                                                                    |
| `locale`   | String | The locale to use for locale-aware formats.                                                                                                                                                                                        |

## geo\_distance

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.

<Tabs sync={false}>
  <Tab title="HubL">
    ```jinja theme={null}
    {% for row in hubdb_table_rows(1234567, "geo_distance(loc,1.233,-5.678,mi)__gt=500") %}
    {{row.name}} <br>
    {% endfor %}
    ```
  </Tab>

  <Tab title="Output">
    ```
    Cambridge, MA<br />
    Salem, MA<br />
    San Diego, CA<br />
    Chicago, IL<br />
    ```
  </Tab>
</Tabs>

| Parameter     | Type      | Description                                                                                                   |
| ------------- | --------- | ------------------------------------------------------------------------------------------------------------- |
| `point1`      | Location  | location from a HubDB column.                                                                                 |
| `point2_lat`  | Latitude  | Latitude of point2.                                                                                           |
| `point2_long` | Longitude | Longitude of point2.                                                                                          |
| `units`       | String    | Units for the return value. Options are `FT` for feet, `MI` for miles, `M` for meters or `KM` for kilometers. |

## get\_asset\_url

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.

<Frame>
  <img src="https://cdn2.hubspot.net/hubfs/53/Designers_Docs_2015/copy-public-url-4.gif" alt="copy-public-url" />
</Frame>

<Tabs sync={false}>
  <Tab title="HubL">
    ```jinja theme={null}
    {{ get_asset_url("/custom/styles/style.css") }}
    ```
  </Tab>

  <Tab title="Output">
    ```
    //cdn2.hubspot.net/hub/1234567/hub_generated/template_assets/1565970767575/custom/styles/style.min.css
    ```
  </Tab>
</Tabs>

| Parameter | Type   | Description                                           |
| --------- | ------ | ----------------------------------------------------- |
| `path`    | String | The design manager file path to the template or file. |

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

<Tabs sync={false}>
  <Tab title="HubL">
    ```html theme={null}
    {{ get_public_template_url_by_id("2778457004")  }}
    ```
  </Tab>

  <Tab title="Output">
    ```
    //cdn2.hubspot.net/hub/327485/hub_generated/style_manager/1431479563436/custom/page/Designers_2015/designer-doc-2105.min.js
    ```
  </Tab>
</Tabs>

| Parameter     | Type | Description                            |
| ------------- | ---- | -------------------------------------- |
| `template_id` | ID   | The ID number of the template of file. |

## hubdb\_table

<Warning>
  **Please note:**

  * [HubDB](/cms/start-building/features/storage/hubdb) requires ***Content Hub*** *Professional* or *Enterprise*.
  * This function has a limit of 10 calls per page and per email.
</Warning>

The `hubdb_table` function can be used to get metadata from a HubDB table, specified by table ID. You can access the follow metadata attributes via dot notation:

* `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.

<Tabs sync={false}>
  <Tab title="HubL">
    ```jinja theme={null}
    {% set table_info = hubdb_table(1548215) %}
    {{ table_info.row_count }}
    ```
  </Tab>

  <Tab title="Output">
    ```
    25
    ```
  </Tab>
</Tabs>

| Parameter  | Type   | Description              |
| ---------- | ------ | ------------------------ |
| `table_id` | String | ID or name of the table. |

## hubdb\_table\_column

<Warning>
  **Please note:** [HubDB](/cms/start-building/features/storage/hubdb) requires ***Content Hub*** *Professional* or *Enterprise*.
</Warning>

Retrieves metadata about a column in a given HubDB table. the function accepts two parameters: the table ID or name, followed by the column ID or name. Column names are not case sensitive. For example, `HS_ID` and `hs_id` are both valid.

The following metadata is available:

* `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, you can also use `getOptionByName("<option name>")` for select type columns. This method retrieves information for the specified option.

<Tabs sync={false}>
  <Tab title="HubL">
    ```jinja theme={null}
    {% set column_info = hubdb_table_column(123456, 6)  %}
    {{ column_info.label }}
    ```
  </Tab>

  <Tab title="Output">
    ```
    role
    ```
  </Tab>
</Tabs>

| Parameter  | Type   | Description                                  |
| ---------- | ------ | -------------------------------------------- |
| `table_id` | String | ID or name of the table.                     |
| `column`   | String | ID or name of the column (case insensitive). |

## hubdb\_table\_row

<Warning>
  **Please note:**

  * [HubDB](/cms/start-building/features/storage/hubdb) requires ***Content Hub*** *Professional* or *Enterprise*.
  * This function has a limit of 10 calls per page and per email.
</Warning>

The `hubdb_table_row` function can be used to pull a single row from a HubDB table. From a 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 a column for this row, specified by the `name` of the column. Column names are not case sensitive. For example, `HS_ID` and `hs_id` are both valid.

<Tabs sync={false}>
  <Tab title="HubL">
    ```jinja theme={null}
    {% set row = hubdb_table_row(1548264, 6726439331)  %}
    {{ row.role  }}
    ```
  </Tab>

  <Tab title="Output">
    ```
    CTO
    ```
  </Tab>
</Tabs>

| Parameter  | Type    | Description                 |
| ---------- | ------- | --------------------------- |
| `table_id` | String  | ID or name of the table.    |
| `row_id`   | Integer | ID of the row of the table. |

## hubdb\_table\_rows

<Warning>
  **Please note:**

  * [HubDB](/cms/start-building/features/storage/hubdb) requires ***Content Hub*** *Professional* or *Enterprise*.
  * This function has a limit of 10 calls per page and per email.
  * If you use a [random filter](/cms/reference/hubl/filters#random) on this function, the page will be [prerendered](/cms/best-practices/testing-staging-performance/prerendering) periodically. This means that the filtered content will not be updated on every page reload.
</Warning>

The `hubdb_table_rows` function can be used to query rows of a HubDB table, which can be useful for iterating through row values.

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.

<Tabs sync={false}>
  <Tab title="HubL">
    ```jinja theme={null}
    {% for row in hubdb_table_rows(1546258, "years_at_company__gt=3&orderBy=count&limit=1500") %}
      the value for row {{ row.hs_id }} is {{ row.name }}
    {% endfor %}
    ```
  </Tab>

  <Tab title="Output">
    ```
    the value for row 6726439331 is Brian Halligan the value for row 8438997836 is
    Dharmesh Shah
    ```
  </Tab>
</Tabs>

| Parameter  | Type   | Description                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| ---------- | ------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `table_id` | String | ID or name of the table to query.                                                                                                                                                                                                                                                                                                                                                                                                                |
| `query`    | String | A query in the same format as a URL query string. If not passed, returns all rows. Learn more about the [available filters](/api-reference/legacy/cms/hubdb/guide) for querying HubDB table rows. <br /><br /> You can sort the returned rows by including the `orderBy` parameter and specifying a column. To reverse the sort, prepend the column name with `-`. Learn more about [sorting HubDB rows](/api-reference/legacy/cms/hubdb/guide). |

<Warning>
  **Please note:**

  When building a query, the values of `range`, `distinct`, `ndistinct`, and `startswith` are reserved keywords. To query a property that uses one of those names, you'll need to use the following format: `range__eq=` (rather than `range=`).
</Warning>

## include\_default\_custom\_css

This function generates a link tag that references the [Primary CSS file](https://knowledge.hubspot.com/design-manager/create-edit-and-attach-css-files-to-style-your-site) (`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`.

<Tabs sync={false}>
  <Tab title="HubL">
    ```jinja theme={null}
    {{ include_default_custom_css(True) }}
    ```
  </Tab>

  <Tab title="Output">
    ```html theme={null}
    <link
    href="https://developers.hubspot.com/docs//cdn2.hubspot.net/hub/327485/hub_generated/style_manager/1420345777097/custom/styles/default/hs_default_custom_style.min.css"
    rel="stylesheet"
    />
    ```
  </Tab>
</Tabs>

## index

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

This function accepts 3 parameters:

* The item in the array that you want to find (required)
* The starting index of the slice of the array to search
* The ending index of the slice of the array to search

<Tabs sync={false}>
  <Tab title="HubL">
    ```jinja theme={null}
    {% 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)}}
    ```
  </Tab>

  <Tab title="Output">
    ```
    triangle index: 0
    trapezoid index: 2
    <hr />
    Adjusted start and end:
    triangle index: 3
    ```
  </Tab>
</Tabs>

## insert

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.

<Tabs sync={false}>
  <Tab title="HubL">
    ```jinja theme={null}
    {% set even_numbers = [2,4,8,10]  %}
    {% do even_numbers.insert(2,6) %}
    {{even_numbers}}
    ```
  </Tab>

  <Tab title="Output">
    ```
    [2, 4, 6, 8, 10]
    ```
  </Tab>
</Tabs>

## locale\_name

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

<Tabs sync={false}>
  <Tab title="HubL">
    ```jinja theme={null}
    {{ locale_name("es") }}
    {{ locale_name("es", "en") }}
    ```
  </Tab>

  <Tab title="Output">
    ```
    Español Spanish
    ```
  </Tab>
</Tabs>

| Parameter              | Type   | Description                                         |
| ---------------------- | ------ | --------------------------------------------------- |
| `language_code`        | String | The language code.                                  |
| `target_language_code` | String | The language that the output will be translated to. |

## load\_translations

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

Learn more about [including field translations in custom modules and themes](/cms/start-building/features/multi-language-content#include-field-translations-in-custom-modules-and-themes).

<Tabs sync={false}>
  <Tab title="HubL">
    ```jinja theme={null}
    {% set template_translations = load_translations('../_locales', 'fr', 'en') %}
    {{ partial_footer_address }}
    ```
  </Tab>

  <Tab title="Output">
    ```
    123 Rue du Pont, Ville, Région, 12300
    ```
  </Tab>
</Tabs>

| Parameter                | Type   | Description                                                                |
| ------------------------ | ------ | -------------------------------------------------------------------------- |
| `path`                   | String | The file path to the \_locales directory of the translations.              |
| `language_code`          | String | The language code.                                                         |
| `language_code_fallback` | String | The language code fallback if the specified `language_code` isn't present. |

## menu

Returns the nested link structure of an advanced menu. Menu nodes have a variety of [properties](/cms/reference/hubl/variables#menu-node-variables) 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`.

<Warning>
  **Please note:**

  This function has a limit of 10 calls per page and per email.
</Warning>

<Tabs sync={false}>
  <Tab title="HubL">
    ```jinja theme={null}
    {% set node = menu(987) %}
    {% for child in node.children %}
      {{ child.label }}<br>
    {% endfor %}

    {% set default_node = menu("default") %}
    {% for child in default_node.children %}
      {{ child.label }}<br>
    {% endfor %}
    ```
  </Tab>

  <Tab title="Output">
    ```html theme={null}
    page1<br />
    page2<br />
    page3<br />
    ```
  </Tab>
</Tabs>

<Tip>
  When using the `menu()` function to generate a menu, [you are fully responsible for making sure your menu is accessible.](/cms/best-practices/improve-existing-sites/accessibility)
</Tip>

| Parameter   | Type        | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| ----------- | ----------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `menu_id`   | Id          | Required. The id of the menu passed as a number.                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| `root_type` | Enumeration | Root type of the menu (`"site_root"`, `"top_parent"`, `"parent"`, `"page_name"`, `"page_id"`, `"breadcrumb"`).<ul><li>`"site_root"` denotes static - Always show top-level pages in menu.</li><li>`"top_parent"` denotes dynamic by section - Show pages in menu that are related to section being viewed.</li><li>`"parent"` denotes dynamic by page - Show pages in menu that are related to page being viewed.</li><li>`"breadcrumb"` denotes breadcrumb style path menu (uses horizontal flow).</li></ul> |
| `root_key`  | String      | Root key (id or name) when using `"page_name"` or `"page_id"`.                                                                                                                                                                                                                                                                                                                                                                                                                                                |

## module\_asset\_url

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

<Tabs sync={false}>
  <Tab title="HubL">
    ```jinja theme={null}
    {{ module_asset_url("smile.jpg") }}
    ```
  </Tab>

  <Tab title="Output">
    ```
    https://cdn2.hubspot.net/hubfs/6178146/logo-black-color.png
    ```
  </Tab>
</Tabs>

| Parameter | Type   | Description            |
| --------- | ------ | ---------------------- |
| `name`    | String | The name of the asset. |

## namespace

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

<Tabs sync={false}>
  <Tab title="HubL">
    ```
    {% set ns = namespace({"name": "item name", "price":"100"}, b=false) %}
    {{ns.name}}, {{ns.b}}
    ```
  </Tab>

  <Tab title="Output">
    ```
    item name, false
    ```
  </Tab>
</Tabs>

| Parameter    | Type   | Description                                             |
| ------------ | ------ | ------------------------------------------------------- |
| `dictionary` | Map    | The dictionary to initialize with.                      |
| `kwargs`     | String | Keyword arguments to put into the namespace dictionary. |

## oembed

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

<Tabs sync={false}>
  <Tab title="HubL">
    ```
    {{ oembed({ url: "https://www.youtube.com/watch?v=KqpFNtbEOh8"}) }}
    ```
  </Tab>

  <Tab title="Output">
    ```jinja theme={null}
    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}
    ```
  </Tab>
</Tabs>

| Parameter | Type   | Description                                                         |
| --------- | ------ | ------------------------------------------------------------------- |
| `request` | String | Request object, `{url: string, max_width: long, max_height: long}`. |

## personalization\_token

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

<Tabs sync={false}>
  <Tab title="HubL">
    ```jinja theme={null}
    Hi {{ personalization_token("contact.firstname", "there") }}!
    ```
  </Tab>

  <Tab title="Output">
    ```
    <!-- If the contact is known -->
    Hi Dharmesh!

    <!-- If the contact is unknown -->
    Hi there!
    ```
  </Tab>
</Tabs>

| Parameter    | Type   | Description                                                      |
| ------------ | ------ | ---------------------------------------------------------------- |
| `expression` | String | An expression for the object and property to render.             |
| `default`    | String | Optional. A default value to use if the expression has no value. |

## pop

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

<Tabs sync={false}>
  <Tab title="HubL">
    ```jinja theme={null}
    {% set even_numbers = [2,3,4,6,8,9,10]  %}
    {% do even_numbers.pop(1) %}
    {{even_numbers.pop(4)}}
    {{even_numbers}}
    ```
  </Tab>

  <Tab title="Output">
    ```
    9 [2, 4, 6, 8, 10]
    ```
  </Tab>
</Tabs>

## 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).

<Tabs sync={false}>
  <Tab title="HubL">
    ```
    {{ postal_location("02139") }}
    {% set location = postal_location("02139", "US") %}
    {{ location.latitude }}
    {{ location.longitude }}
    ```
  </Tab>

  <Tab title="Output">
    ```
    LatLon{latitude=42.3647, longitude=-71.1042} 42.3647 -71.1042
    ```
  </Tab>
</Tabs>

<Warning>
  **Please note:**

  This function has a limit of 10 calls per page and per email.
</Warning>

| Parameter      | Type   | Description                                                                                                  |
| -------------- | ------ | ------------------------------------------------------------------------------------------------------------ |
| `postal_code`  | String | Postal code of the location.                                                                                 |
| `country_code` | String | Country code for the postal code. If not provided, the country will try to be inferred from the postal code. |

## put

Similar to the [update function](#update), 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.

<Tabs sync={false}>
  <Tab title="HubL">
    ```jinja theme={null}
    {% set dict_var = {"authorName": "Tim Robinson"} %}
    {% set key = "key" %}
    {% set value = "value" %}
    {% do dict_var.put(key, value) %}
    {{ dict_var }}
    ```
  </Tab>

  <Tab title="Output">
    ```
    {authorName=Tim Robinson, key=value}
    ```
  </Tab>
</Tabs>

## range

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](/cms/reference/hubl/loops) to specify the number of iterations that should run.

<Tabs sync={false}>
  <Tab title="HubL">
    ```
    {{ range(11) }}
    {{ range(5, 11) }}
    {{ range(0, 11, 2) }}

    {% for number in range(11) %}
    {{ number }}
    {% endfor %}
    ```
  </Tab>

  <Tab title="Output">
    ```
    [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10] [5, 6, 7, 8, 9, 10] [0, 2, 4, 6, 8, 10] 0 1 2
    3 4 5 6 7 8 9 10
    ```
  </Tab>
</Tabs>

## require\_css

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](https://web.dev/articles/defer-non-critical-css#optimize) and any other key-value pair will be added as HTML attributes to the style tag.

<Tabs sync={false}>
  <Tab title="HubL">
    ```
    {{ standard_header_includes }}
    <!-- more html -->
    {{ require_css("http://example.com/path/to/file.css") }}
    {{ require_css(get_asset_url("/relative/path/to/file.css")) }}

    <!-- you can tell the browser to load the file asynchronously -->
    {{ require_css(get_asset_url("./style.css"), { async: true }) }}
    ```
  </Tab>

  <Tab title="Output">
    ```
    <!-- 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"
    />

    <!-- you can tell the browser to load the file asynchronously -->
    <link
    rel="preload"
    href="https://developers.hubspot.com/docs//cdn2.hubspot.net/hub/6333443/hub_generated/template_assets/39079350918/1608661506628/example.css"
    as="style"
    onload="this.onload=null;this.rel='stylesheet'"
    />
    <noscript
    ><link
    rel="stylesheet"
    href="https://developers.hubspot.com/docs//cdn2.hubspot.net/hub/6333443/hub_generated/template_assets/39079350918/1608661506628/example.css"
    /></noscript>
    <!-- more html -->
    ```
  </Tab>
</Tabs>

## require\_personalization\_properties

Allows you to personalize content while still permitting [prerendering](/cms/best-practices/testing-staging-performance/prerendering) options.

Provide any contact or company properties you wish to expose via the `contact_properties` and `company_properties` parameters.

* The function will then generate a signed URL that can be run in a template or executed for a one-time use (which allows you to hardcode the URI).
* Whenever these properties change, the function must be run again to generate a new signature, which will appear as a `sig` query parameter in the `<script>` tag that gets added to your content's HTML.

The resulting `<script>` tag in your HTML will include a `personalization_api_url` value, which should be appended to the content domain where you plan on using your endpoint.

For example, consider the HubL block and rendered HTML below:

<Tabs sync={false}>
  <Tab title="HubL">
    ```jinja theme={null}
    {% require_personalization_properties contact_properties=["a", "b"] company_properties=["c", "d"] %}
    ```
  </Tab>

  <Tab title="Output">
    ```jinja theme={null}
    <script type="application/json" id="personalization_api_url">{"personalization_api_url": "/_hcms/personalization?contactProperties=a,b&companyProperties=c,d&sig=AbCdEfG567890hIjK"}
    </script>
    ```
  </Tab>
</Tabs>

If your page domain was `website.com`, the associated API endpoint would be:

```
https://website.com/_hcms/personalization?contactProperties=a,b&companyProperties=c,d&sig=AbCdEfG567890hIjK
```

You can then make a `GET` request to this endpoint, which would return a response that resembles the following:

```json theme={null}
{
  "user": {
    "contact": {
      "a": "A value",
      "b": "B value"
    },
    "company": {
      "c": "C value",
      "d": "D value"
    }
  },
  "request": {
    "clientIp": "12.34.56.78",
    "country": "US",
    "deviceType": "desktop"
  }
}
```

If the website visitor is known, the API will return the requested contact or company properties (excluding any properties marked as [Sensitive](https://knowledge.hubspot.com/account-security/store-sensitive-data)).

Anonymous data such as user IP, device type, and language are always returned, and does not require a signature.

## require\_js

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](/cms/start-building/building-blocks/templates/html-hubl-templates#header-and-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`

<Tabs sync={false}>
  <Tab title="HubL">
    ```jinja theme={null}
    {{ 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") }}

    <!-- you can add async or defer attributes to the tags that are added. -->
    {{ require_js(get_asset_url("./path/to/file.js"), { position: "footer", async: true }) }}
    {{ require_js(get_asset_url("./jquery-latest.js"), { position: "footer", defer:true }) }}

    {{ standard_footer_includes }}
    ```
  </Tab>

  <Tab title="Output">
    ```html theme={null}
    <!-- other standard header html -->
    <script
    async
    defer
    src="//cdn2.hubspot.net/hub/6333443/hub_generated/template_assets/37785718838/1605816776975/jquery-latest.min.js"
    ></script>

    <script src="http://example.com/path/to/head-file.js"></script>

    <!-- more html -->

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

    <!-- you can add async or defer attributes to the tags that are added. -->
    <script
    async
    src="//cdn2.hubspot.net/hub/######/hub_generated/template_assets/#############/######/jquery-latest.min.js"
    ></script>
    <script
    defer
    src="//cdn2.hubspot.net/hub/######/hub_generated/template_assets/#############/######/jquery-latest.min.js"
    ></script>

    <!-- other standard footer html -->
    ```
  </Tab>
</Tabs>

## 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 one required parameter, and five optional parameters. At least one optional parameter must be passed.

<Warning>
  **Please note:**

  Images that are larger than 4096 pixels in height or width will <u>not</u> be automatically resized. Instead, you'll need to [manually resize the image](https://knowledge.hubspot.com/files/automatic-image-resizing-on-hubspot-content).
</Warning>

<Tabs sync={false}>
  <Tab title="HubL">
    ```jinja theme={null}
    {{ resize_image_url("http://your.hubspot.site/hubfs/img.jpg", 0, 0, 300) }}
    ```
  </Tab>

  <Tab title="Output">
    ```
    http://your.hubspot.site/hubfs/img.jpg?length=300&name=img.jpg
    ```
  </Tab>
</Tabs>

| Parameter                   | Type         | Description                                                                                                                          |
| --------------------------- | ------------ | ------------------------------------------------------------------------------------------------------------------------------------ |
| `url` <RequiredIndicator /> | String       | URL of a HubSpot-hosted image.                                                                                                       |
| `width`                     | Integer (px) | The new image width, in pixels.                                                                                                      |
| `height`                    | Integer (px) | The new image height, in pixels.                                                                                                     |
| `length`                    | Integer (px) | 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).Default value is `false`. |
| `upsize`                    | Boolean      | Return the resized image even if it is larger than the original in bytes.Default value is `false`.                                   |

## reverse

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`](/cms/reference/hubl/filters#reverse)

<Tabs sync={false}>
  <Tab title="HubL">
    ```jinja theme={null}
    {% set numbers = [1,2,3,4] %}
    {% do numbers.reverse() %}
    {{numbers}}
    ```
  </Tab>

  <Tab title="Output">
    ```
    [4, 3, 2, 1]
    ```
  </Tab>
</Tabs>

## super

This function prints content from the parent template into a child template using the [extends](/cms/reference/hubl/overview#blocks-and-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.

<Tabs sync={false}>
  <Tab title="HubL">
    ```html theme={null}
    {% extends "custom/page/web_page_basic/parent.html" %}

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

  <Tab title="Output">
    ```
    <!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>
    ```
  </Tab>
</Tabs>

## today

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

<Tabs sync={false}>
  <Tab title="HubL">
    ```jinja theme={null}
    {{ today() }}
    {{ today("America/New_York") }}
    {{ unixtimestamp(today("America/New_York").plusDays(1)) }}
    ```
  </Tab>

  <Tab title="Output">
    ```
    2018-10-23T00:00Z 2018-10-23T00:00-04:00[America/New_York] 1540353600000
    ```
  </Tab>
</Tabs>

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

<Tabs sync={false}>
  <Tab title="HubL">
    ```jinja theme={null}
    {{ to_local_time(eastern_dt) }}
    ```
  </Tab>

  <Tab title="Output">
    ```
    2015-05-13 10:37:31
    ```
  </Tab>
</Tabs>

| Parameter | Type     | Description                              |
| --------- | -------- | ---------------------------------------- |
| `date`    | Datetime | UNIX timestamp to convert to local time. |

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

<Tabs sync={false}>
  <Tab title="HubL">
    ```jinja theme={null}
    {{ 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 -%}
    ```
  </Tab>

  <Tab title="Output">
    ```
    { 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>
    ```
  </Tab>
</Tabs>

<Warning>
  **Please note:**

  This function has a limit of 10 calls per page and per email.
</Warning>

| Parameter    | Type | Description                    |
| ------------ | ---- | ------------------------------ |
| `content_id` | Id   | The id of the page to look up. |

## truncate

The truncate function works just like the [truncate filter](/cms/reference/hubl/filters#truncate), 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.

<Warning>
  **Please note:**

  Because this function relies on the spaces between words to shorten strings, it may not work as expected for languages without spaces between characters, such as Japanese.
</Warning>

<Tabs sync={false}>
  <Tab title="HubL">
    ```jinja theme={null}
    {{ truncate("string to truncate at a certain length", 19, false, "...") }}

    {% set longString = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus sodales ultricies velit sit amet ornare." %}
    {{ truncate(longString, 40, false, "...") }}
    ```
  </Tab>

  <Tab title="Output">
    ```
    string to truncate ... Lorem ipsum dolor sit amet, consectetur ...
    ```
  </Tab>
</Tabs>

| Parameter            | Type    | Description                                                                                 |
| -------------------- | ------- | ------------------------------------------------------------------------------------------- |
| `string_to_truncate` | String  | String that will be truncated.                                                              |
| `length`             | integer | Specifies the length at which to truncate the text (includes HTML characters).              |
| `killwords`          | boolean | If true, the string will cut text at length, regardless of if it's in the middle of a word. |
| `end`                | String  | The characters that will be added to indicate where the text was truncated.                 |

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

<Tabs sync={false}>
  <Tab title="HubL">
    ```jinja theme={null}
    {{ type("Blog") }}
    {% set my_type = type("Blog") %}
    <p>{{my_type}}</p>
    ```
  </Tab>

  <Tab title="Output">
    ```
    <p>str</p>
    ```
  </Tab>
</Tabs>

## unixtimestamp

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

<Tabs sync={false}>
  <Tab title="HubL">
    ```jinja theme={null}
    {{ unixtimestamp(d) }}
    ```
  </Tab>

  <Tab title="Output">
    ```
    1565983117868
    ```
  </Tab>
</Tabs>

## update

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.

<Tabs sync={false}>
  <Tab title="HubL">
    ```jinja theme={null}
    {% set dict_var = {"authorName": "Douglas Judy", "authorTitle": "Mastermind" } %}
    {% do dict_var.update({"authorFriend": "Jake"}) %}
    {% do dict_var.update({"authorLocation": "unknown"}) %}
    {{ dict_var }}
    ```
  </Tab>

  <Tab title="Output">
    ```
    {authorName=Douglas Judy, authorTitle=Mastermind, authorFriend=Jake,
    authorLocation=unknown}
    ```
  </Tab>
</Tabs>
