HubL Reference

Table of contents
Close

HubL supported variables

HubSpot templates can use a host of predefined variables that can be used to render useful website and email elements. This page is a reference listing of those variables. You can learn more about creating your own variables in a HubL template or module, here.

While most of the variables listed on this page are optional, there are a few variables that are required, in order to create emails and pages from your templates.

Required email template variables

In order to be CAN-SPAM compliant, all emails sent through HubSpot require certain company and opt-out information; therefore, HubSpot email templates required certain variables. There are additional optional email variables listed further down this page.

Variable
Type
Description
{{ site_settings.company_city }}
string
Prints the company city (set in Content Settings > Email > Footer Information).
{{ site_settings.company_name }}
string
Prints the company name (set in Content Settings > Email > Footer Information).
{{ site_settings.company_state }}
string
Prints the company state (set in Content Settings > Email > Footer Information).
{{ site_settings.company_street_address_1 }}
string
Prints the company address (set in Content Settings > Email > Footer Information).
{{ unsubscribe_link }}
string
Prints the URL of the page that allows recipients to manage subscription preferences or unsubscribe from email communications. This variable should be used in the href attribute of an <a>.

Required page template variables

In order to publish a coded file as an editable page or blog template, the following variables must be included. If you want to publish an HTML file without these variables, to use within another template, you can do so unchecking the option "Make this template available for new content." 

{{ standard_footer_includes }}
string
Renders the HubSpot tracking code, public_common.js, and any other code included in your Footer HTML in Content Settings or the options of a particular page. This tag should be inserted directly before the closing body tag.
{{ standard_header_includes }}
string
Adds jQuery, public_common.css, layout.css, any attached stylesheets, a meta viewport tag, Google analytics tracking code, other page meta information, and code added to the head tag at the domain/template/page level. This variable should be added to the <head> of HTML templates.

Variables available in all templates

There are many predefined HubSpot variables that can be used in email, page, or blog templates. Below is a list of these variables. 

General variables

The following variables will render on any type of content.

Variable
Type
Description
{{ account }}
dict
This variable is a dictionary that stores company personalization properties for a known contact. Properties can be accessed from this dict, by adding a period and the property name. For example, account.name would print the company name of a contact.
{{ company_domain }}
string
Prints the company domain from Content Settings > Page Publishing.
{{ contact }}
dict
This variable is a dictionary that stores contact personalization properties for a known contact. Properties can be accessed from this dict, by adding a period and the property name. For example, contact.firstname would print the first name of a contact.
{{ content }}
dict
This variable is a dictionary that stores various properties pertaining to a specific piece of content such as an email, a page, or a post.
{{ content.absolute_url }}
string
Prints the full URL of a page, post, or web page version of an email.
{{ content.archived }}
boolean
This variable evaluates to True, if the page or email was marked as archived by the user.
{{ content.author_email }}
string
The email address of the content creator.
{{ content.author_name }}
string
The first and last name of the content creator
{{ content.author_username }}
string
The HubSpot username of the content creator
{{ content.campaign }}
string
The GUID for the marketing campaign that this page or email is associated with. This unique ID can be found in the URL of a particular campaign in the Campaign's tool.
{{ content.campaign_name }}
string
The name of the marketing campaign that this page, this post, or this email is associated with
{{ content.created }}
datetime
A python datetime object for when the content was originally created, in UTC time. This variable can be formatted with the datetime filter.
{{ content.meta_description }}
string
Prints the meta description of a page.
{{ content.name }}
string
The name of a post, email, or page. For pages and emails this will print the internal content name, while for posts this will print the post title. For blog posts, this is the post title that displays. For other types of content, this is generally an internal name. This variable includes a wrapper so that it is editable via the UI, when included in blog posts. If you want to print the content name without a wrapper, use page_meta.name.
{{ content.publish_date }}
datetime
A python datetime object representing when the content was published, in UTC time. This variable can be formatted with the datetime filter.
{{ content.publish_date_localized }}
datetime
A python datetime object representing when the content was published, in the local time as defined in the HubSpot Report settings. This variable is also subject to the language and  date format settings in Content Settings > Blog.
{{ content.template_path }}
string
The Design Manager file path to your template (ie custom/page/web_page_basic/my_template.html)
{{ content.updated }}
datetime
A python datetime object for when the user last updated the content, in UTC time. This variable can be formatted with the datetime filter.
{{ content_id }}
string
Prints the unique ID for a page, post, or email. This ID can be found in the URL of the editor. You can use this variable as an alias for content.id.
{{ eastern_dt }}
datetime
A python datetime object of the current time in the U.S. eastern time zone
{{ favicon_link }}
string
Prints the source URL of the favicon. This image is set in Content Settings > Page Publishing.
{{ hub_id }}
string
The portal ID of your HubSpot account.
{{ hubspot_analytics_tracking_code }}
string
Includes the analytics tracking code. This tag is not necessary, because standard_footer_includes, already renders the tracking code.
{{ local_dt }}
datetime
A python datetime object of the current time in the time zone defined in your Report Settings
{{ local_time_zone }}
string
The time zone, as configured in your HubSpot Report Settings
{{ page_meta.canonical_url }}
string
The official URL that this page should be accessed at. Usually does not include any query string parameters. Use this for the rel='canonical' tag. HubSpot automatically canonicalizes URLs
{{ page_meta.html_title }}
string
The title of the page. This variable should be used in the <title> tag of HTML templates.
{{ page_meta.name }}
string
An alias for content.name
{{ portal_id }}
string
An alias for hub_id
{{ request_contact }}
dict
A dictionary containing data about the requested contact.
{{ site_settings }}
dict
The site_settings dict contains various settings from such as colors and fonts (see below).
{{ year }}
string
Prints the current year.

Color and font settings

There are several basic color and font controls in Content Settings > Colors and Fonts that can be printed to templates and files. Please note that if you use these variables in CSS files, you will need to republish/recompile your CSS file when you change one of the settings, in order for the new color to apply.

Variable
Type
Description
{{ site_settings.background_color }}
string
Background color setting from Content Settings > Colors and Fonts. Prints a HEX value.
{{ site_settings.body_border_color }}
string
Body border color setting from Content Settings > Colors and Fonts. Prints a HEX value.
{{ site_settings.body_border_color_choice }}
enumeration
The variable is used in HubSpot's default email templates to determine whether or not a border should be added. The setting is controlled in Content Settings > Colors and Fonts. It prints values: BORDER_AUTOMATIC, BORDER_MANUAL, BORDER_NONE
{{ site_settings.body_color }}
string
Body color setting from Content Settings > Colors and Fonts. Prints a HEX value.
{{ site_settings.color_picker_favorite_1 }}
string
Favorite color 1 setting from Content Settings > Colors and Fonts. Prints a HEX value. Replace 1 with 2-6 to modify the tag for other favorite color settings.
{{ site_settings.primary_accent_color }}
string
Primary accent color setting from Content Settings > Colors and Fonts. Prints a HEX value.
{{ site_settings.primary_font }}
enumeration
Primary font setting from Content Settings > Colors and Fonts
{{ site_settings.primary_font_color }}
string
Primary font color setting from Content Settings > Colors and Fonts. Prints a HEX value.
{{ site_settings.primary_font_size }}
string
Primary font size setting from Content Settings > Colors and Fonts. Includes "px".
{{ site_settings.secondary_accent_color }}
string
Secondary font color setting from Content Settings > Colors and Fonts. Prints a HEX value.
{{ site_settings.secondary_font }}
enumeration
Secondary font setting from Content Settings > Colors and Fonts
{{ site_settings.secondary_font_color }}
string
Secondary font color setting from Content Settings > Colors and Fonts. Prints a HEX value.
{{ site_settings.secondary_font_size }}
string
Primary font size setting from Content Settings > Colors and Fonts. Includes "px".

Email variables

The following variables are specifically for HTML email templates or HubL template modules in email layouts.

Variable
Type
Description
{{ background_color }}
string
Email-template only alias for the color and font setting described above.
{{ body_border_color }}
string
Email-template only alias for the color and font setting described above.
{{ body_border_color_choice }}
string
Email-template only alias for the color and font setting described above.
{{ body_color }}
string
Email-template only alias for the color and font setting described above.
{{ content.create_page }}
boolean
This variable is True, if there is a web page version of the email.
{{ content.email_body }}
The main body of the email. This variable renders a rich text module.
{{ content.emailbody_plaintext }}
string
The optional override of the plain text email body
{{ content.from_name }}
string
The from name of the email sender
{{ content.reply_to }}
string
The reply to address for the email
{{ content.subject }}
string
The subject of the email
{{ email_body_border_css }}
string
Email-template only alias for the color and font setting described above.
{{ email_body_padding }}
string
The email body padding setting. This setting is located in Content Settings > Email.
{{ email_body_width }}
string
The email body width setting. This setting is located in Content Settings > Email.
{{ primary_accent_color }}
string
Email-template only alias for the color and font setting described above.
{{ primary_font }}
enumeration
Email-template only alias for the color and font setting described above.
{{ primary_font_color }}
string
Email-template only alias for the color and font setting described above.
{{ primary_font_size }}
string
Email-template only alias for the color and font setting described above.
{{ primary_font_size_num }}
string
Prints the font size number from Content Settings > Colors and Fonts. Excludes "px".
{{ secondary_accent_color }}
string
Email-template only alias for the color and font setting described above.
{{ secondary_font }}
enumeration
Email-template only alias for the color and font setting described above.
{{ secondary_font_color }}
string
Email-template only alias for the color and font setting described above.
{{ secondary_font_size_num }}
string
Prints the font size number from Content Settings > Colors and Fonts. Excludes "px".
{{ site_settings.company_street_address_2 }}
string
Prints the address line 2 from Content Settings > Email > Footer Information.
{{ site_settings.office_location_name }}
string
Prints the office location name from Content Settings > Email > Footer Information.
{{ subscription_confirmation_url }}
string
Prints the URL of the subscription preferences confirmation page. This URL is dynamically generated on send.
{{ subscription_name }}
string
Prints the name of the Email Type specified for that email.
{{ unsubscribe_anchor }}
string
Generates an anchor tag with the work "unsubscribe" linked to your unsubscribe page.
{{ unsubscribe_link_all }}
string
Renders a link to unsubscribe from all email communications, as opposed to a link to manage subscription preferences.
{{ unsubscribe_section }}
string
Renders an unsubscribe section that includes an unsubscribe link, as well as help text.
{{ view_as_page_section }}
string
Generates a link with help text that leads to a webpage version of an email.
{{ view_as_page_url }}
string
Generates a link that leads to a webpage version of an email.

Website pages variables

The following variables are available for site pages, landing pages, system pages, and blogs. 

{{ builtin_body_classes }}
string
This variable dynamicaly prints helpful classes that help differentiate the markup of content created with that template (ie type of content, content name, etc). This makes styling different types of content or particular pages easier. This variable should be used in the class attribute of the body tag on coded templates.

HTTP request variables

The following variables print information about the HTTP page request.

Variable
Type
Description
{{ request.cookies }}
dict
A dictionary of cookie names mapped to cookie values
{{ request.domain }}
string
The domain used to access this page
{{ request.full_url }}
string
The URL used to access this page, with the query string
{{ request.path }}
string
The path component of the URL
{{ request.path_and_query }}
string
The path and query component of the URL
{{ request.query }}
string
The query string component of the URL
{{ request.query_dict }}
dict
The query string coverted into a name->value dictionary
{{ request.referrer }}
string
The HTTP referrer, the url of the page that linked to the current page
{{ request.remote_ip }}
string
The IP address of the visitor
{{ request.scheme }}
string
The protocol of the request (either http or https)
{{ request.search_engine }}
string
The search engine used to find this page, if applicable. Ex: google, aol, live, yahoo, images.google, etc
{{ request.search_keyword }}
string
The keyword phrase used to find this page, if applicable

Blog variables

The following variables are available for blog templates. Some variables are only available for post listings, while other's may only be available for blog posts.

Variable
Type
Description
{{ blog_author }}
string
This variable contains blog author information for blog author listing pages. It can be used to create conditional logic to render markup for blog author listings. It also contains the following properties:

blog_author.avatar, blog_author.bio, blog_author.display_name, blog_author.email, blog_author.facebook, blog_author.google_plus, blog_author.has_social_profiles, blog_author.linkedin, blog_author.twitter, and blog_author.website
{{ content.blog_post_author }}
string
This variable contains individual blog post author information for a given post. It contains the following properties:

content.blog_post_author.avatar, content.blog_post_author.bio, content.blog_post_author.display_name, content.blog_post_author.email, content.blog_post_author.facebook, content.blog_post_author.google_plus, content.blog_post_author.has_social_profiles, content.blog_post_author.linkedin, content.blog_post_author.slug, content.blog_post_author.twitter, and content.blog_post_author.website
{{ content.blog }}
string
An alias for group.
{{ content.comment_list }}
string
A list of the comments for the current blog post
{{ current_page_num }}
integer
The integer index of the current page of blog posts in the view. 
{{ content.featured_image }}
string
The source url of the featured image, selected when the blog was published
{{ content.featured_image_alt_text }}
string
The alt text of the featured image
{{ last_page_num }}
integer
The integer index of the last page of blog posts in the view
{{ next_page_num }}
integer
The integer index of the next page of blog posts in the view
{{ content.next_post_featured_image }}
string
The url of the featured image of the next blog post, if one exists.
{{ content.next_post_name }}
string
The name of the next blog post, if one exists.
{{ content.next_post_slug }}
string
The url slug of the next blog post, if one exists.
{{ content.post_body }}
string
The body of the blog post
{{ content.post_list_content }}
string
The body blog post content, modified for the listing page. The final output is affected by summary settings in Content Settings > Blog. If featured images are enabled in settings, this varible will remove any images above the read more separator automatically.
{{ content.post_list_summary_featured_image }}
string
The featured image for listing layouts. This variable is affected by the settings in Content Settings > Blog.
{{ content.post_summary }}
string
The blog post summary. This content is determined by the read more separator in the blog editor.
{{ content.previous_post_featured_image }}
string
The url of the featured image of the previous blog post, if one exists
{{ content.previous_post_name }}
string
The name of the previous blog post, if one exists
{{ content.previous_post_slug }}
string
The url slug of the previous blog post, if one exists.
{{ content.publish_date_localized }}
string
A string representing the date/time when the blog post was published, formatted according to the blog's language and date formatting settings.
{{ content.simple_list_page }}
boolean
A boolean to indicate whether the requested page is the 'all posts' page containing links to all blog posts
{{ content.topic_list }}
string
The list of topic objects associated with the blog post. The following properties can be accessed from each topic object: name and slug
{{ contents }}
string
Contents is a sequence of your blog posts that is iterated through using a for loop.
{{ contents.total_count }}
integer
Total number of posts in a listing (regular, topics, authors, etc.)
{{ contents.total_page_count }}
integer
Total number of pages of posts based on your number of posts per page.
{{ contents_topics }}
string
Get a list of all blog topics in the contents sequence of posts.
{{ group }}
dict
The dictionary containing variables that pertain to an entire blog.
{{ group.absolute_url }}
string
The base URL of a blog
{{ group.allow_comments }}
boolean
Evaluates to True, if comments are allowed
{{ group.description }}
string
The description of the blog from Content Settings > Blog. Used for the meta description on certain listing pages.
{{ group.header }}
string
The header of the blog
{{ group.html_title }}
string
The title of this blog as it should appear in the <title> tag
{{ group.id }}
string
The unique ID of a blog. This ID can be found in the URL of the Blog Dashboard for a particular blog.
{{ group.public_title }}
string
The title of this blog as it should appear at the top of rendered pages
{{ group.slug }}
string
The path to this blog
{{ topic }}
dict
The topic variable can be used to render markup for a topic listing. It also contains the properties: topic.name and topic.slug.