Shopify themes, liquid, logos, and UX
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:
<p>{{ product.title }} is a fig tree variety from AJ's Collection. We will learn more about this variety during the growing season of 2025.</p>
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.
Hi @Asad-Mahmood thank you for replying. When modifying the main-product.liquid, I should
replace this:
{%- when 'description' -%}
{%- if product.description != blank -%}
<div class="product__description rte quick-add-hidden" {{ block.shopify_attributes }}>
{{ product.description }}
</div>
with:
{%- when 'description' -%}
{%- if product.description != blank -%}
<div class="product__description rte quick-add-hidden" {{ block.shopify_attributes }}>
{{ product.description | replace: '{{ product.title }}', product.title }}
</div>
correct?
when I do that, I get an error:
Hello,
did you figure out what you need to do?
I would also like to use this for my shop.
Thank you!
Find Global Growth Opportunities For Your Business with Shopify AcademyLearn how to exp...
By Shopify Feb 4, 2025Hey Community, happy February! Looking back to January, we kicked off the year with 8....
By JasonH Feb 3, 2025Expand into selling wholesale with Shopify Academy’s learning path, B2B on Shopify: Lau...
By Shopify Jan 28, 2025