Skip to main content
NextLevel
Contributor IV
Contributor IV
April 18, 2024
Solved

Shopify product description shows with HTML tags

  • April 18, 2024
  • 4 replies
  • 462 views

Hi guys, 

I am setting up a back in stock flow and was wondering how I could add the product description. 

I am using the following code, which pulls the description dynamically from the catalogue.

{% catalog event.VariantId integration='shopify' %}{{ catalog_item.description }}{% endcatalog %}

However, the description includes HTML tags (see Screenshot). What do I have to do, to remove them?

 

Thanks

Hendrik

    This topic has been closed for replies.
    Best answer by In the Inbox

    Hi @NextLevel 

    Thank you for posting your question in the community. 

    While I have not specifically run into this challenge I wanted to chime in and see if I could help point you in the right direction to get the HTML tags removed. 

    Klaviyo uses django web framework. When I create custom code to format shopify data I reference the Django documentation frequently. 

    https://docs.djangoproject.com/en/5.0/ref/templates/builtins/

    In your case, there is a condition called Striptags which is supposed to remove HTML tags from a block of text. 

    I am not an expert in Django, but play around with it, I think if you add the following to your code, it could do the trick.

    {{ value|striptags }}

    {% catalog event.VariantId integration='shopify' %}{{ catalog_item.description|striptags }}{% endcatalog %}

     

    Please let me know if that does the trick!

    @In the Inbox 

    4 replies

    In the Inbox
    Partner - Platinum
    2025 Champion
    April 18, 2024

    Hi @NextLevel 

    Thank you for posting your question in the community. 

    While I have not specifically run into this challenge I wanted to chime in and see if I could help point you in the right direction to get the HTML tags removed. 

    Klaviyo uses django web framework. When I create custom code to format shopify data I reference the Django documentation frequently. 

    https://docs.djangoproject.com/en/5.0/ref/templates/builtins/

    In your case, there is a condition called Striptags which is supposed to remove HTML tags from a block of text. 

    I am not an expert in Django, but play around with it, I think if you add the following to your code, it could do the trick.

    {{ value|striptags }}

    {% catalog event.VariantId integration='shopify' %}{{ catalog_item.description|striptags }}{% endcatalog %}

     

    Please let me know if that does the trick!

    @In the Inbox 

    Bryan Richey // Klaviyo Champion & Email Strategist at In the Inbox // https://intheinbox.co/
    NextLevel
    Contributor IV
    NextLevelAuthor
    Contributor IV
    April 19, 2024

    @In the Inbox thanks for your answer.

    It works, but then there are no blank spaces between sentences and no paragraphs 😃

    Any idea how to solve this?

     

    Hendrik
    Contributor II
    May 20, 2024

    We dont whant to strip the html but to insert the html.

     

    Please help!

    In the Inbox
    Partner - Platinum
    2025 Champion
    May 20, 2024

    Hi @Enelclavo 

    Thank you for the follow up. While the initial goal of remove the HTML tags for the content did work, I am sorry to see it’s completely removed the formatting from the email. I’d be curious if any of the other Champions might have an idea here to help @Bobi N. @Omar @retention? 

    @In the Inbox 

    Bryan Richey // Klaviyo Champion & Email Strategist at In the Inbox // https://intheinbox.co/