Frontend to WP

How to Split Static HTML into WordPress Templates & Partials

Diagram illustrating how to Split Static HTML into WordPress Templates including header.php and footer.php
Decomposing a monolithic HTML document into header.php, front-page.php, and footer.php.

Transitioning from a single-file static prototype to a maintainable WordPress theme starts with learning how to split static HTML into WordPress templates cleanly. Separating shared headers and footers from page content eliminates code duplication and ensures every WordPress core hook executes reliably.

1. Mapping Static Landmarks When You Split Static HTML into WordPress Templates

In static websites, every .html file repeats the exact same document head, navigation bar, and footer markup. When converting to WordPress, review your static HTML document and split it along three primary boundaries:

  • header.php: Holds <!DOCTYPE html>, the <head> section, opening <body <?php body_class(); ?>> tag, and site navigation.
  • front-page.php / index.php / page.php: Calls get_header() at the top, renders the main content or WordPress Loop, and calls get_footer() at the bottom.
  • footer.php: Closes main containers, renders footer links and copyright notices, and outputs closing </body></html> tags.

2. Placing the Three Mandatory WordPress Hooks

Omitting core hooks is the single most common bug when converting static prototypes. As detailed in the WordPress Template Hierarchy Handbook, every theme requires three hooks in exact positions:

  • wp_head(); directly before </head> in header.php (required for SEO meta tags, enqueued stylesheets, and admin bar styles).
  • wp_body_open(); immediately after the opening <body> tag in header.php (required for skip links and tag manager scripts).
  • wp_footer(); directly before </body> in footer.php (required for deferred JavaScript assets and footer analytics).

3. Canonical Loop & Reusable Template Parts

Inside index.php, wrap repeating post or card markup using the standard WordPress Loop and get_template_part() so archive, search, and blog templates share consistent card layouts:

<?php get_header(); ?>
<main id="primary" class="site-main container">
	<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
		<?php get_template_part( 'template-parts/content', get_post_type() ); ?>
	<?php endwhile; the_posts_pagination(); endif; ?>
</main>
<?php get_footer(); ?>

Common Mistakes to Avoid When Splitting HTML

  • Unclosed Wrapper Tags: Make sure every <div> or <main> opened at the bottom of header.php has its matching closing tag at the top of footer.php.
  • Duplicate HTML/Body Attributes: Remove static lang="en" and static class="..." attributes on <html> and <body> once language_attributes() and body_class() are in place.
  • Hardcoded Asset Links: Move static stylesheet and script tags out of header.php and footer.php into functions.php via our Enqueue Generator.

4. Testing Your Split Templates Across Multiple WordPress Views

Once you split static HTML into WordPress templates, verify that header.php and footer.php render consistently across single blog posts (single.php), category archives (archive.php), search results (search.php), and custom landing pages. Because page templates omit editorial sidebars or hero banners used on the homepage, wrap page-specific sections inside front-page.php or dedicated template-parts/ files rather than hardcoding them into the global header.

Check rendered HTML source in browser DevTools to confirm asset links resolved cleanly via wp_head() and wp_footer() before shipping to production.

Frequently Asked Questions

Should my static landing page go into index.php or front-page.php?

Place custom homepage sections inside front-page.php and keep index.php for the canonical WordPress Loop fallback so blog archives, search results, and category pages do not inherit landing-page hero markup unintentionally.

Why do semantic <main> and <footer> tags make HTML splitting cleaner?

Explicit semantic landmarks make boundary slicing unambiguous for automated splitters and screen readers alike without relying on brittle CSS wrapper class names.

What if my prototype needs different headers on landing pages vs blog posts?

Create header-landing.php alongside header.php and load it conditionally via get_header( 'landing' ) inside your custom page template.

How should global navigation links and logos stay editable inside header.php?

Replace hardcoded anchor lists with wp_nav_menu() bound to a registered menu location and call the_custom_logo() or get_bloginfo( 'name' ) so site owners can update branding and navigation labels from WordPress Admin without editing PHP files after you split static HTML into WordPress templates cleanly for client handoff.

Automate this entire split in seconds with our Static HTML to header.php & footer.php Splitter, then package your full theme with the Starter Theme ZIP Generator.

WH

WP Haider

WordPress core engineer, theme architect, and founder of CodeToWP. Building lightweight, zero-bloat developer tooling for modern web workflows.