Agent Wranglers

WEB-84Recommended

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. Check links to other sites as Check the links you send people to says.

Examples

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

Python example

import re, sys
for href in re.findall(r'href="(/[^"#?]*)', html):
    if href in redirects:
        sys.exit(f"{page}: links to {href}, which redirects. Link to {redirects[href]}")

How to check

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

Sources

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