The collection of schemas used in WordPress, including the theme.json
, block.json
and font-collection.json
schemas.
JSON schemas are used by code editors to offer tooltips, autocomplete, and validation.
Many editors recognize the $schema
property in JSON files.
Update your block.json
to include:
{
"$schema": "https://schemas.wp.org/trunk/block.json"
}
Or in your theme.json
:
{
"$schema": "https://schemas.wp.org/trunk/theme.json"
}
Or in your font-collection.json
:
{
"$schema": "https://schemas.wp.org/trunk/font-collection.json"
}
For a specific version of the schema, replace trunk
with wp/X.X
:
{
"$schema": "https://schemas.wp.org/wp/5.8/block.json"
}
Visual Studio Code and PhpStorm are two popular editors that work out of the box. However, some editors require a plugin installed, and not all editors recognize the $schema
property. Check your editor's documentation for details. Additionally, SchemaStore.org and JSON Schema have lists of editors known to have support if your current editor is unsupported.
You may wish to update one of the schemas to conform to a new change in the structure. In order to do this you'll want to be able to see how your changes impact how your IDE displays schema information.
To allow this you will need to:
- update your theme's
theme.json
to reference the local version of the schema file:
{
"$schema": "file://{{FULL_FILE_PATH}}/schemas/json/theme.json"
}
- update your block's
block.json
to include:
{
"$schema": "file://{{FULL_FILE_PATH}}/schemas/json/block.json"
}
- update your font collections's
font-collection.json
to include:
{
"$schema": "file://{{FULL_FILE_PATH}}/schemas/json/font-collection.json"
}
Be sure to replace {{FULL_FILE_PATH}}
with the full local path to your Gutenberg repo.
With this in place you should now be able to edit either schemas/json/theme .json
, schemas/json/block.json
or schemas/json/font-collection.json
in order to see changes reflected in theme.json
, block.json
or font-collection.json
in your IDE.