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!
Hey Community! As we jump into 2025, we want to give a big shout-out to all of you wh...
By JasonH Jan 7, 2025Hey Community! As the holiday season unfolds, we want to extend heartfelt thanks to a...
By JasonH Dec 6, 2024Dropshipping, a high-growth, $226 billion-dollar industry, remains a highly dynamic bus...
By JasonH Nov 27, 2024