Agent Wranglers

Site architecture Recommended

Write each page once for every format

Build every format (HTML, Markdown, JSON-LD, sitemap, feeds, llms.txt) from the same page data, so they cannot drift apart.

How to do it

Have the build write each page's HTML, Markdown and JSON-LD, plus a manifest of all pages. Build the sitemap, feeds and agent files from that manifest.

Example

import { writeFileSync } from 'node:fs';
const manifest = pages.map(({ path, title, updated }) => ({ path, title, updated }));
writeFileSync('dist/manifest.json', JSON.stringify(manifest));
const urls = manifest.map(p => `<url><loc>https://example.com${p.path}</loc><lastmod>${p.updated}</lastmod></url>`);
writeFileSync('dist/sitemap.xml', `<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">${urls.join('')}</urlset>`);
import json
from pathlib import Path
manifest = [{"path": p.path, "title": p.title, "updated": p.updated} for p in pages]
Path("dist/manifest.json").write_text(json.dumps(manifest))
urls = "".join(f"<url><loc>https://example.com{p['path']}</loc><lastmod>{p['updated']}</lastmod></url>" for p in manifest)
Path("dist/sitemap.xml").write_text('<?xml version="1.0" encoding="UTF-8"?>\n'
    f'<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">{urls}</urlset>')

How to check

A test reads the page list. Every public page has a sitemap entry and a Markdown file. Every sitemap and feed entry is a listed page.

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/one-source-many-formats.