Skip to content

WordPress block themes from scratch — the file structure that ships

A WordPress block theme is theme.json plus a folder of HTML templates. The minimal file structure that produces a working block theme, with notes on what each file actually does.

A WordPress agency that has built classic themes for a decade is asked to ship a block theme. The reflex is to copy a working classic theme, rename it, and start changing things. That produces a hybrid that mostly works and is impossible to debug. A block theme is structurally different — theme.json, templates/, parts/, and no header.php or footer.php at the root. Starting from a block theme template, not from a classic theme, is the right move.

What’s happening

WordPress 5.9 introduced block themes (also called FSE themes — Full Site Editing). A block theme has no header.php, footer.php, or index.php in the classic sense. Instead, templates/index.html is the home template, parts/header.html is the header, and theme.json declares the design system — colors, spacing, typography, what blocks are allowed in which contexts.

A block theme produces a Site Editor experience: users can edit templates, change global styles, and create their own template parts without touching code. The trade is that “make this change in CSS” stops being the answer — most appearance changes live in theme.json or in the template HTML, not in a stylesheet.

The minimum viable block theme is six files. Everything else is optional.

How to verify

For an existing block theme, the file structure tells you what’s actually there:

cd wp-content/themes/example-block-theme
ls -la
# expect: style.css, theme.json, templates/, parts/, functions.php (optional)
cat theme.json | jq '.version, .settings, .templateParts'

version must be 2 or 3 (3 is current as of WordPress 6.6). Version 1 was experimental and not all features work.

Check that templates resolve:

ls templates/
# index.html (mandatory), single.html, page.html, archive.html, 404.html
ls parts/
# header.html, footer.html, sidebar.html

In WordPress admin, Site Editor (Appearance > Editor) should open without errors. If it shows “Template not found,” the theme is missing templates/index.html.

What to do

Build a minimum block theme that ships.

  1. Directory structure:
my-block-theme/
├── style.css           (required — declares the theme to WordPress)
├── theme.json          (design system + settings)
├── templates/
│   ├── index.html      (the fallback template)
│   ├── single.html     (single post)
│   ├── page.html       (single page)
│   ├── archive.html    (archives)
│   └── 404.html        (not found)
├── parts/
│   ├── header.html
│   └── footer.html
└── functions.php       (optional — for theme support, custom blocks)
  1. style.css is the theme metadata header, not stylesheet code (though you can add CSS below the header):
/*
Theme Name: My Block Theme
Theme URI: https://example.com
Author: Agency Name
Description: Custom block theme for example.com
Version: 1.0.0
Requires at least: 6.4
Tested up to: 6.6
Requires PHP: 8.0
License: GPL-2.0-or-later
Text Domain: my-block-theme
*/
  1. theme.json (version 3) declares the design system:
{
    "$schema": "https://schemas.wp.org/trunk/theme.json",
    "version": 3,
    "settings": {
        "appearanceTools": true,
        "color": {
            "palette": [
                { "slug": "brand-primary", "color": "#0F4C81", "name": "Brand Primary" },
                { "slug": "brand-accent", "color": "#F7B500", "name": "Accent" }
            ]
        },
        "typography": {
            "fontFamilies": [
                {
                    "slug": "system",
                    "fontFamily": "-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif",
                    "name": "System"
                }
            ],
            "fontSizes": [
                { "slug": "small", "size": "0.875rem", "name": "Small" },
                { "slug": "regular", "size": "1rem", "name": "Regular" },
                { "slug": "large", "size": "1.5rem", "name": "Large" }
            ]
        },
        "layout": {
            "contentSize": "720px",
            "wideSize": "1200px"
        }
    },
    "styles": {
        "color": {
            "background": "var(--wp--preset--color--white)",
            "text": "var(--wp--preset--color--brand-primary)"
        },
        "typography": {
            "fontFamily": "var(--wp--preset--font-family--system)"
        }
    },
    "templateParts": [
        { "name": "header", "title": "Header", "area": "header" },
        { "name": "footer", "title": "Footer", "area": "footer" }
    ]
}
  1. templates/index.html (HTML with block comments, not PHP):
<!-- wp:template-part {"slug":"header","tagName":"header"} /-->

<!-- wp:group {"tagName":"main","layout":{"type":"constrained"}} -->
<main class="wp-block-group">
    <!-- wp:query {"query":{"perPage":10,"postType":"post"}} -->
    <div class="wp-block-query">
        <!-- wp:post-template -->
            <!-- wp:post-title {"isLink":true} /-->
            <!-- wp:post-excerpt /-->
        <!-- /wp:post-template -->
    </div>
    <!-- /wp:query -->
</main>
<!-- /wp:group -->

<!-- wp:template-part {"slug":"footer","tagName":"footer"} /-->
  1. parts/header.html and parts/footer.html follow the same shape — block comment HTML, no PHP.

  2. functions.php is optional but useful for registering custom blocks, enqueueing scripts, or declaring theme supports:

<?php
add_action('after_setup_theme', function() {
    add_theme_support('wp-block-styles');
    add_theme_support('responsive-embeds');
    add_theme_support('editor-styles');
});

add_action('init', function() {
    register_block_pattern_category('my-theme', [
        'label' => 'My Theme',
    ]);
});
  1. Develop with hot-reload: WordPress 6.5+ supports theme.json updates via the Site Editor without a refresh. For template HTML edits, refresh the editor.

For the custom blocks that fill out the theme, see WordPress block development workflow. Stack Harbor’s enterprise WordPress support practice ships block themes with theme.json governance for distributed teams. If a classic theme is showing its age and a block theme conversion is on the table, we can scope the project.