What is approach for updating/replacing existing section using App?

I’m building an app that should update content of the registration page (/account/register).

As far as I understood ‘App blocks’ and ‘App embeds’ can’t be used for this. Documentation says that App could “inject code directly into your theme’s code to add functionality”, but I didn’t manage to find any documentation or tutorial for that case. All I found is related to ‘App blocks’. In my case, I don’t want to add a block I want to change or replace an existing section.

Any approach suggestions or links to related tutorials are highly appreciated :smiley:

You need to uses the assets api to modify theme assets directly.

Backend

Before replacing ALWAYS either be making a backup of the theme with some way for merchant restoration, or duplicate the section with OLD|BACKUP etc in the name; and or or make your own section name i.e. main-section-myappname.liquid and update references in other files.

When adding a new asset make sure either in the name or top of file to note where the file came from.

https://shopify.dev/api/admin-rest/2022-10/resources/asset

Frontend

For client-side replace of a section use the section rendering api.

https://shopify.dev/api/section-rendering

1 Like

Thank you a lot for such a detailed and helpful answer!

1 Like