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
June brought summer energy to our community. Members jumped in with solutions, clicked ...
By JasonH Jun 5, 2025Learn how to build powerful custom workflows in Shopify Flow with expert guidance from ...
By Jacqui May 7, 2025Did You Know? May is named after Maia, the Roman goddess of growth and flourishing! ...
By JasonH May 2, 2025