Determine if product uses specific template

New Member
3 0 0


I currently have 2 templates:

- product.liquid
- product.test.liquid

On the homepage i want to add an if-statement so a piece of text only appears when a product uses this 'product.test.liquid'

I tried 

{% if == 'product.test' %}

but this seems to only work when i am actually on that product, and not when i am on the homepage itself.

How can i 'see' which template a product uses?

Thank you in advance

Replies 7 (7)
Shopify Staff
205 1 64

Hey, Marshall.

Leon here from Shopify Support.

I'm unsure about the effectiveness of an if-statement to determine which template is being used for a product, however there's an easier way to do accomplish the same task. You could add the text you'd like displayed for those products right to the product.test.liquid template using code so that this text will only be displayed when that template is used for a product.

If ther is another reason you're looking to use an if-statement, other than to determine which template is being used please let me know so we can explore further.

Have a great day,


Leon | Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit the Shopify Help Center or the Shopify Blog

New Member
3 0 0

Hi Leon,

Thank you for your reply!
Yes, your suggestion would be one way to have it 'shown', but i also want to do it the other way.. how to hide certain text/elements when i am just showing the products in a carousel on the homepage?

Which is why i tried

{% if == 'product.test' %}

but that does not work unless you are actually within that template.


Shopify Expert
10438 169 2081

You only need the template_suffix property.

{% assign testPage = %}
{% if testPage.template_suffix == "test" %}


I jump on these forums to help and share some insights. Not looking to be hired, and not looking for work.
Don't hand out staff invites or give admin password to forum members unless absolutely needed. In most cases the help you need can be handled without that.
★ ★
New Member
3 0 0

Thank you so much Jason!
Exactly what i was looking for!


New Member
3 0 0

Good evening,

I found this thread and its doing 90% of what i am looking for...

So what i want to do is test if the Product template ("product.custom-artwork.liquid") is being loaded to either display or hide a upload option.

<!-- ==========> Insert Custom Field - Upload Image File <========== -->

{% if template_suffix == 'product.custom-artwork' %}
<p class="line-item-property\_\_field"> <label for="custom\_photo">Upload your Artwork Photo (JPG or PNG) <br/> Ideally this would be a 2000px x 2000px file </label> <input required id="custom\_photo" type="file" name="properties\[Photo\]"> </p>
{% else %}
<input type="hidden" name="id" value="{{ }}" />
{% endif %}

<!-- ==========> Insert Custom Field - Upload Image File <========== -->


New Member
3 0 0


I am trying to detect products with template "comingsoon" in product-card-grid.liquid file. How can I alter this code for that? Kindly help. Thanks in advance

15 1 2

Did the latest post before yours with the code not help? I did something similar using that technique.