Skip to main content

ValidBlockTarget

Ensures that block types reference valid files, and that nested blocks are declared in the root-level of the schema.


Anchor to Validation on block file existenceValidation on block file existence

This section describes the validations to ensure that block types reference valid files.

In the following example, there's no corresponding invalid.liquid file in the blocks directory for the theme:

{% schema %}
{
"name": "Invalid Section",
"blocks": [
{
"type": "invalid"
}
]
}
{% endschema %}

In the following example, text.liquid exists in the blocks directory:

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

Anchor to Validation on nested blocksValidation on nested blocks

This section describes the validations that occur on blocks nested within presets.

In this example, neither the nested block nested-block nor @theme are declared in the root-level blocks array:

{% schema %}
{
"name": "Section with Nested Blocks",
"blocks": [
{
"type": "text"
}
],
"presets": [
{
"name": "Default",
"blocks": [
{
"type": "nested-block"
}
]
}
]
}
{% endschema %}

In this example, _private_block is a private block which hasn't been explicitly declared in the root-level blocks array:

{% schema %}
{
"name": "Section with Nested Blocks",
"blocks": [
{
"type": "@theme"
}
],
"presets": [
{
"name": "Default",
"blocks": [
{
"type": "_private_block"
}
]
}
]
}
{% endschema %}

In this example, @theme is declared in the root-level blocks array:

{% schema %}
{
"name": "Section with Nested Blocks",
"blocks": [
{
"type": "@theme"
}
],
"presets": [
{
"name": "Default",
"blocks": [
{
"type": "nested-block"
}
]
}
]
}
{% endschema %}

In this example, the private block _private_block is declared in the root-level blocks array:

{% schema %}
{
"name": "Section with Nested Blocks",
"blocks": [
{
"type": "_private_block"
}
],
"presets": [
{
"name": "Default",
"blocks": [
{
"type": "_private_block"
}
]
}
]
}
{% endschema %}

The following example contains the default configuration for this check:

ValidBlockTarget:
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?