0
votes

I'm trying to create a liquid if statement to only run if product page == ?

  {% if template contains 'products' and page.url == '/products/sky-dweller' %}
    <script>window.location.href = '/';</script>
{% endif %}
1
Describe the problem, thank youLeo
If you're on a product page, you won't have a page variable - that's only for the pages created at [your-store]/admin/pages. Instead, you could try checking if product.handle == 'sky-dweller'Dave B

1 Answers

1
votes

Based on the documentation here you can check if the template name is product.

{% if template.name == 'product' %}
  This will only appear on product pages.
{% endif %}