Skip to main content

StylesheetOncePerFile

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

Each section, block, or snippet file should keep its CSS in a single stylesheet tag. To learn how Shopify bundles this CSS, refer to JavaScript and stylesheet tags.


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

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

{% stylesheet %}
.hero {
display: grid;
}
{% endstylesheet %}

{% stylesheet %}
.hero__title {
margin-block: 0;
}
{% endstylesheet %}

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

{% stylesheet %}
.hero {
display: grid;
}

.hero__title {
margin-block: 0;
}
{% endstylesheet %}

The following example contains the default configuration for this check:

StylesheetOncePerFile:
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 StylesheetOncePerFile %}
{% stylesheet %}
.hero {
display: grid;
}
{% endstylesheet %}

{% stylesheet %}
.hero__title {
margin-block: 0;
}
{% endstylesheet %}
{% # theme-check-enable StylesheetOncePerFile %}

Was this page helpful?