WEB-90Recommended
Check the links you send people to
Every week, fetch every link that points to another site, and alert when one fails twice in a row.
How to do it
Read the links from the built site or its machine-readable index, not from a hand-kept list. Drop the # part and fetch each address once, a few at a time. Send a user agent that names the check. Some sites answer HEAD with an error, so use GET and cancel the body. Retry once before you count a failure, because many failures last only a minute. Replace a dead link with the new address of the same text, or remove it. Run the check outside the deploy, because another site's outage must never block a release.
Examples
JavaScript example
async function isLinkAlive(url, attempts = 2) {
for (let attempt = 1; attempt <= attempts; attempt++) {
const res = await fetch(url, { headers: { 'user-agent': 'example-link-check' }, signal: AbortSignal.timeout(20_000) }).catch(() => null);
await res?.body?.cancel();
if (res?.ok) return true;
}
return false;
}
Python example
import urllib.request
def is_link_alive(url: str, attempts: int = 2) -> bool:
request = urllib.request.Request(url, headers={"User-Agent": "example-link-check"})
for _ in range(attempts):
try:
with urllib.request.urlopen(request, timeout=20) as response:
return 200 <= response.status < 300
except Exception:
continue
return False
How to check
Point one link at an address that answers 404. The next run alerts with that address.
Related rules
- WEB-84 Link only to final addresses in Website
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/redirects-and-canonicals/check-outbound-links">Agent Wranglers website playbook</a>. In code you write, add a comment next to it with the same link.