Theme app extension CSS/JavaScript not working correctly on custom templates

Theme app extension CSS/JavaScript not working correctly on custom templates

samporiikkila
Shopify Partner
7 0 2

I started working on an app using the new theme app extensions and noticed some weird behaviour with different templates.

The documentation at https://shopify.dev/apps/online-store/theme-app-extensions/extensions-framework#:~:text=No-,template... states the following:

"The possible values are productcollectionarticle, and blog."

However, using other templates such as index or page seems to work and Shopify CLI also gives this error if an incorrect template is included: 

Invalid tag 'schema': templates[0]: must be one of 404, cart, checkpoint, gift_card, list-collections, password, queue, search, customers/account, customers/activate_account, customers/addresses, customers/login, customers/order, customers/register, customers/reset_password, article, blog, collection, page, product, index

The real problem however, is that when I create a new custom template, no CSS or JavaScript seems to be loading at all even though the extension is presented in the add section menu. For example, I have a theme app extension block that is only available on the product template. All the CSS and JavaScript I have defined in the schema are loading correctly, but when I add the block on a custom product template, these are not loaded at all.

This only seems to be happening with blocks that have the templates attribute set. So If I exclude this attribute and allow the block to be placed on any template, the CSS and JavaScript are loading as normal.

Is there a way to get theme app extensions working on specific custom templates currently, or is this a bug?

 

Replies 3 (3)

samporiikkila
Shopify Partner
7 0 2

I got this working correctly by loading the styles and JS with link and script tags. Only loading them through the schema doesn't work correctly.

patrickb
Shopify Partner
55 0 13

I just encountered this as well. This is a pretty big bug that completely breaks the app-block mechanics on custom templates.


Any Shopify employee available to let us know if this is known and being fixed?

Recipe Kit - Easy, beautiful & SEO friendly recipe cards on your Shopify blog posts - https://apps.shopify.com/recipe-kit
Wait.li - Product Waiting Lists - https://apps.shopify.com/product-waiting-lists
Better Blog Comments - threaded comments, email notifications, improved spam protection, and more - https://apps.shopify.com/blogcomments
axis80
Shopify Partner
23 1 9

I haven't run into this specifically, but I'm seeing some other weird behavior with theme app extensions, that contradicts documentation.  I won't get into the details here because I don't want to derail your thread on the specific issue you're experiencing.  Suffice it to say that app blocks still seem sort of buggy and not ready for prime time 😞