I’m trying to make this work: I currently have three app blocks that are set to target the “section” in their liquid settings. What I want to do is create a new liquid file with a target of “body” instead. This way, when I access the editor, I’ll see only the app embed, which I can activate or deactivate. Once enabled, the blocks will appear in the “sections” part (not directly in the theme itself but in the available section on the screen).
Hi @ozgar
To make the app embed work the way you described, here’s how you can achieve this step by step:
1. Understand App Embeds and Blocks
App embeds are typically used to inject scripts or functionalities globally on your Shopify store, whereas app blocks are more specific and usually tied to sections within the editor. By targeting the body, you can manage your app embed from the Shopify theme editor and enable or disable it globally.
2. Create a New App Embed Targeting the Body
You need to create a new liquid file for the app embed that targets body instead of section. Here’s what you can do:
- Navigate to your app’s Liquid files in the Assets folder of your Shopify theme.
- Create a new app embed configuration file. You can do this by creating a new file in the app’s settings, typically found in the config folder.
- Use the following example code in your new app embed configuration:
{% schema %}
{
“name”: “App Embed for Body”,
“target”: “body”,
“settings”: [
{
“type”: “checkbox”,
“id”: “enable_app_blocks”,
“label”: “Enable App Blocks”,
“default”: true
}
]
}
{% endschema %}
{% if settings.enable_app_blocks %}
{% endif %}
This creates an app embed that can be toggled on or off from the editor.
3. Modify the App Blocks to Work with the Embed
If you already have app blocks targeting the section, adjust their behavior so that when the app embed is enabled, the blocks are available in the “sections” part of the editor.
For each block, ensure you set the appropriate schema and Liquid settings. Here’s an example block configuration:
{% schema %}
{
“name”: “App Block”,
“target”: “section”,
“settings”: [
{
“type”: “text”,
“id”: “custom_text”,
“label”: “Custom Text”,
“default”: “Hello, World!”
}
]
}
{% endschema %}
{{ block.settings.custom_text }}
4. Test in the Theme Editor1. Open the Online Store > Themes section in Shopify admin.
- Click Customize next to your current theme.
- Look for the “App Embeds” menu (usually found in the left-hand panel). Activate the new embed you just created.
- Once activated, your app blocks should be available for selection under the “sections” part in the editor.
5. Optional: Debug and Refine
If something isn’t showing as expected:
- Check the theme.liquid file to ensure the app embed is being injected correctly.
- Use the browser developer tools to inspect if your scripts or blocks are being loaded.
- Ensure the settings and schema in your app embed and blocks are correct.
If you’d like, I can provide a more tailored example or help troubleshoot further. Just let me know! ![]()
If you need any other assistance, feel free to reply and I will try my best to respond.
Best regards,
Daisy
