Build your first Blueprint
Let's build an elementary Blueprint that
- Creates a new WordPress site
- Sets the site title to "My first Blueprint"
- Installs the Adventurer theme
- Installs the Hello Dolly plugin from the WordPress plugin directory
- Installs a custom plugin
- Changes the site content
1. Create a new WordPress site
Let's start by creating a blueprint.json
file with the following contents:
{}
It may seem like nothing is happening, but this Blueprint already spins up a WordPress site with the latest major version.
If you use an IDE, like VS Code or PHPStorm, you can use the Blueprint JSON Schema for an autocompleted Blueprint development experience. Add the following line at the top of your blueprint.json
file:
{
"$schema": "https://playground.wordpress.net/blueprint-schema.json"
}
Here's what it looks like in VS Code:
2. Set the site title to "My first Blueprint"
Blueprints consist of a series of steps that define how to build a WordPress site. Before you write the first step, declare an empty list of steps:
{
"$schema": "https://playground.wordpress.net/blueprint-schema.json",
"steps": []
}
This Blueprint isn't very exciting—it creates the same default site as the empty Blueprint above. Let's do something about it!
WordPress stores the site title in the blogname
option. Add your first step and set that option to "My first Blueprint":
{
"$schema": "https://playground.wordpress.net/blueprint-schema.json",
"steps": [
{
"step": "setSiteOptions",
"options": {
"blogname": "My first Blueprint"
}
}
]
}
The setSiteOptions
step specifies the site options in the WordPress database. The options
object contains the key-value pairs to set. In this case, you changed the value of the blogname
key to "My first Blueprint". You can read more about all available steps in the Blueprint Steps API Reference.