# IF Statements in HTML email template

**URL:** <https://community.hubspot.com/t/if-statements-in-html-email-template/81372>\
**Category:** Email Marketing Tool\
**Tags:** professional\
**Created:** [May 17, 2023, 9:54am UTC](https://community.hubspot.com/t/if-statements-in-html-email-template/81372 "2023-05-17T09:54:16Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![MSaurat](https://avatars.discourse-cdn.com/v4/letter/m/a698b9/32.png) [@MSaurat](https://community.hubspot.com/u/MSaurat)\
**Post date:** [May 17, 2023, 9:54am UTC](https://community.hubspot.com/t/if-statements-in-html-email-template/81372/1 "2023-05-17T09:54:16Z")

</div>

Hi,

Quite new to HS here. I’ve been trying to add IF statements in HTML template based on contact owner ID (but will be uself for any other contact property in the future).

Basically we have different BDM and I want to show different “get in touch with your BDM”

Code looks like this:

{% if hubspot\_owner\_id == 123456789 %}

show this image and text

{% else %}

show something else

{% endif %}

I’ve tried looking into modules as well but not sure how to use them in an HTML template.

There must be a way to make this work. We used to have a very simple ESP before and it would work. Surely hubspot can make it happen as well.

---

<div class="post-metadata">

**Author:** ![Ben\_M](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/ben_m/32/2679_2.png) [@Ben\_M](https://community.hubspot.com/u/Ben_M)\
**Post date:** [May 17, 2023, 1:45pm UTC](https://community.hubspot.com/t/if-statements-in-html-email-template/81372/2 "2023-05-17T13:45:08Z")

</div>

Is there a reason you are trying to program this into the template? You could just use smart content to look for the owner and display a different section depending on the owner. Just make sure you build some active lists in Hubspot to look at the owner and then use that membership to match it to your content section.

---

<div class="post-metadata">

**Author:** ![MSaurat](https://avatars.discourse-cdn.com/v4/letter/m/a698b9/32.png) [@MSaurat](https://community.hubspot.com/u/MSaurat)\
**Post date:** [May 17, 2023, 1:49pm UTC](https://community.hubspot.com/t/if-statements-in-html-email-template/81372/3 "2023-05-17T13:49:52Z")

</div>

Yes because this is section that is recurring and I don’t want to update this evertime I send a campaign.

But also how to create smart content that’s not on a drag and drop email?

---

<div class="post-metadata">

**Author:** ![orgmadnezz](https://avatars.discourse-cdn.com/v4/letter/o/9d8465/32.png) [@orgmadnezz](https://community.hubspot.com/u/orgmadnezz)\
**Post date:** [March 14, 2024, 5:20pm UTC](https://community.hubspot.com/t/if-statements-in-html-email-template/81372/4 "2024-03-14T17:20:31Z")

</div>

you need to turn on beta email templates

> **[Create programmable emails](https://knowledge.hubspot.com/marketing-email/create-programmable-emails)**
>
> Learn how to create programmable emails in HubSpot (BETA).

then you need to create modules

and you need to define your variables before start coding your template (see image)

 ![orgmadnezz_0-1710436798347.png](https://d2qpr2jzcazej7.cloudfront.net/original/3X/0/8/0892ec4d3e4b1d9d6ca5c32324cf5ebd9751c449.png)
