Skip to main content
Block templates define a default initial state for an editor session. They specify which blocks should appear by default and with what configuration.

What are Block Templates?

Templates allow you to:
  • Set default blocks: Pre-populate the editor with blocks
  • Configure initial state: Set default attributes and content
  • Lock structures: Prevent users from modifying the layout
  • Guide content creation: Provide structure for specific content types

Template Scope

Templates can be applied at two levels:
  1. Post Type Templates: Define default blocks for entire post types
  2. InnerBlocks Templates: Define default nested blocks within a container block

Post Type Templates

Define default blocks that appear when creating a new post of a specific type.

Basic Post Type Template

When users create a new post, it will contain these three blocks.

Template with Attributes

Custom Post Type with Template

Template Locking

Control how users can modify the template structure.

Lock Options

Available lock types:
  • contentOnly - Only allows editing block content. Hides blocks without content from list view.
  • all - Prevents all operations (insert, move, delete)
  • insert - Prevents inserting/removing blocks (allows reordering)
  • false or not set - No locking (default)

Example with Locking

Nested Templates

Templates can include blocks with inner blocks:

InnerBlocks Templates

Define default nested blocks for container blocks.

Basic InnerBlocks Template

InnerBlocks Template with Locking

Individual Block Locking

Lock individual blocks within a template:

JavaScript

PHP

Lock properties:
  • remove - Lock/unlock removal of the block
  • move - Lock/unlock moving the block

Template API Format

Templates are defined as arrays of block configurations:

Block Attributes in Templates

Find available attributes in block.json files:

Example: Heading Block

You can use attributes and supports in templates:

Complete Examples

Blog Post Template

Product Template

FAQ Template

Template Inheritance

InnerBlocks inherit locking from their parent:
  1. If InnerBlocks templateLock is not set, parent’s lock is used
  2. If block is top-level, post type’s template_lock is used
  3. Explicit templateLock always takes precedence

Finding Block Attributes

To find available attributes for templates:

In Gutenberg Plugin

Check packages/block-library/src/[block-name]/block.json

In WordPress Core

Check wp-includes/blocks/[block-name]/block.json

Template vs Pattern vs Variation

Use templates for structured post types and container blocks. Use patterns for reusable layout combinations. Use variations for different configurations of a single block.

Best Practices

  1. Provide placeholders: Help users understand what content goes where
  2. Use appropriate locking: Balance structure with flexibility
  3. Test the workflow: Ensure the template improves the editing experience
  4. Document required fields: Make it clear what users must fill in
  5. Consider accessibility: Use semantic HTML and proper heading hierarchy
  6. Keep it simple: Don’t over-structure the content
  7. Allow some flexibility: Total locking can be frustrating

Common Use Cases

Landing Page Template

Recipe Template