Skip to main content

JSONMissingBlock

Ensures that a JSON template file includes block types that reference valid files and are declared at the root level of their associated schema.


The following example contains code snippets that either fail or pass this check.

In the following example, the JSON template file references a block type that doesn't exist. There's no corresponding invalid-block.liquid file in the blocks directory for the theme:

templates/index.json

{
"sections": {
"custom-section": {
"type": "custom-section",
"blocks": {
"invalid-block": {
"type": "invalid-block"
}
},
"block_order": ["invalid-block"]
}
},
"order": ["custom-section"]
}

In the following example, the JSON template file references a block type that exists, but is not declared at the root level of the custom-section liquid section schema:

templates/index.json

{
"sections": {
"custom-section": {
"type": "custom-section",
"blocks": {
"text-block": {
"type": "text"
}
},
"block_order": ["text-block"]
}
},
"order": ["custom-section"]
}

sections/custom-section.liquid

{% schema %}
{
"name": "Custom Section",
"blocks": [
{
"type": "image"
}
]
}
{% endschema %}

In the following example, the JSON template file references a block type that exists, but isn't declared at the root level of the text liquid block schema:

templates/index.json

{
"sections": {
"custom-section": {
"type": "custom-section",
"blocks": {
"parent_block": {
"type": "text",
"blocks": {
"child_block": {
"type": "missing_nested"
}
}
}
},
"block_order": ["parent_block"]
}
},
"order": ["custom-section"]
}

blocks/text.liquid

{% schema %}
{
"name": "Text",
"blocks": [
{
"type": "image"
}
]
}
{% endschema %}

In the following example, the JSON template file references a block type that exists, and is declared at the root level of the custom-section liquid section schema:

templates/index.json

{
"sections": {
"custom-section": {
"type": "custom-section",
"blocks": {
"text-block": {
"type": "text"
}
},
"block_order": ["text-block"]
}
},
"order": ["custom-section"]
}

sections/custom-section.liquid

{% schema %}
{
"name": "Custom Section",
"blocks": [
{
"type": "text"
}
]
}
{% endschema %}

In the following example, the JSON template file references a block type that exists, and is declared at the root level of the text liquid block schema:

templates/index.json

{
"sections": {
"custom-section": {
"type": "custom-section",
"blocks": {
"parent_block": {
"type": "text",
"blocks": {
"child_block": {
"type": "image"
}
}
}
},
"block_order": ["parent_block"]
}
},
"order": ["custom-section"]
}

blocks/text.liquid

{% schema %}
{
"name": "Text",
"blocks": [
{
"type": "image"
}
]
}
{% endschema %}

The following example contains the default configuration for this check:

JSONMissingBlock:
enabled: true
severity: error
ParameterDescription
enabledWhether this check is enabled.
severityThe severity of the check.

Anchor to Disabling this checkDisabling this check

Disabling this check isn't recommended.


Was this page helpful?