A space to discuss online store customization, theme development, and Liquid templating.
Store 2.0 theme has header.liquid with block that has a type @app.
"blocks": [
{
"type": "@app"
},
Also, if that exists, it is rendered via this:
{%- for block in app_blocks -%}
{%- render block -%}
In the theme customizer, when I examine the header, there is the control to add a block. But that never looks for an App extension? Why? All I see is this:
I have an App set to with enabled_on targets and groups set to ["*"] thinking that would allow the extension to be dropped on the header, but it does not work that way.
Can anyone point out why not? Thanks for any info.
Solved! Go to the solution
This is an accepted solution.
For our case, the problem was that the section is statically rendered which according to the documentation here: App blocks (shopify.dev) is not supported by app blocks.
You can tell the difference by checking your code ( likely theme.liquid ) , and you may find something like the following
{% section 'header' %}
That is a statically rendered section, you need section rendered using JSON templates. You can find an example in the latest Dawn theme, you will find this instead
{% sections 'header-group' %}
notice the extra "s" in the tag , the header-group is the name of a json file under `sections/header-group.json'
One solution is to create a similar file to header-group.json , that renders one section: the header section. This way, the app block will work
We are having the same issue in the Symmetry theme among others, were you able to resolve this? only difference is the way the for loop works on other themes like older "Dawn" is
{% for block in section.blocks %}
{% case block.type %}
{% when '@app' %}
{% render block %}
{% endcase %}
{% endfor %}
This is an accepted solution.
For our case, the problem was that the section is statically rendered which according to the documentation here: App blocks (shopify.dev) is not supported by app blocks.
You can tell the difference by checking your code ( likely theme.liquid ) , and you may find something like the following
{% section 'header' %}
That is a statically rendered section, you need section rendered using JSON templates. You can find an example in the latest Dawn theme, you will find this instead
{% sections 'header-group' %}
notice the extra "s" in the tag , the header-group is the name of a json file under `sections/header-group.json'
One solution is to create a similar file to header-group.json , that renders one section: the header section. This way, the app block will work
That is very good information! I have recently had success dropping my extension into the header, but I did not check as to why it was working all of a sudden, but I am betting if I dive in and look for this little aspect of it, header rendering as a JSON section, it'll jump out at me!
Thanks for this explanation!