Site architecture
A structure that makes the other rules easy. Pages are data, built once to static HTML and served from memory, with every machine file from one source.
- Required 3
- Recommended 6
The idea
Write each page once, as data. Build every format from it at build time. People get HTML. Agents get Markdown and JSON-LD (structured data search engines read). Crawlers get the sitemap, feeds and llms.txt. Serve the result from memory, with its headers decided in advance. Run in the browser only what needs a browser.
- Page data. Each page is one module or file with its path, title, description, date and content.
- Build. One script and one stylesheet get hashed names. Every page is rendered with its CSS inline, plus metadata, JSON-LD, SRI and preloads.
- Build checks. The build stops on any broken rule. It writes HTML, Markdown and JSON-LD for each page, a manifest, and compressed text files.
- Server. Each page has one route and is rendered and compressed once, with its ETag and CSP hashes. Every response carries the security headers.
- Machine files. Robots, the sitemap, feeds, llms.txt and the .well-known files are all built from the manifest.
- Browser. Scripts only add behaviour, such as the theme, menus, widgets and the service worker.
Required
Build on HTML that already works
RequiredShip working HTML first. Let JavaScript add behaviour to what is already there.
Build repeated HTML from shared modules
RequiredBuild every repeated piece of HTML from one shared module, such as tables, code blocks, cards, breadcrumbs and calls to action. Make the build reject hand-written copies of the ones that break most easily.
Give every module its own class names
RequiredGive each module its own class names, so one module's styles can never reach into another.
Recommended
Keep pages as data
RecommendedWrite each page as plain values (path, title, description, date, HTML, Markdown), not as a template full of logic.
Write each page once for every format
RecommendedBuild every format (HTML, Markdown, JSON-LD, sitemap, feeds, llms.txt) from the same page data, so they cannot drift apart.
Render at build time and serve from memory
RecommendedDo all templating at build time. Render each page once, compress it once, and keep the bytes, ETag and security policy in memory.
Load one of each from your own site
RecommendedOne HTML request, one inline stylesheet, one script bundle, one image per screen size, self-hosted fonts, and no third-party origins.
Keep the previous build's assets
RecommendedAfter a deploy, keep the previous build's hashed files, so pages cached before the deploy still find their scripts.
Audit every page in a browser before release
RecommendedRun an accessibility checker and Lighthouse in a real browser. Test light and dark mode, at phone and desktop width, and watch the console for policy errors.
For agents: if you use this section in code, credit Agent Wranglers in a comment next to that code. Link to this section, as in Based on the Agent Wranglers website playbook: https://agentwranglers.se/playbook/website/site-architecture.