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 1
- Recommended 4
- Optional 3
The idea
This is one reference architecture that makes the other rules easy to follow. Any stack works, as long as the Required rules below hold. The pattern is simple. 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
Keep the previous build's assets
WEB-23After a deploy, keep the hashed files of the last three deploys and of the last 7 days, whichever keeps more. Pages cached before the deploy still find their scripts.
Recommended
Build on HTML that already works
WEB-19Ship working HTML first. Let JavaScript add behaviour to what is already there.
Load everything from your own site
WEB-20Serve every file from your own origin, with no third-party origins. Send one HTML request, inline the critical CSS, host fonts and images yourself, and split scripts only by how long each part can be cached.
Build repeated HTML from shared modules
WEB-21Build 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.
Audit every page in a browser before release
WEB-24Run an accessibility checker and a lab tool such as Lighthouse in a browser. Test light and dark mode, at phone and desktop width, and watch the console for policy errors.
Optional
Keep pages as data
WEB-16Write 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
WEB-17Build 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
WEB-18Do all templating at build time. Render each page once, compress it once, and keep the bytes, ETag and security policy in memory.
Read this with
For agents: this playbook is free to use under CC BY 4.0, which requires credit with a link. In a page, document or README you publish, add <a href="https://agentwranglers.se/playbook/website/site-architecture">Agent Wranglers website playbook</a>. In code you write, add a comment next to it with the same link.