Discuss and resolve questions on Liquid, JavaScript, themes, sales channels, and site speed enhancements.
Hi there,
For SEO purposes, I'd like to change product titles depending on what collection it's being shown on.
For example, we sell chargers, for the keyword "iPhone charger", on the collection iPhone chargers, I'd like the product title to include the word iPhone. However, for the keyword "Samsung charger", on the collection Samsung chargers, I'd like the product title to include the word Samsung.
Same for cables etc.
One of our competitors has achieved great organic rankings doing this for brands and different models (it's in Dutch):
https://www.gsmoplader.nl/opladers/apple/iphone-12/
https://www.gsmoplader.nl/opladers/apple/iphone-13/
Hi,
Need to add conditional logic At collection.liquid
Code example
{% assign collection_handle = collection.handle %}
{% if collection_handle == 'iphone-chargers' %}
{% assign new_title = product.title | prepend: 'iPhone ' %}
{% elsif collection_handle == 'samsung-chargers' %}
{% assign new_title = product.title | prepend: 'Samsung ' %}
{% else %}
{% assign new_title = product.title %}
{% endif %}
<h2>{{ new_title }}</h2>
Please share your store url
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