New templates must be in published theme to use them?

Highlighted
Shopify Partner
10 0 2

So I wanted to add a new page template to my theme... Following the instructions, (in a copy, not the published theme, of course, so that I don't risk messing things up), I created a new template file. Great. After making the new template file in the templates folder, I click on "online store" in my admin, click on "pages" and lastly, click "add page". Put in a title and a bit of content and then go to choose the template suffix. My newly created template isn't there. Double check the templates folder. Yes, it's there. Go back to the "add page" page, still can't choose it. After scratching my head for a while, I discover this line (https://help.shopify.com/themes/customization/store/create-alternate-templates#sectioned-themes):

"Only templates present in your published theme will be available in the Theme templates section."

Maybe I'm missing something obvious but I don't understand how this is supposed to work. The whole point is to work on a copy, is it not? Not only that, but I'm using Theme Kit, which is uploading any changed file up to my copy.

So just to get this straight... In order to add a new (usable) template, you have to create it in the templates folder of the PUBLISHED theme in order to be able to access it from the copy. OK, fine. BUT! When I'm finally finished tweaking my copy and want THAT one to be the published version, what happens then? All of a sudden, the now-published theme (previously a copy) doesn't contain the template file I created! I guess the page isn't going to render properly, is it? (Or at all?)

So is the "correct" (in quotes because it seems more like a workaround than a well-thought out procedure) way to do things to create a new template in the templates folder of the active theme first, then copy/paste it to the "copy of theme" that you're working on? And I assume you need to do that every time you make any changes to it, correct?

This can't be right...

2 Likes
Highlighted
Shopify Partner
1365 24 238

Unfortunatley it is like that.

Even if you create an alternative template on your theme copy, if that template does not exist on your live theme, it will not appear in the options.

Had the same issue and it was a bit frustrating.

https://sections.design tips, tricks & Shopify sections
0 Likes
Highlighted
Shopify Partner
10 0 2

OMG, it gets even crazier than I originally realized. The only way I can figure out to add a new page template and use it is on the active theme! This seriously cannot be right...

In the active theme, this is what I did:

  1. In "Templates", I created a new page template.(page.mypage.liquid)
  2. In the admin, under "pages", I created a new page
  3. In theme.liquid, I added a css reference  {{ 'mypage.css' | asset_url | stylesheet_tag }}
  4. In "Assets", I created a new file (mypage.css.liquid) and just made the heading blue
  5. I viewed my new page and it worked. The heading was blue.

I then made a duplicate of the active theme and deleted the css file and css reference in theme.liquid of the active theme. I left intact the page template and the page itself. Then tried to view the page but the heading wasn't blue anymore.

Is there really no way to do all of this in a duplicate so that we don't risk screwing up the currently published theme? This is absolutley total insanity. Doesn't it make the entire point of working on duplicates moo (as Joey would say)? If you add any custome page templates, the only way to see them is in the active theme?

 

0 Likes
Highlighted
Shopify Expert
2684 67 815

No, 

it's not like this. You have to have a template with the same name in the active theme, but it may be empty. It's only needed to tell Shopify that there exists alternate template with this name, so it can populate the "Templates" drop-down on the object page in admin.

It is only needed to assign an alternate template to an obect (say, product). 

Note that you can always use ?view=alt-template-name at the end of your URL to see the alternate template (even when previewing unpublished theme and there is no such template in active theme).

You say "Then tried to view the page but the heading wasn't blue anymore." -- have you tried it via Preview link of your development theme?

Obviously, in your active theme it would not be blue, because these CSS rules and not there anymore...

 

Want to hire me to tweak a theme? Mail me at tairli@yahoo.com!
My post solved your problem? Like it!
I am away till Feb-15.
2 Likes
Highlighted
Shopify Partner
10 0 2

Thank you! That was the key. I was clicking on "view" in the page editor after creating it. I can view it by clicking "preview" on my duplicate theme and then simply appending "pages/newpagename" to the end of the root URL. I knew there had to be a way. lol Upvoted.

0 Likes
Highlighted
New Member
7 0 0

Can this be done if the 'Live' theme is a different theme to the one unpublished?

0 Likes
Highlighted
Shopify Partner
2 0 0

Thank you Tim!

2 years later and this just saved my butt! 

 

Could not for the life of me figure out why my new template was not populating dropdown.

 

Appreciate the save!

0 Likes
Highlighted
New Member
5 0 0

Thank you Tim. This was what I was confused about.

0 Likes