# Hubl and if statement has content

**URL:** <https://community.hubspot.com/t/hubl-and-if-statement-has-content/130693>\
**Category:** CMS Development\
**Tags:** marketing-email\
**Created:** [April 28, 2025, 3:23pm UTC](https://community.hubspot.com/t/hubl-and-if-statement-has-content/130693 "2025-04-28T15:23:51Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![MMcRae](https://avatars.discourse-cdn.com/v4/letter/m/ce7236/32.png) [@MMcRae](https://community.hubspot.com/u/MMcRae)\
**Post date:** [April 28, 2025, 3:23pm UTC](https://community.hubspot.com/t/hubl-and-if-statement-has-content/130693/1 "2025-04-28T15:23:51Z")

</div>

Hi, all!

Coming from a Freemarker environment and cannot find this simple query. We use variations of it in multiple scenarios.  
The Freemarker uses the condition "

**has\_content**

" -- any content in the specified field.

[#if Profile.FirstName?has\_content]${Profile.FirstName},[#else]Hi![/#if]

If the field does NOT have content, then remove spacing and display a different message.

---

<div class="post-metadata">

**Author:** ![Jaycee\_Lewis](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/jaycee_lewis/32/61352_2.png) [@Jaycee\_Lewis](https://community.hubspot.com/u/Jaycee_Lewis)\
**Post date:** [April 29, 2025, 3:20pm UTC](https://community.hubspot.com/t/hubl-and-if-statement-has-content/130693/2 "2025-04-29T15:20:08Z")

</div>

Hey, @MMcRae 👋 Welcome to our community! Have you already looked into the [**Create programmable emails**](https://knowledge.hubspot.com/marketing-email/create-programmable-emails) option? This enables a lot more HubL personalization options for emails.

Best,

Jaycee

---

<div class="post-metadata">

**Author:** ![MMcRae](https://avatars.discourse-cdn.com/v4/letter/m/ce7236/32.png) [@MMcRae](https://community.hubspot.com/u/MMcRae)\
**Post date:** [April 29, 2025, 3:44pm UTC](https://community.hubspot.com/t/hubl-and-if-statement-has-content/130693/3 "2025-04-29T15:44:17Z")

</div>

Thanks for the info, but from my historic usage of other ESPs, this is a simple query.  
It shouldn’t require programmable templates unless that’s HubSpot’s only way to handle a basic if/else statement looking for content in a property.

---

<div class="post-metadata">

**Author:** ![nickdeckerdevs1](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/nickdeckerdevs1/32/5198_2.png) [@nickdeckerdevs1](https://community.hubspot.com/u/nickdeckerdevs1)\
**Post date:** [May 5, 2025, 2:02pm UTC](https://community.hubspot.com/t/hubl-and-if-statement-has-content/130693/4 "2025-05-05T14:02:21Z")

</div>

I believe you received the response you did because you were giving an example of “code” and you are in the developer section of this site. If you would have asked this question in more of the marketing focused area, they likely would have given you a differnet answer.  
You can do this when editing the pages -- they are “personalization tokens” and you can inject them wherever you’d like.  
Example [screenshot](https://share.cleanshot.com/83fxxryz) | [docs](https://knowledge.hubspot.com/marketing-email/personalize-your-content)  
Each property can be set up with a default value -- that way they show the default value instead of a blank item.

> **[Use personalization tokens](https://knowledge.hubspot.com/marketing-email/use-personalization-tokens)**
>
> Learn how to use personalization tokens in HubSpot to display the custom property value for a specific contact.

---

<div class="post-metadata">

**Author:** ![GRajput](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/grajput/32/102020_2.png) [@GRajput](https://community.hubspot.com/u/GRajput)\
**Post date:** [April 29, 2025, 3:45pm UTC](https://community.hubspot.com/t/hubl-and-if-statement-has-content/130693/5 "2025-04-29T15:45:10Z")

</div>

Hi @MMcRae

In HubSpot, you can use HubL, its Jinja-based templating language, for conditional content rendering. While HubL lacks a direct equivalent to Freemarker, it supports if statements to check for the existence of non-empty values.  
Here’s how to write your example in HubL:

```lia-code-sample
{% if contact.firstname %}
 {{ contact.firstname }},
{% else %}
 Hi!
{% endif %}

```

I hope this will help you out. Please mark it as **Solution Accepted and upvote** to help another Community member.  
Thanks!

---

<div class="post-metadata">

**Author:** ![MMcRae](https://avatars.discourse-cdn.com/v4/letter/m/ce7236/32.png) [@MMcRae](https://community.hubspot.com/u/MMcRae)\
**Post date:** [May 8, 2025, 4:01pm UTC](https://community.hubspot.com/t/hubl-and-if-statement-has-content/130693/6 "2025-05-08T16:01:31Z")

</div>

This did not work within a non-programmable email. Thank you for trying.

---

<div class="post-metadata">

**Author:** ![MMcRae](https://avatars.discourse-cdn.com/v4/letter/m/ce7236/32.png) [@MMcRae](https://community.hubspot.com/u/MMcRae)\
**Post date:** [May 8, 2025, 4:11pm UTC](https://community.hubspot.com/t/hubl-and-if-statement-has-content/130693/7 "2025-05-08T16:11:11Z")

</div>

Thank you for responding, Nick and others:  
I chose the “developer” side as it is related to Hubl and Hubspot is different from SalesForce Marketing Cloud which uses Ampscript or another ESP which uses Freemarker.  
The personalization token code within the “marketing” section of Hubspot does not resolve this issue.  
It that you have to use programmable templates as noted from Jaycee’s comment and from what testing I’ve done.  
In other ESPs, this task is at the email-build level. I’ve tried finding documentation from others who have migrated from SalesForce Marketing Cloud, but have come up empty. Would appreciate any help if anyone knows of any.
