Agent Wranglers

Redirects and canonicals Required

Link only to final addresses

Link only to addresses that answer 200. Never link to a redirect from your own pages, sitemap, feeds or canonical tags.

How to do it

After a move, update internal links, the sitemap, feeds, canonicals, hreflang and Open Graph addresses to the new paths. Redirects are for links you cannot change. Make the build fail when a page links to an address that is in the redirect map.

Example

// Build check: no internal link may point at an old address
for (const href of html.matchAll(/href="(\/[^"#?]*)/g)) {
  if (redirects.has(href[1])) fail(`${page}: links to ${href[1]}, which redirects. Link to ${redirects.get(href[1])}`);
}

How to check

The build rejects any page whose links point at a redirect. Fetching every sitemap address returns 200 with no redirect.

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/redirects-and-canonicals/final-addresses.