Introduction to Block Themes
What is Full Site Editing?
Full Site Editing (FSE) is WordPress's modern approach to theme development. Instead of PHP templates, you use blocks to build every part of your site.
Block Themes vs Classic Themes
| Feature | Classic Theme | Block Theme |
|---|---|---|
| Templates | PHP files | HTML with blocks |
| Header/Footer | header.php, footer.php | Template parts |
| Styles | style.css + PHP | theme.json + CSS |
| Customization | Customizer | Site Editor |
| Widget Areas | register_sidebar() | Block areas |
| Menus | wp_nav_menu() | Navigation block |
Block Theme Requirements
A minimal block theme needs:
my-theme/
โโโ style.css # Theme metadata
โโโ theme.json # Configuration
โโโ templates/
โ โโโ index.html # Fallback template
โโโ parts/
โโโ header.html # Template partRequired: style.css Header
/*
Theme Name: My Block Theme
Theme URI: https://example.com/my-theme
Author: Your Name
Author URI: https://example.com
Description: A modern block theme.
Version: 1.0.0
Requires at least: 6.0
Tested up to: 6.5
Requires PHP: 7.4
License: GNU General Public License v2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Text Domain: my-block-theme
*/Required: templates/index.html
<!-- wp:template-part {"slug":"header","tagName":"header"} /-->
<!-- wp:group {"tagName":"main","layout":{"type":"constrained"}} -->
<main class="wp-block-group">
<!-- wp:query -->
<div class="wp-block-query">
<!-- wp:post-template -->
<!-- wp:post-title {"isLink":true} /-->
<!-- wp:post-excerpt /-->
<!-- /wp:post-template -->
<!-- wp:query-pagination /-->
</div>
<!-- /wp:query -->
</main>
<!-- /wp:group -->
<!-- wp:template-part {"slug":"footer","tagName":"footer"} /-->The Site Editor
Access via Appearance โ Editor (or Site Editor).
Editor Capabilities
- Edit any template
- Create new templates
- Modify template parts
- Adjust global styles
- Create and edit patterns
- Preview on different devices
Template Hierarchy in FSE
Block themes follow the same hierarchy as classic themes:
| Template | Used For |
|---|---|
| index.html | Fallback |
| singular.html | Single posts/pages |
| single.html | Single posts |
| page.html | Pages |
| archive.html | Archives |
| 404.html | Not found |
| search.html | Search results |
| home.html | Blog home |
| front-page.html | Static front page |
Converting a Classic Theme
Steps to convert:
- Create
templates/index.html - Move header to
parts/header.html - Move footer to
parts/footer.html - Add
theme.jsonconfiguration - Convert custom PHP to blocks
Gradual Migration: You can keep functions.php and use it alongside block templates. WordPress will recognize your theme as a block theme if templates/index.html exists.
Your First Block Theme
Let's create a basic block theme structure:
# Create theme directory
mkdir -p wp-content/themes/my-block-theme/{templates,parts,patterns,styles}
# Create required files
touch wp-content/themes/my-block-theme/{style.css,theme.json,functions.php}
touch wp-content/themes/my-block-theme/templates/{index.html,single.html,page.html,404.html}
touch wp-content/themes/my-block-theme/parts/{header.html,footer.html}Next Steps
In the next lesson, we'll dive deep into theme.json configuration.
๐ฏ Lesson Complete! You understand the fundamentals of block themes and Full Site Editing.