How to insert custom HTML in theme via custom Shopify App?

shopify

Solution

Using the Asset API you can add or update assets, for example your custom HTML. An asset belongs to a theme, so probably you also need the Theme API, which gives you access to the installed theme(s) and it's role(s). You shouldn't update existing assets which don't belong to your own App.

If you only want to add a JavaScript to the store, you might want to use a ScriptTag.

A third option is to use application proxies. Application proxies will forward web requests to your application. Your application returns custom HTML (or Liquid), which will be returned to the visitor. This way you extend the store with for example an image gallery.

Keep in mind `assets` won't be removed when the store uninstalls your App. Also after uninstall you don't have access to your `assets` anymore. A `ScriptTag` will be removed when the store uninstalls your App. For an application proxy you can implement an access mechanism yourself and deny access when the store uninstalls your App.

Problem

I want to include custom HTML in shopify theme whenever user install / enable my APP in their store. Can anyone suggest me that how to do that ?

Original source