Skip to main content

Block Theme Development

Block themes leverage WordPress Full Site Editing (FSE) to provide visual, no-code customization experiences. WooCommerce fully supports block themes with specialized templates, blocks, and global styling through theme.json.
This guide covers block themes using HTML templates and FSE. For classic PHP-based theme development, see Classic Theme Development.
New to block theme development? Complete the WordPress Block Theme Development Course before diving into WooCommerce-specific concepts.

Block Theme Fundamentals

Block themes use HTML files instead of PHP templates and are styled through theme.json rather than traditional CSS. This architecture enables:
  • Visual editing - Users customize templates in the Site Editor
  • Global styles - Consistent styling via theme.json configuration
  • Better performance - Only required CSS loads on each page
  • User control - Non-developers can modify layouts without code

Prerequisites

Before developing WooCommerce block themes, ensure you understand:
  • WordPress block editor (Gutenberg)
  • Block templates and template parts
  • theme.json configuration
  • Global styles and settings
  • Site Editor interface

WooCommerce Block Templates

WooCommerce provides default block templates for product and shop pages. These templates are located in:

Available Templates

  • single-product.html - Single product page layout
  • archive-product.html - Main shop/product catalog
  • product-search-results.html - Product search results

Template Hierarchy

WooCommerce block templates follow WordPress template hierarchy with specific fallback patterns:
Category, tag, and attribute templates fall back to archive-product.html if specific taxonomy templates aren’t provided.

Overriding Block Templates

Create custom templates by adding HTML files to your theme’s /templates/ directory:
1

Create Templates Directory

Ensure your theme has a templates/ folder:
2

Copy WooCommerce Template

Copy the template you want to customize from WooCommerce to your theme:
3

Edit in Site Editor

Customize the template using the WordPress Site Editor:Appearance → Editor → Templates → Single Product
4

Export Changes (Optional)

Export modified templates to commit them to your theme repository.

Example: Custom Single Product Template

Specific Product Templates

Create templates for specific products using their slug:

Block Template Parts

WooCommerce provides specialized template parts for reusable components:

Available Template Parts

  • mini-cart.html - Used inside the Mini-Cart block drawer
  • checkout-header.html - Header used in checkout template
Override template parts in your theme’s /parts/ directory:

Example: Custom Mini-Cart Template Part

Styling with theme.json

Global styles in theme.json provide the primary styling mechanism for block themes. WooCommerce blocks support all standard theme.json style properties.

Basic WooCommerce Block Styling

Complete WooCommerce Styling Example

Advantages of theme.json Styling

Performance

Only necessary CSS loads per page, reducing bundle size and improving load times

User Customization

Users can modify styles through the Site Editor without touching code

Conflict Management

Gracefully handles conflicts between plugins and themes

Markup Independence

Styles persist even when block markup or class names change
Avoid writing CSS that depends on specific block nesting or HTML structure. Users can freely rearrange blocks, breaking CSS selectors that rely on hierarchy.

WooCommerce Block Reference

Common WooCommerce blocks available in block templates:

Product Display Blocks

Product Collection Blocks

Cart & Checkout Blocks

Utility Blocks

For the complete block reference including all attributes and settings, see the WooCommerce Block Reference.

CSS Styling (When Necessary)

While theme.json is preferred, some styling requires custom CSS. When writing CSS for block themes:
WooCommerce strongly discourages CSS selectors that rely on specific block nesting. Users can rearrange blocks freely, breaking hierarchy-dependent selectors.

CSS Best Practices

Block and Component Class Names

WooCommerce uses BEM naming with two prefixes:
  • .wc-block- - Block-specific classes
  • .wc-block-components- - Reusable component classes
Target components globally or within specific blocks:

Container Queries for Cart/Checkout

Cart and Checkout blocks define CSS containers for responsive styling:
Container queries allow responsive design based on parent container width, not viewport width. This provides better adaptability in varied layouts.

User Customization Considerations

Block themes empower users to customize templates through the Site Editor. Design themes with this in mind:
1

Provide Sensible Defaults

Set up well-structured default templates that work out-of-the-box but remain customizable.
2

Use Global Styles Extensively

Define comprehensive theme.json styles so users can modify appearance without CSS.
3

Document Customization Options

Provide theme documentation explaining which blocks and styles users can safely modify.
4

Test User Modifications

Test templates with various block arrangements to ensure CSS doesn’t break with user changes.
Users can modify templates via the Site Editor. Always keep in mind that blocks may be moved, removed, or added in unexpected ways.

Migration from Classic Themes

Converting classic themes to block themes requires restructuring templates and styles:
Convert PHP templates to HTML block templates:Classic (PHP):
Block (HTML):

Best Practices

Prioritize theme.json

Use global styles for all styling that doesn’t require complex selectors

Avoid Structure Dependency

Never write CSS that assumes specific block nesting or order

Test with Variations

Test templates with blocks added, removed, and rearranged by users

Document User Options

Clearly explain which customizations users can make safely

Next Steps

Block Reference

Complete reference for all WooCommerce blocks

Theme Customization

Advanced styling and customization techniques

Create Block Theme Plugin

Tool for creating and exporting block themes