# Fix broken links

- Check 12.13 · Internal linking · Important
- Source: https://checklist-seo-geo.com/en/internal-linking/fix-broken-links
- Repair broken internal links: 4xx and 5xx errors, missing #section anchors, malformed hrefs, deleted files, with the right replacement target.
- Updated on 2026-11-25
- Licence: CC BY 4.0. Credit “Checklist SEO & GEO” with a link to https://checklist-seo-geo.com/en/internal-linking/fix-broken-links.
- Plugin checklist-seo-geo: 1.3.1 · https://github.com/maximegaul/checklist-seo-geo

## In short

A broken internal link is a link on your site that does not lead where it promises: a page returning a 404, 410 or 5xx, but also a `#section` anchor that no longer exists on the target page, a malformed `href`, a deleted PDF or image, a link that breaks only in the mobile menu or in another language. The task is to find them all, rank them by importance, then choose for each one the replacement target that keeps the link's intent. Once done, every link in your internal linking leads to the right page, at the right spot.

Detecting HTTP errors and fixing them at a basic level is covered in [fix broken internal links](https://checklist-seo-geo.com/en/http-redirects/fix-broken-internal-links). This guide covers what that audit misses and how to rebuild internal linking around the repaired links.

## Why it matters

An internal link has two roles: taking the visitor to the answer and telling search engines which page covers the topic. A broken link loses both. Google points out that every page you care about should have a link from at least one other page on the site, and that it discovers most pages by following links; a page whose inbound links are broken becomes, from its point of view, a less connected page, or even an orphan.

Standard audits only see HTTP status codes. Yet some broken links return a 200:

- **Missing anchor**: `/guide-entretien/#purge-radiateurs` loads the page fine, but the `purge-radiateurs` identifier disappeared during a rewrite. The reader lands at the top of a long guide, without the answer.
- **Malformed href**: `href="www.example.com/tarifs"` with no protocol is read as a relative path and produces `/blog/www.example.com/tarifs`.
- **Link to an emptied page**: the page returns a 200 but shows “No products” or an error message; see [fix soft 404s](https://checklist-seo-geo.com/en/indexing-canonicalization/fix-soft-404s).

AI assistants that browse a site, and search engines that point to a specific passage on a page, depend on the same links and the same anchors. No practice guarantees a citation, but a link that leads to the right passage can only help.

## What it improves

- **Internal linking**: target pages get their inbound links and the context of their anchors back.
- **Crawling**: fewer requests to dead ends. A noticeable effect when the error is in a template.
- **Visitor experience**: fewer error pages and fewer arrivals at the wrong spot on a long page.
- **Conversion**: links from guides to commercial pages work again. Measurable in your analytics tool.
- **Rankings**: no direct effect; Google states that 404s do not penalize a site. The gain comes from restored internal linking.

## How to check

1. **HTTP errors**: a full crawl with Screaming Frog (free up to 500 URLs), `Response Codes` tab, `Internal` filter, 4xx and 5xx errors, then the `Inlinks` tab at the bottom for the source pages. Free methods beyond 500 URLs are in the guide [fix broken internal links](https://checklist-seo-geo.com/en/http-redirects/fix-broken-internal-links).
2. **`#section` anchors**: the script in step 3.
3. **Malformed hrefs**: the command in step 4.
4. **Mobile versions and languages**: run the crawl again with the smartphone user agent (`Configuration > User-Agent`) and from the home page of each language.
5. **Bing Webmaster Tools**: the Site Scan audit also reports broken links.

Compliant result: zero internal links to an error, zero missing anchors, zero malformed `href` values, across every version of the site.

## How to implement

### Step 1 — Prioritize

Export the list “source page, broken URL, anchor, link position” and add a priority:

| Situation | Priority |
|---|---|
| Template link (menu, footer, breadcrumbs) | 1, whatever the target |
| Link from a high-traffic page or a page that earns backlinks | 1 |
| Link to a priority commercial page | 1 |
| Editorial link from a rarely visited page | 2 |
| Link to an old file (PDF, image) in an archive | 3 |

Pages that receive traffic and backlinks can be found with [identify the most visible pages](https://checklist-seo-geo.com/en/internal-linking/identify-most-visible-pages) and [identify pages that earn backlinks](https://checklist-seo-geo.com/en/internal-linking/identify-pages-that-earn-backlinks).

### Step 2 — Choose the replacement target

A repaired link must keep the intent of the sentence. In order:

1. **The same page at its new address**: replace with the exact final URL.
2. **A page that meets the same intent**: a discontinued product is replaced by its successor or by the category that contains it; a merged guide by the guide that absorbed it.
3. **The parent page** if it really answers the sentence: category, pillar page.
4. **None**: rewrite the sentence and remove the link. Never replace with the home page by default. See [avoid redirecting all removed pages to the homepage](https://checklist-seo-geo.com/en/http-redirects/avoid-redirecting-all-removed-pages-homepage).

Adapt the anchor to the passage: if the target changes, “our 600 ml Kyusu kettle” becomes “our cast iron teapots”. For discontinued products, see [manage permanently discontinued products](https://checklist-seo-geo.com/en/e-commerce-seo/manage-permanently-discontinued-products).

Tracking table:

| Source page | Broken link | Type | New target | New anchor | Done on |
|---|---|---|---|---|---|
| `/blog/purger-radiateurs/` | `/guide-entretien/#purge` | Missing anchor | `/guide-entretien/#purger-radiateurs` | bleed the radiators | 2026-11-25 |
| `/guides/choisir-the-vert/` | `/products/kyusu-600` | 404 | `/collections/theieres` | our Japanese teapots | 2026-11-25 |
| `/blog/` (footer) | `/blog/www.example.com/contact` | Href without protocol | `/contact/` | Contact | 2026-11-26 |

### Step 3 — Repair missing #section anchors

This dependency-free Python script reads your sitemap, collects the identifiers (`id` and `name`) of each page and flags internal links whose fragment matches no identifier on the target page. Save it as `ancres.py`:

```python
#!/usr/bin/env python3
"""Internal links to a #fragment anchor missing from the target page."""
import re
import sys
import time
import urllib.parse
import urllib.request
from html.parser import HTMLParser

SITEMAP = sys.argv[1]
HOST = urllib.parse.urlsplit(SITEMAP).netloc


class Parser(HTMLParser):
    def __init__(self):
        super().__init__()
        self.ids, self.links = set(), []

    def handle_starttag(self, tag, attrs):
        a = dict(attrs)
        for key in ("id", "name"):
            if a.get(key):
                self.ids.add(a[key])
        if tag == "a" and a.get("href") and "#" in a["href"]:
            self.links.append(a["href"])


def get(url):
    request = urllib.request.Request(url, headers={"User-Agent": "ancres-check/1.0"})
    with urllib.request.urlopen(request, timeout=15) as response:
        return response.read().decode("utf-8", "replace")


def urls(sitemap):
    body = get(sitemap)
    locs = re.findall(r"<loc>\s*([^<\s]+)\s*</loc>", body)
    return [u for child in locs for u in urls(child)] if "<sitemapindex" in body else locs


pages = {}
for url in urls(SITEMAP):
    try:
        parser = Parser()
        parser.feed(get(url))
        pages[url] = parser
    except Exception as error:
        print(f"# {url} : {error}", file=sys.stderr)
    time.sleep(0.3)

print("page_source\tlien\tfragment_absent")
for source, parser in pages.items():
    for href in parser.links:
        target, fragment = urllib.parse.urldefrag(urllib.parse.urljoin(source, href))
        fragment = urllib.parse.unquote(fragment)
        if not fragment or urllib.parse.urlsplit(target).netloc != HOST or fragment == "top":
            continue
        if target not in pages:
            continue
        if fragment not in pages[target].ids:
            print(f"{source}\t{href}\t{fragment}")
```

```bash
python3 ancres.py https://example.com/sitemap.xml > ancres-cassees.tsv
```

The script checks only the pages in the sitemap and does not see identifiers added by JavaScript. For each line, restore the identifier on the target page if the section still exists, or fix the link's fragment. To keep anchors from breaking every time a heading is rewritten, set stable identifiers: see [add stable anchors](https://checklist-seo-geo.com/en/readability-direct-answers/add-stable-anchors).

### Step 4 — Fix malformed hrefs

Look for the following patterns in the HTML of the main templates:

```bash
curl -s https://example.com/blog/purger-radiateurs/ \
  | grep -oE 'href="(#?|javascript:[^"]*|www\.[^"]*|https?//[^"]*|[^"/#:?][^":]*|[^"]*(undefined|null)[^"]*)"' \
  | sort | uniq -c
```

| Pattern found | Effect | Fix |
|---|---|---|
| `href=""` or `href="#"` | Reloads the page or jumps to the top | A real link, or a `<button>` if it is an action |
| `href="javascript:void(0)"` | Nothing for a bot | A real `<a href>` link; see [make links available in HTML with href](https://checklist-seo-geo.com/en/javascript-html-rendering/make-links-available-html-href) |
| `href="www.example.com/…"` | Wrong relative path | Full URL or root-relative path |
| `href="produits/chaise"` | URL differs depending on the page | `/produits/chaise/` |
| `href="/undefined"`, `/null` | Empty variable in the template | Fix the code that builds the link |

### Step 5 — Fix in your tool

### WordPress

Versions: WordPress 6.4 to 7.1, Broken Link Checker plugin 2.4.

- **Continuous detection**: the Broken Link Checker plugin checks the links in your content. With its cloud engine, offered by default, you can edit or remove them from its list; with the local engine, fix them in the editor.
- **Anchors**: in the block editor, a heading's identifier is set in the block panel, `Advanced > HTML anchor`. Do not let it change every time the heading is edited.
- **Files**: a PDF deleted from the `Media Library` breaks every link that points to it. When possible, replace the file with a new version at the same address rather than deleting it.
- **Menus**: with a classic theme, `Appearance > Menus` flags items whose target page no longer exists. With a block theme, open each menu in `Appearance > Editor > Navigation` and check its links.

### Shopify

Versions: Shopify admin, all plans, November 2026.

Uploaded files (`Content > Files`) have an address on Shopify's CDN: a deleted file breaks the links in descriptions and pages. Menus are fixed in `Content > Menus`. An archived or deleted product breaks its links: replace them in blog posts and collections, and create a redirect in `Content > Menus > View URL redirects` for external links.

### PrestaShop

Versions: PrestaShop 8 and 9.

Fix the descriptions (`Catalog`), CMS pages (`Design > Pages`) and the menu and footer modules. A disabled product can return a 404 or a redirect depending on the setting chosen on its product page (`SEO` tab, page behavior when the product is offline): align the links with that choice.

### Drupal

Versions: Drupal 10 and 11, Link checker module 2.x.

The Link checker module extracts links from content when it is saved, checks them periodically and shows broken links in the reports and on the content edit page. It can also update links that point to a permanent redirect. Section identifiers are set in CKEditor through the `id` attribute, or with the anchor modules in your installation.

### Wix

Versions: Wix Editor and Wix Studio, November 2026.

Wix has no built-in link checker: start from an external crawl, then fix each link in the editor. For anchors, use the editor's “Anchor” elements and link to them rather than typing a fragment by hand.

### Webflow

Versions: Webflow Designer, all site plans, November 2026.

Fix the links in the Designer and in collection link fields. For an anchor, give the section an ID in the element settings panel, then choose “Page section” as the link target.

### Laravel

Versions: Laravel 11 to 13, Pest 3 and 4.

Add a fragment check on key pages to the internal links test:

```php
it('contains no missing internal anchor', function (): void {
    $html = $this->get('/guide-entretien')->assertOk()->getContent();

    preg_match_all('/href="#([^"]+)"/', $html, $links);
    preg_match_all('/\sid="([^"]+)"/', $html, $ids);

    expect(array_diff(array_unique($links[1]), $ids[1]))->toBeEmpty();
});
```

### Next.js

Versions: Next.js 15 and 16.

Run linkinator on the local build in continuous integration (see the HTTP guide) and generate heading identifiers deterministically, for example with the `rehype-slug` plugin for MDX, so that an anchor changes only when the heading text does.

### Astro

Versions: Astro 5 to 7.

Astro adds identifiers to Markdown headings based on their text. A rewritten heading therefore changes its identifier: search for old fragments in `src/content` after each rewrite, or set the identifier in HTML within the content.

### Step 6 — Monitor over time

Run the check again after every template redesign, migration or removal of a batch of products, and every month on a site that publishes often. See [schedule automated crawls](https://checklist-seo-geo.com/en/automation-quality-control/schedule-automated-crawls).

> **Tip:** for a page that lost many inbound links at once, then check that it has not become [under-linked](https://checklist-seo-geo.com/en/internal-linking/identify-under-linked-pages).

## Common mistakes

- **Checking only HTTP status codes**: missing anchors and emptied pages slip through.
- **Replacing every broken link with the home page**: the link no longer answers the sentence.
- **Keeping the original anchor with a new target**: the anchor describes a page that no longer exists.
- **Rewriting a heading without checking its anchor links**: every `#fragment` that pointed to it breaks silently.
- **Deleting a file from the media library** instead of replacing it at the same address.
- **Crawling only the desktop version in a single language**: mobile menus and other languages often have their own broken links. See [test cross-language links](https://checklist-seo-geo.com/en/multilingual-tracking-maintenance/test-cross-language-links).

## Frequently asked questions

### Is a link to a missing #section anchor a broken link?

Yes, for the visitor a link to a missing anchor is broken, even if the page returns a 200: they land at the top of the page instead of the promised passage. Standard crawlers do not report it, because they ignore the fragment. Check these links with a script that compares fragments with the target page's identifiers, and set stable identifiers on sections.

### What should a link to a deleted page be replaced with?

Replace a link to a deleted page with the page that meets the same intent: the new location, the successor product, the guide that absorbed the content or the parent category. Adapt the anchor to the new target. If no page answers the sentence, remove the link and rewrite the sentence rather than pointing to the home page.

### Do broken links prevent a page from being indexed?

Broken links do not prevent the pages that contain them from being indexed. However, a target page whose inbound links are all broken becomes hard to discover and looks less important: Google finds most pages by following links and asks that every page you care about receive at least one link from another page on the site.

### Should links to PDFs and images be checked too?

Yes, also check links to PDFs, images and other files. They often break silently when a file is deleted from the media library or the CDN, and visitors looking for a technical data sheet or a price list hit an error. A crawl that includes resources reports them; replace the file at the same address rather than deleting it.

## Resources

- [Google Search Central: Link best practices](https://developers.google.com/search/docs/crawling-indexing/links-crawlable?hl=en)
- [Google Search Central Blog: Do 404s hurt my site?](https://developers.google.com/search/blog/2011/05/do-404s-hurt-my-site)
- [MDN: id attribute](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Global_attributes/id)
- [Bing Webmaster Tools: Site Scan](https://www.bing.com/webmasters/help/site-scan-623520c9)
- [Drupal: Link checker module](https://www.drupal.org/project/linkchecker)
- [linkinator: documentation](https://github.com/JustinBeckwith/linkinator)

Next steps: [identify under-linked pages](https://checklist-seo-geo.com/en/internal-linking/identify-under-linked-pages) and [audit the internal link graph](https://checklist-seo-geo.com/en/internal-linking/audit-internal-link-graph).
