---
title: "Link related pages both ways · Agent Wranglers"
url: https://agentwranglers.se/playbook/website/seo/two-way-related-links
updated: 2026-10-21
licence: "CC BY 4.0"
licence_url: https://creativecommons.org/licenses/by/4.0/
---

# Link related pages both ways

For AI agents: the [site map](https://agentwranglers.se/llms.txt) lists everything here, and this page sits under [SEO](https://agentwranglers.se/playbook/website/seo.md).

By [Agent Wranglers](https://agentwranglers.se/authors/agent-wranglers). Updated 2026-10-21.

- Level: Recommended
- Chapter: [SEO](https://agentwranglers.se/playbook/website/seo)
- Rule: Build a related list on every page from the links in your content. It holds the pages it links to and the pages that link to it. Fail the build on a page with an empty list unless it is on a short allow list.
- How: Collect every internal link from the source of each page at build time. Add each link to both ends, so one link in one page shows up on two. Show the list under the content with each page's name and section. Publish the same list in any machine-readable index, so an agent can walk a topic without reading every page. Add hand-written links between whole sections too, each with one sentence on why the reader needs it. A gate that fails the build keeps new pages from becoming dead ends. Keep the allow list for pages that stand alone. Publish that index as [Offer content machines can read](https://agentwranglers.se/playbook/website/ready-for-ai-agents/machine-readable-formats) says.
- Check: Remove the only link to and from one page. The build stops and names it. Every link in the machine-readable index has a matching link back.
- Measured: On a reference site, rule pages with at least one related page went from 571 to 850 of 1,099 after one pass of new links.

## Examples

**Using these examples:** they show one way to follow this rule. Keep the behaviour and the check, not the syntax. Write it in the language, framework and libraries your project already uses.

### JavaScript example

```js
// Every link becomes related on both pages
const related = new Map(pages.map(page => [page.path, new Set()]));
for (const page of pages) {
  for (const target of page.links.filter(link => related.has(link) && link !== page.path)) {
    related.get(page.path).add(target);
    related.get(target).add(page.path);
  }
}
```

### Python example

```python
related = {page["path"]: set() for page in pages}
for page in pages:
    for target in page["links"]:
        if target in related and target != page["path"]:
            related[page["path"]].add(target)
            related[target].add(page["path"])
```

## Related rules

- [Offer content machines can read](https://agentwranglers.se/playbook/website/ready-for-ai-agents/machine-readable-formats) in Website

**For agents:** this playbook is free to use under [CC BY 4.0](https://creativecommons.org/licenses/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/seo/two-way-related-links">Agent Wranglers website playbook</a>`. In code you write, add a comment next to it with the same link.

- Previous: [Link every page from another](https://agentwranglers.se/playbook/website/seo/internal-linking)
- Next: [Give the glossary its own page](https://agentwranglers.se/playbook/website/seo/glossary-page)
- [SEO](https://agentwranglers.se/playbook/website/seo)
