Shopify themes, liquid, logos, and UX
I have a custom product page template on my shopify store that's different than my default product page template and I would like to know where I can put custom code for this page. I can find the .json file for this custom template but not the .liquid file. When I add custom code to the main-product.liquid it adds it to the custom template page so I'm assuming custom templates for product pages still pulls from the main-product.liquid.
In this case is there a way to do something like {% if template.name == 'product.custom-product-page' %} <!-- code to run if the current page is a product page with the custom-product-page template --> {% endif %}
Basically any way to do custom code for a specific template page even if it means going through the main-product.liquid because it seems as if templates pull from this and don't create their own .liquid only a .json
If you need more information to answer my question please ask thank you in advanced !
Solved! Go to the solution
This is an accepted solution.
Please use 'template.suffix'
{% if template.suffix == 'custom-neon-quote-product' %}
{% endif %}
Hopefully it will help you. If yes then Please don't forget hit Like and Mark it as solution!
This is Richard from PageFly - Shopify Page Builder App
You are correct, in this case simply put the condition code in the theme.liquid file, for example:
{% if template.name == 'product.custom-product-page' %}
<style></style>
{%endif%}
So this style only triggers on that product page
Hope this can help you solve the issue
Best regards,
Richard | PageFly
Please let me know if it works by giving it a Like or marking it as a solution!
➜ Optimize your Shopify store with PageFly Page Builder (Free plan available)
All features are available from Free plan. Live Chat Support is available 24/7.
Hey thanks for the reply,
I understand the code but why would I put it in the theme.liquid page if I want it to show up on product.liquid page but only render for specific templates ? Can you clarify this. Also is there a way to get the exact naming covention for a specific product template I created ?
Yes, your idea is correct. You can use template.name to determine which page you are on.
Can you take a screenshot to describe your requirements? So that I can assist you.
Where would I enter template.name code ? I tried entering it into main-product.liquid but doesn't seem to work. Also if my template is named custom-neon-quote-product would i be typing {% if template.name == 'product.custom-neon-quote-product' %} or {% if template.name == 'custom-neon-quote-product' %} or some other naming convention ?
This is an accepted solution.
Please use 'template.suffix'
{% if template.suffix == 'custom-neon-quote-product' %}
{% endif %}
Hopefully it will help you. If yes then Please don't forget hit Like and Mark it as solution!
Thank you so much this worked ! For anyone else wondering I placed it in the main-product.liquid and just referenced the template that I wanted to add code for.
You are welcome. I'm glad to hear that the solution worked well for you.
If you require any more help, please don't hesitate to reach out.
By investing 30 minutes of your time, you can unlock the potential for increased sales,...
By Jacqui Sep 11, 2024We appreciate the diverse ways you participate in and engage with the Shopify Communi...
By JasonH Sep 9, 2024Thanks to everyone who participated in our AMA with 2H Media: Marketing Your Shopify St...
By Jacqui Sep 6, 2024