Sub topic 12
Update internal links to the surviving URL
This chapter assumes you can export reports from Search Console, edit HTML in a CMS, and that you have already merged pages and set up 301 redirects. Here you fix the internal links that still point at the retired URLs.
Why redirects are not enough
A 301 redirect sends visitors and crawlers to the surviving page. Internal links that still point at the old URL work, but they cause three problems:
- Every click and every crawl takes an extra request through the redirect.
- Your site keeps telling search engines that the old URL is the one you care about.
- Redirects get removed during later cleanups. Links to the old URL then break.
The goal is that every internal link points straight at the final URL, with no redirect in between.
Find the links that need changing
Start from the list of retired URLs from your consolidation. Search your site for links that point at them. Most CMSs can search post content. A site crawler can also list every internal link and the page it appears on.
Look in all of these places, not only article bodies:
- Navigation menus, footers and sidebars
- Breadcrumbs and "related posts" blocks
- Image links and call-to-action buttons
- The XML sitemap
- Canonical tags and hreflang annotations
If you can export your pages as HTML files, this script lists the pages that link to a retired URL:
import re
import sys
from pathlib import Path
retired = [
"/blog/on-page-seo-basics/",
"/blog/seo-tips-2019/",
]
pattern = re.compile(r'href="([^"]+)"')
for path in Path(sys.argv[1]).rglob("*.html"):
html = path.read_text(encoding="utf-8")
for href in pattern.findall(html):
if any(href.endswith(old) or href == old for old in retired):
print(f"{path}: {href}")Run it with python find_links.py ./export. It is a first pass. A crawler also catches links that templates and plugins generate.
Choose good anchor text
When you change the URL, check the anchor text too. The anchor text is the visible, clickable words of a link. Make it describe the surviving page, for example "SEO checklist" rather than "click here" or the old page's title. Keep it natural. Do not stuff the same keyword phrase into every link.
Update and verify
- Replace each old URL with the surviving URL, using the exact canonical form, including protocol, host and trailing slash.
- Make sure the surviving page links to related pages that are still live, and not to the pages you merged into it. A page that links to itself through a redirect is a common leftover.
- Re-crawl the site. Filter the results for internal links that return a 301 and for links that return a 404.
- Confirm the sitemap lists only the surviving URL, not the old ones.
Common mistakes
- Fixing only article text and forgetting menus and footers.
- Linking to a version of the URL that differs in trailing slash or
httpversushttps, which creates another redirect. - Leaving links to removed pages that have no redirect target, which produce 404 errors.
Exercise
After merging two posts into /guides/seo-checklist/ and adding 301 redirects, a crawl shows 40 internal links that still point at the old URLs. The links work. Why should you still change them, and should you delete the redirects afterwards?
Show answer
Changing them removes the extra redirect request, signals the surviving URL as the one you want to rank, and avoids broken links if redirects are removed later. You should keep the redirects, because external links, bookmarks and search results still use the old URLs.