I’m trying to create a link to the app settings within a Shopify block using schema in Liquid. I want to include dynamic variables like shop.domain and block.id in the URL.
Here’s my code:
{% schema %}
{
"name": "block",
"target": "body",
"settings": [
{
"type": "header",
"content": "Customize [App Configuration Page](https://admin.shopify.com/store/{{ shop.domain }}/apps/myapp/{{ block.id }})"
}
]
}
{% endschema %}
However, the variables {{ shop.domain }} and {{ block.id }} are not being parsed within the schema. The link displays as plain text rather than dynamically replacing these variables.
Is there a way to include dynamic variables in the link within the Shopify block schema? If not, are there any recommended workarounds for creating dynamic links in Shopify blocks?
UPDATE 1
Thanks for reply – but this button is visible at front public page …
and i see in this app – they create link to app – so shop url is dynamic variable . Hot they do it ?
2
Answers
You can not directly include dynamic variables in URLs within the Shopify schema, you can work around this limitation by using a combination of block settings and Liquid templating outside the schema.
First, define a block setting for a part of the URL:
Then,
You need to use the type liquid in the schema.
Then in the customizer you can add the liquid code into the block.
And when you get the variable into the code you need to append the block.id.
Then you get the dynamic link like below example: