Search code examples
shopifyliquidshopify-template

Shopify: Add additional sections to a specific product page


I'm trying to add additional sections to my Shopify product pages. I've already been successful adding the sections, but would now like to show the sections on only specific products pages. Until now they are showing on all product pages.
Can someone help me with that? This is the code I've used:

{% if product.title == "The Ocean Mat" %}
    {% section "index-columns" %}
{% endif %}

But it doesn't work.

Thanks a lot!

Best, Lasse


Solution

  • use contains when check for string since your title might not match exactly

    {% if product.title contains "The Ocean Mat" %}
        do something
    {% endif %}
    

    instead of product.title, use product.type; it is much easier to control. The customer does not see it and it can be control from the product page.

    {% if product.type contains "mat" %}
        do something
    {% endif %}