> ## Documentation Index
> Fetch the complete documentation index at: https://engineering.trewknowledge.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Creating a Block Plugin

All our blocks go into plugins. You can either have one block per plugin or one plugin that contains multiple blocks.
When deciding to add a block to an existing plugin or as a standalone plugin, consider if this plugin is supposed to be available and shared with other sites in the network with the exact same functionality or if it is an opt-in feature that may only be used on a few sites.

<Warning>
  Please do not style your blocks with the provided scss files. Use TailwindCSS classes directly in your markup instead.
</Warning>

## Creating a new block plugin

In your terminal, navigate to the `wp-content/plugins` directory and run the following command:

**Static blocks:**

```bash theme={null}
npx @wordpress/create-block my-block
```

**or for dynamic blocks**

```bash theme={null}
npx @wordpress/create-block my-block --variant=dynamic
```

<Tip>
  For all options you can visit the [official documentation](https://developer.wordpress.org/block-editor/reference-guides/packages/packages-create-block/#options)
</Tip>

## Creating a new block in an existing plugin

When creating a block plugin for the first time the block files will be inside the `src/` directory. When adding additional blocks, you should move these files into their own folder. Example:

move `src/*` to `/src/my-first-block/`

In your terminal, navigate to the src directory inside of your blocks plugin and run the following command:

```bash theme={null}
npx @wordpress/create-block --no-plugin my-second-block
```

This will create an additional folder in your `src/` folder with the new block files. You then need to open your plugin `.php` file and make adjustments.

**Before:**

```php theme={null}
register_block_type( __DIR__ . '/build' );
```

**After:**

```php theme={null}
register_block_type( __DIR__ . '/build/my-first-block' );
register_block_type( __DIR__ . '/build/my-second-block' );
```
