How to Create Template Parts and Block Templates for Your Theme: A Complete Guide Dec 24, 2025 | 11 minutes read 8 Likes How Template Parts and Block Templates Power Modern WordPress ThemesThe block editor has moved WordPress into a new era where themes are no longer just PHP templates; they’re collections of block-based layouts that give developers more control and users more flexibility. Template parts and block templates play a massive role in this evolution, helping you structure your theme intelligently while keeping everything future-proof and incredibly customizable. Whether you’re building a classic theme, a hybrid theme, or a full block theme, understanding how to create and customize template parts and block templates is essential. This guide breaks the topic down into simple, actionable steps so you can confidently build modern WordPress themes that work seamlessly with Gutenberg. What Are Template Parts? Template parts are reusable sections of a theme, such as the Header, Footer, Sidebar, or any repetitive layout element. In block themes, they’re built using blocks and stored as HTML files instead of PHP. This makes editing them easier for both developers and end users. Why Use Template Parts? They keep your theme modular They let users customize sections without editing code They improve consistency across the site They integrate tightly with the Site Editor They reduce repetitive structure in templates Common template part examples include: header.html footer.html sidebar.html Custom template parts like hero.html, newsletter.html, etc. What Are Block Templates? Block templates define the structure of an entire page or post type using blocks. A template may include: Header block Content area Query loop Sidebar block Footer block CTA section Custom template parts You can create block templates for: Pages Posts Custom post types Archives 404 pages Search results WooCommerce templates Block templates live in your theme’s /templates directory and are written using block markup in .html files. Folder Structure for Templates and Template Parts To build block templates and template parts, ensure your theme follows this structure: your-theme/ ├─ templates/ │ ├─ index.html │ ├─ single.html │ ├─ archive.html │ └─ page.html ├─ parts/ │ ├─ header.html │ ├─ footer.html │ └─ sidebar.html └─ theme.json If your theme does not have these folders, you can create them manually. How to Create Template Parts Creating template parts is simple once you understand the block markup approach that Gutenberg uses. Create Your Template Part FileInside your theme, navigate to: /parts/ Create a file such as: header.html Add Block Markup Inside the FileBlock themes use HTML files that contain block comment markup, like this: This file now becomes a template part that can be reused anywhere in your theme. Register Template Parts via theme.jsonTo enhance flexibility, register template parts using the templateParts section: Include Template Parts Inside TemplatesIn your template, such as index.html: That’s it—your template parts are now dynamic and editable. How to Create Block Templates for Your Theme Block templates define the structure of entire pages. They replace legacy PHP templates. Create a Template File inside /templates/Example: single.html Add Your Page Layout Using BlocksSample block template for single posts: This defines the entire layout of your single post template. Create a Custom Template for Pages or CPTsIf you have a custom post type like portfolio, create: templates/single-portfolio.html Then add layout: WordPress automatically assigns the template to your custom post type. Using theme.json to Control Template Behavior The theme.json file is the heart of block theme configuration. It controls: Layout Colors Typography Spacing Borders Template parts Custom templates Register Block Templates via theme.json : You can tell WordPress about your templates like this: Now this template shows up in the Page Template dropdown.Build flexible WordPress themes with block templatesContact UsThe Way ForwardCreating template parts and block templates is a core skill in modern WordPress development. These tools let you build smart, flexible, modular themes where every section is reusable and customizable. By using block markup instead of PHP, you give users more creative freedom while keeping development clean and scalable. Template parts help you structure the repeatable sections of your theme, while block templates define the layout of entire pages, including custom post types, archives, and landing pages. Combined with the power of theme.json, you can style, register, and manage these templates effortlessly. Mastering template parts and block templates isn’t just about staying updated; it’s about building themes that are future-ready, user-friendly, and optimized for the new block-based era of WordPress.You may also like this: Understanding WP Cron: How It Works & How to Replace It With Real Cron JobsFree Consultation wp theme developmententerprise wordpress development agencywordpress web design companywordpress website developerMaulik MakwanaDec 24 2025You may also like Understanding WP Cron: How It Works & How to Replace It With Real Cron Jobs Read More Dec 22 2025 How to Control Gutenberg Settings in Your Theme (Enable/Disable Features) Read More Dec 22 2025 ACF + Gutenberg: How to Build ACF Blocks (Full Tutorial) Read More Dec 19 2025 How to Create a Reusable Theme Template Using Gutenberg Patterns Read More Dec 17 2025 How to Make Gutenberg Editor Match Frontend Design (Editor Styles Guide) Read More Dec 15 2025 How to Reduce App Load Time with Code-Splitting and Lazy Loading in React Native Read More Dec 15 2025