Nativa
Themes as modules, for kids

Themes as modules, for kids

A theme used to be a thing rather than a place. Not a class, not a file — a decision, a colour and a padding, scattered across whichever template happened to need them.

The first part of this series is about how a scattered mixture becomes a module: one place you can open and read.

What it was before

Three reasons the mixture spread. Each looked entirely reasonable, which is exactly why it lasted so long.

  • Colours inline in markup, where nobody went looking for them.
  • Margin decisions living in a template instead of a token.
  • Branches on whether something was “our” theme or not.

A theme was not a thing. It was a mixture that looked like one.

The contract

An interface. Sixteen methods: eight for identity and assets, three for the chrome, and one per public surface.

public function header(ShellContext $context): string;
public function footer(ShellContext $context): string;
public function pageWrap(string $content): string;
public function homepage(PageContext $context): string;
public function blogIndex(PageContext $context): string;
public function blogArticle(PageContext $context): string;

The connector

One file knows that erik means ErikTheme. Nothing else knows anything about themes — and an architecture test enforces it.

What stays in the core

The head connector. Metadata, JSON-LD, the nonce — that belongs to the kernel, not the theme. A theme starts after <body>.