Agent Wranglers

WEB-17Optional

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. The same idea for documents is State each value in one document and link to it.

Examples

JavaScript 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>`);

Python example

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: 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/one-source-many-formats">Agent Wranglers website playbook</a>. In code you write, add a comment next to it with the same link.