Skip to main content

UniqueStaticBlockId

Makes sure that all static blocks have a distinct ID defined.

Two static blocks are considered duplicates when they share the same id and identical arbitrary parameters. Blocks with the same id but different arbitrary parameters (such as variant) are treated as distinct.


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

In the following example, there are two static blocks using the same ID:

{% content_for "block", type: "text", id: "static-block" %}
{% content_for "block", type: "text", id: "static-block" %}

In the following example, the blocks share the same ID and identical arbitrary parameters:

{% content_for "block", type: "text", id: "header-menu", variant: "mobile" %}
{% content_for "block", type: "text", id: "header-menu", variant: "mobile" %}

In the following example, the two static blocks have distinct IDs:

{% content_for "block", type: "text", id: "static-block-1" %}
{% content_for "block", type: "text", id: "static-block-2" %}

In the following example, the blocks share the same ID but have different arbitrary parameters, making them distinct:

{% content_for "block", type: "text", id: "header-menu" %}
{% content_for "block", type: "text", id: "header-menu", variant: "mobile" %}
{% content_for "block", type: "text", id: "header-menu", variant: "navigation_bar" %}

The following example contains the default configuration for this check:

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