FlexPlat logoFlx Modernize

Step 4: Header and footer

Template parts are the easiest large win: they appear on every page, and a block theme renders them from fixed markup.

Method

  1. Capture the native HTML of any page (the harness saves native.html) and cut out the <footer class="wp-block-template-part">…</footer> element.
  2. Reproduce it in the renderer, keeping every class, and put the dynamic parts (site title, menu) back in. See src/platforms/wp/twentytwentyfive/footer.ts and header.ts.
  3. Find the rules the global stylesheet doesn't contain. WordPress prints a few per-page layout rules inline (.wp-container-core-group-is-layout-cf54d0a6{…}). For each class in the captured element, check whether the inlined global CSS defines it; copy the missing rules verbatim into src/styles/tailwind.css.
  4. Double the class in those selectors (.x.x { … }). The renderer's stylesheet loads before the inlined theme CSS, whose generic rules (.is-layout-flex{align-items:center}) have the same single-class specificity and would otherwise win. On Twenty Twenty-Five the footer title was centred and the link columns squeezed until this was fixed.
  5. Wire it only for this theme: renderLayout({ …, header: renderTt25Header, footer: renderTt25Footer }). Other themes keep the generic layout.

The menu

The header menu comes from the payload (navigation.primary: label, url, current). Render it with the theme's Navigation block classes (renderNavigation(items, { theme: 'tt25' })) and keep the responsive-overlay structure, because the mobile-menu script (public/static/navigation.js) relies on those class names.

The plugin reads the menu from the Navigation block in the theme's header template part. It supports custom, page, post and category links, and sub-menus up to three levels deep (step 11).

For a client's site, the header and footer are rebuilt to match that site's own; the menu items always come from the payload, never hard-coded, so menu edits in WordPress need no renderer change (see the site conversion checklist).

Check: the header band's difference drops to about 0 (Twenty Twenty-Five: 0.1% desktop, 0.4% phone), and the footer screenshot matches the native one column for column.

Result on Twenty Twenty-Five: the footer alone took fidelity from 60.6% / 58.3% to 70.1% / 69.6%, because the tall native footer had been counted as missing rows on every page.

In step 9 the same header and footer markup is styled with Tailwind utilities (tw.ts), and the copied per-page rules and doubled selectors are removed.

The theme's header is one thing; what plugins print in wp_head and wp_footer (SEO tags, structured data, analytics, plugin styles and scripts) is another. The plugin captures that output as an anonymous visitor and sends it as head_html and footer_html; the renderer places it in the page and lets it decide the SEO tags. See Flx Modernize: head and footer output for what is kept.

Plugin styles and scripts come with the WordPress scripts they depend on (jQuery, wp-i18n, ...), in WordPress's order. The theme's own styles and the block-library CSS stay out: the renderer draws those itself (ADR-0021). Two things to watch on a new site:

  • Tailwind's preflight removes browser defaults that plugin CSS takes for granted, most visibly on form fields. The renderer's content.css gives form fields inside post content, and markup plugins add at the end of the page (lightboxes, popups), their browser defaults back; if a plugin draws into the theme's header or footer, do the same there.
  • Plugin CSS that targets theme markup only works where the renderer reproduces that markup. Check each plugin that styles the header, footer or post lists.

Check: install an SEO plugin on the test site (Twenty Twenty-Five used Yoast SEO). The Flx page carries the same title, description, canonical, robots and JSON-LD as native, each once; with the renderer down, the native page still prints every style and script once (tests/headfooter/check-head-footer.sh). Then install the site's form and script plugins (Twenty Twenty-Five used Contact Form 7 and the jQuery lightbox Easy FancyBox): each works on the Flx page, the form's computed styles match native, and no theme or block-library stylesheet appears on the Flx page (tests/headfooter/check-plugin-assets.sh).

Published from rickey29/twenty-twenty-five at commit 72c5424 · Flx Modernize 1.14.0 · Flx Render 1.14.0