HTML anchor tag inside Liquid {% let %} variable results in "welcomeText of email variant is malformed" Product | Community
Skip to main content
Level 2
July 21, 2026
Question

HTML anchor tag inside Liquid {% let %} variable results in "welcomeText of email variant is malformed" Product

  • July 21, 2026
  • 2 replies
  • 30 views

Issue Summary

We are using a common footer fragment across multiple email templates. The footer receives a variable (welcomeText) from the email template and renders it using triple braces ({{{welcomeText}}}).

When the welcomeText variable contains HTML tags such as <br>, <sup>, <b>, or <p>, the email validates successfully.

However, when the variable contains an HTML anchor tag (<a href="...">...</a>), the email validation fails with the following error:

welcomeText of email variant is malformed

 

 

Steps to Reproduce

  1. Define a variable in the email template:
{% let welcomeText = "<a href='https://google.com'>Google</a>" %}
  1. Render the variable in the email template or a content fragment using:
{{{welcomeText}}}
  1. Save or validate the email.

Actual Result

The email validation fails with the following error:

welcomeText of email variant is malformed

2 replies

Level 3
July 21, 2026

Hi ​@shivangisingh 

This happens because AJO's validator parses <a> tags out of the compiled HTML specifically to register them for click-tracking. It expects anchors to be present as static markup so it can attach tracking parameters. When the whole <a href="...">...</a> tag is built at runtime from a {% let %} variable, the validator can't reformat it as a proper trackable link, which is why it flags the variant as malformed (other tags like <br>/<b>/<p> don't need this special handling, so they pass fine).

Suggested Workaround: don't build the whole tag as a variable — only pass the dynamic pieces (URL, label text) as plain variables, and write the <a> tag itself directly as static markup in the fragment:

{% let welcomeUrl = "https://google.com" %}
{% let welcomeLabel = "Google" %}

<a href="{{welcomeUrl}}">{{welcomeLabel}}</a>

This validates because the anchor tag is real markup in the source, not assembled from a string during the time of render. 

Hope this helps!

Regards,

Ganesh Kumar C

SatheeskannaK
Community Advisor
Community Advisor
July 21, 2026

Hi ​@shivangisingh This is one of the places where you can utilize the AI assistant in email templates to resolve issues. You can prompt to ask what you want, and it will generate expressions based on your input. Additionally, you will have the option to obtain explanations for the generated functions. Here is the sample,

 

 

 

Thanks, Sathees