Overview
The@wordpress/edit-site package provides the complete Site Editor interface for WordPress block themes. It enables you to edit templates, template parts, global styles, and site-wide design settings through a unified block-based interface.
This package is designed for WordPress core and may not be fully documented for external use. However, you can use it in your own projects with the understanding that APIs may evolve.
Three-Layer Architecture
The Site Editor follows the same three-layer architecture as the post editor:Layer Responsibilities
@wordpress/block-editor- Generic block editing canvas. Provides the foundation for any block-based editing experience.@wordpress/editor- WordPress entity management. Handles saving, revisions, and entity-specific features.@wordpress/edit-site- Complete site editor implementation. Adds template management, global styles UI, navigation between templates, and pattern management.
What the Site Editor Manages
The Site Editor provides a unified interface for managing:- Templates - Full-page templates (e.g., index, single post, archive)
- Template Parts - Reusable template components (e.g., header, footer, sidebar)
- Global Styles - Site-wide design system including colors, typography, and spacing
- Patterns - Reusable block patterns for quick content insertion
- Navigation Menus - Block-based navigation structures
- Page Management - Browse and edit site pages
Installation
Install the package via npm:@wordpress/babel-preset-default.
Initializing the Site Editor
You initialize the Site Editor using theinitialize function:
Parameters
| Parameter | Type | Description |
|---|---|---|
selector | string | CSS selector for the root DOM element where the editor will mount |
settings | Object | Block editor settings object with theme support, colors, fonts, etc. |
The settings object should include all block editor configuration from your theme’s
theme.json file, merged with any programmatic settings.Key Differences from Post Editor
While@wordpress/edit-post focuses on individual posts and pages, @wordpress/edit-site manages site-wide elements:
| Feature | edit-post | edit-site |
|---|---|---|
| Primary Use | Editing individual posts/pages | Editing templates and site design |
| Entity Types | Posts, pages, custom post types | Templates, template parts, navigation |
| Scope | Single content item | Site-wide elements |
| Navigation | N/A (single item focus) | Template browser, pattern library |
| Styles | Per-post settings | Global styles system |
Site Editor Features
Template Management
The Site Editor provides a visual interface for managing templates:Global Styles Interface
The Site Editor includes a comprehensive global styles panel:- Typography - Font families, sizes, line heights, and text decorations
- Colors - Color palettes, duotone filters, and gradients
- Layout - Content width, wide width, and spacing scales
- Blocks - Per-block-type style overrides
Global styles follow a three-layer merge system: WordPress defaults <
theme.json < user customizations. This ensures user preferences always take precedence.Template Part Editing
Template parts are reusable components that appear across multiple templates:Navigation and Routing
The Site Editor uses client-side routing to navigate between different views:/- Site Editor home with template browser/wp_template/all- All templates view/wp_template/single/{slug}- Edit specific template/wp_template_part/all- All template parts view/patterns- Pattern library/navigation- Navigation menu editor/page- Page management interface
Working with the Entity System
The Site Editor works extensively with WordPress entities through@wordpress/core-data:
Block Theme Requirements
The Site Editor requires a block theme to function properly. Block themes must:- Include an
index.htmltemplate in the/templatesdirectory - Optionally provide a
theme.jsonfile for design system configuration - Use block-based templates (HTML files with block markup)
- Define template parts in the
/partsdirectory (optional)
theme.json Integration
The Site Editor reads your theme’stheme.json to populate available styles:
Extending the Site Editor
You can extend the Site Editor using the same plugin system as the post editor:Plugin components registered for the Site Editor appear in the template editing interface, allowing you to add custom panels and controls.
REST API Endpoints
The Site Editor interacts with several WordPress REST API endpoints:/wp/v2/templates- Template CRUD operations/wp/v2/template-parts- Template part management/wp/v2/global-styles- Global styles configuration/wp/v2/navigation- Navigation menu data/wp/v2/patterns- Pattern library access/wp/v2/template-types- Available template types
Performance Considerations
The Site Editor loads more data than the post editor. Consider these optimization strategies:- Lazy loading - Load templates and patterns on demand
- Caching - Cache frequently accessed templates and global styles
- Selective queries - Only fetch needed fields using
_fieldsparameter - Pagination - Use pagination for large template and pattern lists
Related Packages
@wordpress/block-editor- Generic block editing functionality@wordpress/editor- WordPress entity-aware editor features@wordpress/core-data- WordPress entity management and REST API integration@wordpress/global-styles-ui- Global styles interface components@wordpress/router- Client-side routing for site editor navigation