What's your biggest current challenge? Have your say in Community Polls along the right column.

How to create a dynamic link with variables in Shopify block schema?

How to create a dynamic link with variables in Shopify block schema?

greg11223
Shopify Partner
3 0 0

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?

Reply 1 (1)

Moeed
Shopify Partner
6348 1721 2079

Hey @greg11223 

 

Shopify's schema JSON section doesn’t support Liquid templating directly, which is why your variables like {{ shop.domain }} and {{ block.id }} aren’t being parsed. Liquid variables can only be used in the main Liquid template outside the JSON schema.

 

Here's how you can structure it:

{% assign app_link = "https://admin.shopify.com/store/" | append: shop.domain | append: "/apps/myapp/" | append: block.id %}

<div>
  <h2>Customize App Configuration</h2>
  <p><a href="{{ app_link }}" target="_blank">Go to App Configuration Page</a></p>
</div>

{% schema %}
{
    "name": "block",
    "target": "body",
    "settings": [
        {
          "type": "header",
          "content": "Customize the App Configuration from your Shopify Admin."
        }
    ]
}
{% endschema %}

This approach will create a clickable, dynamic link that takes users to the app configuration page while displaying the section header within the schema.

 

Best Regards,

Moeed

- Need a Shopify Specialist? Chat on WhatsApp

- Get a quick Shopify quote – Click here!

- Boost Your Sales with Affiliate Marketing - UpPromote: Affiliate & Referral