Shopify / dawn

Shopify's first source available reference theme, with Online Store 2.0 features and performance built-in.
Other
2.5k stars 3.36k forks source link

Error: too many templates for 'page' template type #288

Closed ak-avesta closed 2 years ago

ak-avesta commented 3 years ago

Describe the current behavior I am trying to create about 78 'page' JSON templates, but there seems to be a limit set around 50 pages. And if I try to add more than 50, I get this: image

And this is when I do it manually. But I get the same error when I try to do this with GitHub integration: image

Describe the expected behavior I assume, I should be able to create any number amount of templates, since nowhere in the shopify.dev documentation is it noted that there is a template amount limit.

Technically, this isn't directly a dawn theme issue, rather an Online Store 2.0 problem. I've already contacted Shopify Plus support but got nothing so far, that's why I'm also reporting it here.

PaulNewton commented 3 years ago

A higher level limitation to keep in mind is ,unless it's changed , themes have max size of 20MB(api)~50MB(client admin) . So the max size allowed for JSON-templates must be considered or have some sort of tradeoff for exteme usage keeping in mind a reserved amount for every other part of a themes-files or it's assets(images,pdfs).

Now with settings for rich text, liquid-type, html, or text and long inputs such as base64 images, svg, third party embeds, etc that combined with how fast the new designer lets users create alternate templates some limits still have to be considered before letting a merchant being able to hit the ceiling of max theme size with unlimited templates.

EXTREME example an max of ~512kb max per JSON-template ,not sure of a max size atm , for around 75 templates would leave very little room for every other part of a theme (~12mb of 50mb client size). 256kb ~ 150 templates 128kb ~ 300 templates etc

ak-avesta commented 3 years ago

Hi @PaulNewton, thanks for your response.

I had no idea that there was a max size limit of 20 MB for themes. But I just checked the size of our modified prestige theme, and it's only 8.6 MB so far with 82 JSON templates, so are you sure that is what's causing the error?

Considering at the moment all our JSON templates are the same file with different names, they are each 8.0 KB per template.

ak-avesta commented 3 years ago

Just an update, I just received email from Shopify Support, and they're basically confirming that there is in fact a hard limit on JSON templates per type? (in this case, pages), which is 50 templates. Sadly, this doesn't solve our issue and also kinda makes JSON templates basically useless in the sense that they were advertised, as being a modular alternative to liquid templates.

Thank you for your patience on this, I've chatted in with our technical team and confirmed that the number of pages in Theme Editor dropdown = 50. The platform is functioning as expected in this case, it’s just a hard limit we enforce. it’s not something in our scope of support. Since this is important to you and your workflow, I can certainly submit this feedback regarding this to our developers to consider adding this in our developer documentations in a future update. While I cannot guarantee that this will be added in on future versions of Shopify in any timeline, we do always appreciate the feedback of our merchants to help strengthen the Shopify platform. Please let us know if you have any further questions or concerns. Nikoo | Plus Support Specialist

Hopefully this will change in the future..

Also, it would be nice if this was documented somewhere on the documentation 😕

PaulNewton commented 3 years ago

and it's only 8.6 MB so far with 82 JSON templates, so are you sure that is what's causing the error?

@ak-avesta sorry for the confusion I was mentioning a known limit for understanding why there are other limits. I was not stating a direct root cause, there are still other considerations shopify has to handle.

Also, it would be nice if this was documented somewhere on the documentation 😕 Well really they should just be forward that this is more like a live beta lots of edges and early adopters will get cut.

there is in fact a hard limit on JSON templates per type? (in this case, pages), which is 50 templates. Sadly, this doesn't solve our issue and also kinda makes JSON templates basically useless

Could you elaborate on your use case for why you need so many sections everywhere templates? Are you not able to distill somethings into more configurable sections/blocks/settings/snippets to lower the amount you need? Have you tried anything like applying the custom-liquid-type-section to insert dynamic liquid for each page JSON template increasing it's capability?

ak-avesta commented 3 years ago

@PaulNewton I am aware, that you meant that as a general limitation, I was just mentioning that, so you are aware that that's not the issue at hand.

Could you elaborate on your use case for why you need so many sections everywhere templates?

Well, at least in our case, we do a lot of marketing where we create a new landing page for a campaign and for the most part the page layout is the same, just different content like let's say images and text, meaning we can just use the same sections for all the pages, but that's not really possible with liquid templates as far am aware. Next best thing is JSON templates and using different values for each section.

Are you not able to distill somethings into more configurable sections/blocks/settings/snippets to lower the amount you need?

The idea was to use JSON templates since it's much simpler than creating liquid template + section template for each page since they need to have a unique section ID for them to be stored in settings.json.

Have you tried anything like applying the custom-liquid-type-section to insert dynamic liquid for each page JSON template increasing it's capability?

No, we haven't, Could you elaborate on that?

gregjotau commented 2 years ago

https://help.shopify.com/en/manual/online-store/themes/os20/theme-structure/templates You can have a maximum of 50 templates per resource type, for example, 50 product templates or 50 page templates.

Also interested in knowing more about how to create customized landing pages with json templates and maybe some liquid to get the desired dynamic content.

ak-avesta commented 2 years ago

https://help.shopify.com/en/manual/online-store/themes/os20/theme-structure/templates You can have a maximum of 50 templates per resource type, for example, 50 product templates or 50 page templates.

Also interested in knowing more about how to create customized landing pages with json templates and maybe some liquid to get the desired dynamic content.

Nice, they finally added it to the documentation. Would be nice if it was mentioned on shopify.dev too

gregjotau commented 2 years ago

@ak-avesta I guess this can be closed?

For collection templates one can use metafields in many cases instead of "duplicating templates for small changes":

https://github.com/gregjotau/dawn-famme/commit/70f24298c22c3bbb9bf876732b2bdf61df99fc6a

ak-avesta commented 2 years ago

@ak-avesta I guess this can be closed?

For collection templates one can use metafields in many cases instead of "duplicating templates for small changes":

gregjotau/dawn-famme@70f2429

That works if you work the same layout, not when you change or add new elements to it. Although, if you work with liquid templates, you could check if a Metafield exists and if it does render it, but that's more of a workaround than solution.

Other than that, yes, I will close this issue since Shopify has somewhat addressed the issue by increasing the limit to 1000 templates. I wish there was no limit, but this works for now.

https://shopify.dev/changelog/json-templates-now-have-limit-of-1000-per-theme

PaulNewton commented 2 years ago

@ak-avesta

No, we haven't, Could you elaborate on that?

Custom html, or custom liquid sections|blocks https://shopify.dev/themes/architecture/settings/input-settings#html https://shopify.dev/themes/architecture/settings/input-settings#liquid An example being whether to show a product vendor or the product vendor as a link for some product types or specific vendors or other custom business logic that could otherwise end up being several different templates when a vendor-block's visibility is on/off in tandem with it's combinatorics among other settings and business rules for a template settings 🤮 .

Then there's also leveraging the section rendering api to get specific content through the frontend. https://shopify.dev/api/section-rendering

An example of the two features working together is whether based on a tags, product.type, template.suffix, etc a hook element such as for an app <div id="app-newsletter"></div> or a custom data element <div data-product-recommendations></div> is rendered. Or rendered with different data <div data-product-recommendations data-product-tags="{{product.tags|join:','}}"></div>. Then if it is rendered other sections like product recommendations are pulled in on the frontend using the section rendering api with different parameters. For secondary content this can cut down alternate templates usage when there are slightly different settings justifying making new templates. Kinda convention over configuration as long as a programmatic approach can be taken to code the architecture like that instead of trying to do everything through a visual designer which simply was not built to scale up like that.

PaulNewton commented 2 years ago

@gregjotau

For collection templates one can use metafields in many cases instead of "duplicating templates for small changes":

I think the main thing to avoid is: Is a section or block is removeable.. will an end user(merchant|staff) be able to replicate what you've setup directly in the JSON.

To avoid hardcoding 🤔 a metafields namespace and key there's also using custom-liquid blocks/sections, or dynamic sources(depending on the content type attribute availability).

https://help.shopify.com/en/manual/online-store/themes/theme-structure/sections-and-blocks#using-metafields-and-dynamic-sources

@ak-avesta

.. Shopify has somewhat addressed the issue by increasing the limit to 1000 templates. I wish there was no limit, but this works for now.

https://shopify.dev/changelog/json-templates-now-have-limit-of-1000-per-theme

Yes it is more flexible at least in letting us choose where are quota gets used. But it's a bit sneaky moving it to per theme not per template type. Before it was 50 per resource type = ~13 template-types * 50 = 650 Effectively less than doubling the limit ,not a big change over all. Still an impediment for large stores that will require being careful with modularity in theme architecture, or have to consider moving to some bigger CMS until shopify updates theirs supposedly and whatever affect that will have on theme limits like this.