Referencing code snippet on new product page template

I’m using the Refresh theme. On my shop I have a default product page. I added a code snippet for a back button and referenced this in the main theme layout file. Everything worked. Then I created a second product page template so I could customize further. This new template isn’t showing the back button.

I assumed that the new template would also use the main theme layout so the button would just appear. Should a new page template automatically use the main theme layout? If so, shouldn’t it automatically know about the same code snippets?

I don’t see any sort of liquid file for the new template, only a json file. So, if I need to add the snippet again or reference it somewhere, I’m not sure where. Basically, how do I get the new product page template to reference the same code snippet and display the same back button as the default page?

Thanks!!!

Hi @ADHD

You will need to add code to main-product.liquid file to make it be applied to all new product templates that you create.

Hello @ADHD
Thank you for submitting your query to the Shopify community. I’d be happy to assist you. Could you please provide the store URL and password (if it’s password-protected) so I can review and get back to you with an update?

Yes, all templates use the same layout (unless it’s specifically selected with layout command).

It’s hard to tell what the problem can be without seeing the site or code you’ve used.

Could be that you’re using selector or conditions in your code which no longer apply in your new template.

Thank you! Here is the site URL: https://shop.seattleurbanfarmco.com/

If your code in layouts/theme.liquid is like this:


or

```php

Then it should be visible on all pages and all templates on your site.

However, if you have a condition in your snippet like (which you seem to have, because /collections does not have back button)

```php
{% if template == "product" or template == "collection" %}

then obviously this is the reason why it does not show on new product template.

The code should be

{% if template.name == "product" or template.name == "collection" %}

So would be nice to see your snippet code too.