---
title: ValidBlockTarget
description: >-
  A validation that identifies when a block is using an invalid target in a
  theme.
source_url:
  html: >-
    https://shopify.dev/docs/storefronts/themes/tools/theme-check/checks/valid-block-target
  md: >-
    https://shopify.dev/docs/storefronts/themes/tools/theme-check/checks/valid-block-target.md
---

# ValidBlockTarget

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

***

## Validation on block file existence

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

### ✗ Fail

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

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

### ✓ Pass

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

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

***

## Validation on nested blocks

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

### ✗ Fail

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

```liquid
{% 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:

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

### ✓ Pass

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

```liquid
{% 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:

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

***

## Options

The following example contains the default configuration for this check:

```yaml
ValidBlockTarget:
  enabled: true
  severity: error
```

| Parameter | Description |
| - | - |
| `enabled` | Whether this check is enabled. |
| `severity` | The [severity](https://shopify.dev/docs/storefronts/themes/tools/theme-check/configuration#check-severity) of the check. |

***

## Disabling this check

Disabling this check isn't recommended.

***
