---
title: "Write each page once for every format · Agent Wranglers"
url: https://agentwranglers.se/playbook/website/site-architecture/one-source-many-formats
updated: 2026-10-20
licence: "All rights reserved"
---

# Write each page once for every format

By Erik Bergstedt, Agent Wranglers. Updated 2026-10-20.

- Level: Recommended
- Chapter: [Site architecture](https://agentwranglers.se/playbook/website/site-architecture)
- Rule: Build every format (HTML, Markdown, JSON-LD, sitemap, feeds, llms.txt) from the same page data, so they cannot drift apart.
- How: 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.
- 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.

Example:

```js
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
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>')
```

**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`.

- Previous: [Keep pages as data](https://agentwranglers.se/playbook/website/site-architecture/pages-as-data)
- Next: [Render at build time and serve from memory](https://agentwranglers.se/playbook/website/site-architecture/render-at-build-time-serve-from-memory)
- [Site architecture](https://agentwranglers.se/playbook/website/site-architecture)
