Skip to main content

SchemaOncePerFile

Identifies files that contain more than one {% schema %} tag. Theme Check reports the second and later schema tags because {% schema %} can appear only once per file.

Each section or block file should define a single schema so Shopify can parse one settings definition for the file.


The following examples contain code snippets that either fail or pass this check.

In the following example, sections/product.liquid contains two {% schema %} tags:

{% schema %}
{
"name": "Product"
}
{% endschema %}

{% schema %}
{
"settings": []
}
{% endschema %}

In the following example, sections/product.liquid contains one {% schema %} tag:

{% schema %}
{
"name": "Product",
"settings": []
}
{% endschema %}

The following example contains the default configuration for this check:

SchemaOncePerFile:
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. If you can't avoid violating the rule, then you should disable the check using the comment syntax. This ensures that you intentionally disable the check for each instance.

{% # theme-check-disable SchemaOncePerFile %}
{% schema %}
{
"name": "Product"
}
{% endschema %}

{% schema %}
{
"settings": []
}
{% endschema %}
{% # theme-check-enable SchemaOncePerFile %}

Was this page helpful?