call product title variable in description

Topic summary

A user wants to dynamically insert product titles into product descriptions for 200 items with similar descriptions, attempting to use {{ product.title }} as a variable placeholder. However, Shopify’s product description field treats content as static HTML and doesn’t parse Liquid variables by default.

Solution provided:

  • Modify the main-product.liquid file where product descriptions render
  • Use a custom placeholder like [[title]] in the product description field instead of {{ product.title }}
  • Update the liquid code to: {{ product.description | replace: '[[title]]', product.title }}
  • This dynamically replaces the placeholder with the actual product title when the page renders

Technical note: The initial attempt using {{ product.title }} directly in the replace filter caused a Liquid syntax error due to nested curly braces. The workaround uses square brackets as a safe placeholder that won’t conflict with Liquid syntax.

Screenshots were provided showing the implementation in both the product description field and the rendered output.

Summarized with AI on November 1. AI used: claude-sonnet-4-5-20250929.

I’ve looked through the docs to try and find the answer, but it is unclear.

I am uploading a new product list of 200 products, many have the same description except the name of the item (the shopify title). I’d like to call that title as a variable in the description using the {{ product.title }} tag, but it does not work.

I see references to the main-product.liquid code, but it’s unclear what I am supposed to do there.

The product description HTML I’d like to use is:

{{ product.title }} is a fig tree variety from AJ's Collection. We will learn more about this variety during the growing season of 2025.

This renders the following on the webpage:

{{ product.title }} is a fig tree variety from AJ’s Collection. We will learn more about this variety during the growing season of 2025.

Any help would be appreciated!

The issue you’re experiencing is because Shopify doesn’t parse Liquid variables ({{ product.title }}) within the product description field by default. The product description field is treated as static HTML, and Liquid variables are not interpreted there.

To achieve your goal, you need to modify the main-product.liquid (or equivalent) file where the product description is rendered. Here’s how to resolve this:

{{ product.description | replace: '{{ product.title }}', product.title }}

This code replaces the placeholder {{ product.title }} in the description with the actual product title dynamically.

1 Like

Hi @Asad-Mahmood thank you for replying. When modifying the main-product.liquid, I should

replace this:

{%- when ‘description’ -%}
{%- if product.description != blank -%}

{{ product.description }}

with:

{%- when ‘description’ -%}
{%- if product.description != blank -%}

*{{ product.description | replace: '{{ product.title }}', product.title }}*

correct?

when I do that, I get an error:

  • Liquid syntax error (line 197): Unexpected character ’ in “{{ product.description | replace: '{{ product.title }}”

Hello,

did you figure out what you need to do?

I would also like to use this for my shop.

Thank you!

In your product description use this

[[title]]

and update code to this

{{ product.description | replace: '[[title]]', product.title }}

In your product description use this

[[title]]

and update code to this

{{ product.description | replace: '[[title]]', product.title }}