Search code examples
htmlsmartyshopifyliquid

Shopify / Liquid find "-" and remove and content before


I have some content, for example: Product Type - Colour Name (this changes but always the same format, I want to just display the "Colour Name"

It is outputted with:

{{ product.title }}

What I need to do is use the available string filters and find and remove "-" and the content before it so it just displays the part after the hyphen "-"

Does anyone have any ideas?


Solution

  • You can use the split filter.

    {% assign words = product.title | split: ' - ' %}
    {{ words[1] }}