Website Structure Audit: Steps, Python Script and Report

Audit website structure step by step: crawl depth, URL hierarchy, orphans and internal links, with a Python script and a report template to share with clients.

· BugViso Team

16 min read

A website structure audit checks how your pages connect: click depth, orphan pages, where internal links concentrate, URL hierarchy and whether your XML sitemap matches the pages you link to.

Important pages should be within three clicks, linked from relevant hubs and listed in the sitemap at their final URL. The audit report turns those checks into numbers and an ordered fix list.

Search engines discover and weigh pages mostly through internal links. A page buried six clicks deep, or linked from nowhere, gets crawled less and inherits little authority, however good its content.

A structure audit finds those pages and the template decisions that created them. If you're planning a new site rather than auditing one, start with a topical authority map.

You'll come away with the seven audit steps, a script that crawls your site and writes the website structure audit report in Markdown, and a real report from our own site showing what each section should say.


What a Website Structure Audit Checks

A website structure audit checks six things: click depth, orphan pages, internal link distribution, URL hierarchy, navigation and breadcrumbs, and sitemap against crawl. The table shows what to look for and why each matters.

CheckWhat you're looking forWhy it matters
Click depthPages more than 3 clicks from the homepageDeep pages are crawled less often and look less important
Orphan pagesPages in the sitemap or analytics that no page links toCrawlers can only find them through the sitemap; they get no internal link equity
Internal link distributionWhich pages receive the most links, and which receive almost noneLinks signal importance; money pages should be well linked
URL hierarchyFolders that reflect sections (/blog/, /products/category/item)Clear sections help users and crawlers understand grouping
Navigation and breadcrumbsCrawlable <a href> links in menus, footers and breadcrumbsJavaScript-only menus hide structure from crawlers
Sitemap vs crawlURLs in one but not the other; sitemap URLs that redirect or 404The sitemap should list exactly your indexable, final URLs

Google's ecommerce guide on site structure states the reason directly: Google can use the number of links it needs to follow to reach a page, and the number of links to a page, to infer that page's relative importance.

Its guidance on making links crawlable is the baseline: links need to be <a> elements with an href to count.


What We Found Auditing Real Site Structures

We crawled up to 250 pages on each of 80 sites drawn at random from our study sample (Tranco ranks 1,001–50,000), following raw-HTML links from the homepage, and compared the result with each site's XML sitemap.

FindingResult
Sites with a sitemap findable via robots.txt or /sitemap.xml38 of 76 that completed (50%)
Median sitemap size1,412 URLs
Sitemaps where every sampled URL returned 20022 of 36 (61%)
Sitemaps listing URLs that redirect9 of 36 (25%)
Sitemaps listing URLs that return 404/4105 of 36 (14%)
Internal links on a typical page (median)75

And from our separate raw-vs-rendered study of 219 homepages, 9.2% exposed fewer than half of their links without JavaScript. Those sites' structure is largely invisible to crawlers that don't render, including most AI crawlers.

The pattern: sitemaps drift. Pages get redirected or removed, but the sitemap generator keeps listing the old URLs.

A structure audit is where that drift gets caught.


How to Run a Website Structure Audit, Step by Step

Run a website structure audit in seven steps: crawl from the homepage, then check each structural signal in turn, and finish with a written report. Each step below says what to record.

Start at the homepage and follow internal <a href> links breadth-first. Record the click depth of each page as the first time it's reached. Don't seed the crawl from the sitemap for this step, or you'll hide orphans.

Step 2: Check click depth

List pages by depth. Anything important at depth 4 or more needs a shorter path: a link from a hub page, a category page or the main navigation.

DepthTypical pagesAction if important pages land here
1Main navigation targets—
2Category and hub pages, recent posts—
3Product and article pagesAcceptable
4+Paginated archives, old contentAdd links from hubs or related-content blocks

Step 3: Find orphan pages

Compare the crawl with the sitemap (and with landing pages from analytics or Search Console). Sitemap URLs the crawl never reached are orphan candidates. For each one, decide: link it from a relevant page, merge it, or remove it. Our guide to orphan pages covers the fixes.

Count inbound internal links per page. Your most important commercial pages should be among the most linked. If your most-linked pages are the privacy policy and a tag archive, your templates are distributing links badly. See our internal linking audit checklist.

Step 5: Check URL hierarchy

Folders should match sections. Watch for the same content under two paths (/blog/post and /news/post), parameters creating duplicate pages, and inconsistent trailing slashes.

Step 6: Check navigation, footers and breadcrumbs are crawlable

View the page source (not DevTools) and confirm menu links are real <a href> elements. Breadcrumbs should be links, ideally with BreadcrumbList structured data; see breadcrumb navigation for SEO.

Step 7: Reconcile the sitemap

The sitemap should list every indexable page at its final URL, and nothing else: no redirects, no 404s, no noindex pages, no parameter duplicates. Google's sitemap overview explains the format.


Script: Audit Your Site Structure

This standard-library Python script runs steps 1, 2, 3, 4 and 7, and with --report it writes the audit report for you. It crawls raw HTML only, so links that exist only after JavaScript runs won't be followed (which is exactly what non-rendering crawlers see).

python
"""Website structure audit: click depth, orphan pages, link distribution and sitemap hygiene.

Usage: python3 structure_audit.py https://example.com/ [max_pages] [--report > report.md]
Crawls same-host <a href> links breadth-first from the homepage (raw HTML, no
JavaScript), then compares the result with the sitemap:
  - click depth of every page reached
  - inbound internal links per page, with template links (on 90%+ of pages) split
    from contextual ones, so the footer doesn't hide where equity really goes
  - sitemap URLs never reached by links (orphan candidates)
  - linked pages missing from the sitemap
  - sitemap URLs that redirect or error
--report prints a filled Markdown structure audit report instead of plain text.
Standard library only.
"""
import datetime, html as htmllib, re, sys, urllib.error, urllib.request
from collections import Counter, deque
from urllib.parse import urljoin, urlsplit, urlunsplit

UA = {"User-Agent": "Mozilla/5.0 (structure-audit)"}
SKIP = re.compile(r"\.(jpe?g|png|gif|webp|avif|svg|pdf|zip|mp4|css|js|xml|json|ico)$", re.I)

class NoRedirect(urllib.request.HTTPRedirectHandler):
    def redirect_request(self, *args, **kwargs):
        return None

def fetch(url, follow=True):
    opener = urllib.request.build_opener() if follow else urllib.request.build_opener(NoRedirect)
    try:
        r = opener.open(urllib.request.Request(url, headers=UA), timeout=15)
        ctype = r.headers.get("Content-Type", "")
        body = r.read(3_000_000).decode("utf-8", "replace") if "html" in ctype or "xml" in ctype else ""
        return r.status, r.geturl(), body
    except urllib.error.HTTPError as e:
        return e.code, url, ""
    except Exception:  # noqa: BLE001
        return None, url, ""

def norm(url):
    s = urlsplit(url)
    path = s.path.rstrip("/") or "/"
    return urlunsplit((s.scheme, s.netloc.lower().removeprefix("www."), path, s.query, ""))

def crawl(home, max_pages):
    host = urlsplit(home).netloc.lower().removeprefix("www.")
    depth, inbound, queue, pages = {norm(home): 0}, Counter(), deque([home]), 0
    while queue and pages < max_pages:
        url = queue.popleft()
        status, final, html = fetch(url)
        pages += 1
        if status != 200:
            continue
        seen_here = set()
        for href in re.findall(r'<a\s[^>]*href=["\']([^"\'#]+)', html, re.I):
            link = urljoin(final, htmllib.unescape(href))
            s = urlsplit(link)
            if s.scheme in ("http", "https") and s.netloc.lower().removeprefix("www.") == host and not SKIP.search(s.path):
                key = norm(link)
                if key not in seen_here and key != norm(url):
                    seen_here.add(key)
                    inbound[key] += 1
                if key not in depth:
                    depth[key] = depth[norm(url)] + 1
                    queue.append(link)
    return depth, inbound, not queue, pages

def sitemap(home):
    base = "{0.scheme}://{0.netloc}".format(urlsplit(home))
    _, _, robots = fetch(base + "/robots.txt")
    maps = re.findall(r"(?im)^sitemap:\s*(\S+)", robots) or [base + "/sitemap.xml"]
    urls = []
    for sm in maps[:5]:
        _, _, xml = fetch(sm)
        locs = re.findall(r"<loc>\s*([^<\s]+)\s*</loc>", xml)
        if "<sitemapindex" in xml:
            for child in locs[:10]:
                urls += re.findall(r"<loc>\s*([^<\s]+)\s*</loc>", fetch(child)[2])
        else:
            urls += locs
    return list(dict.fromkeys(u.replace("&amp;", "&") for u in urls))

def audit(home, max_pages=500):
    depth, inbound, complete, fetched = crawl(home, max_pages)
    listed = sitemap(home)
    listed_keys = {norm(u) for u in listed}
    codes, bad = Counter(), []
    for u in listed[:50]:
        code = fetch(u, follow=False)[0]
        codes[code] += 1
        if code != 200:
            bad.append((code, u))
    template = {u for u, c in inbound.items() if c >= 0.9 * max(fetched - 1, 1)}
    return {
        "home": home, "template": template, "fetched": fetched, "complete": complete, "depth": depth, "inbound": inbound,
        "listed": listed, "orphans": [u for u in listed if norm(u) not in depth],
        "missing": [u for u in depth if u not in listed_keys], "codes": codes, "bad": bad,
    }

def text(a):
    print(f"Crawled {a['fetched']} pages ({'whole site' if a['complete'] else 'stopped at cap'}), sitemap lists {len(a['listed'])} URLs\n")
    print("Click depth from homepage:")
    for d, n in sorted(Counter(min(v, 5) for v in a["depth"].values()).items()):
        print(f"  {d if d < 5 else '5+'} clicks: {n} pages")
    print(f"\nTemplate links (on 90%+ of pages): {len(a['template'])}")
    print("Most linked pages, template links excluded:")
    for u, n in [x for x in a["inbound"].most_common() if x[0] not in a["template"]][:5]:
        print(f"  {n:>4}  {u}")
    print(f"\nSitemap URLs not reached by internal links: {len(a['orphans'])}" + ("" if a["complete"] else " (crawl hit the cap; some may just be deeper)"))
    for u in a["orphans"][:10]:
        print("   ", u)
    print(f"\nLinked pages missing from the sitemap: {len(a['missing'])}")
    for u in a["missing"][:5]:
        print("   ", u)
    print(f"\nSitemap hygiene (first {min(50, len(a['listed']))} URLs): {dict(a['codes'])}")
    for code, u in a["bad"][:10]:
        print(f"    {code}  {u}")

def report(a):
    n = len(a["depth"])
    deep = [u for u, d in a["depth"].items() if d > 3]
    hist = Counter(min(v, 5) for v in a["depth"].values())
    out = [f"# Website Structure Audit: {urlsplit(a['home']).netloc} ({datetime.date.today()})", "",
           "## Summary",
           f"- Pages reached by links: {n} | In sitemap: {len(a['listed'])} | Crawl complete: {'yes' if a['complete'] else 'no (hit cap)'}",
           f"- Pages deeper than 3 clicks: {len(deep)} ({100 * len(deep) / max(n, 1):.0f}%)",
           f"- Orphan candidates: {len(a['orphans'])} | Sitemap URLs not returning 200: {len(a['bad'])} of {sum(a['codes'].values())} checked",
           "", "## Click depth", "| Depth | Pages |", "|---:|---:|"]
    out += [f"| {d if d < 5 else '5+'} | {c} |" for d, c in sorted(hist.items())]
    out += ["", "## Orphan candidates", "| URL | Action: link / merge / remove |", "|---|---|"]
    out += [f"| {u} | |" for u in a["orphans"][:25]] or ["| none | |"]
    out += ["", "## Internal link distribution",
            f"Template links (on 90%+ of pages, e.g. header and footer): {len(a['template'])}", "",
            "| Page (template links excluded, top 10) | Inbound internal links |", "|---|---:|"]
    out += [f"| {u} | {c} |" for u, c in [x for x in a["inbound"].most_common() if x[0] not in a["template"]][:10]]
    weak = sorted((c, u) for u, c in a["inbound"].items() if u not in a["template"] and a["depth"].get(u, 0) > 0)[:5]
    out += ["", "| Weakest linked pages | Inbound internal links |", "|---|---:|"]
    out += [f"| {u} | {c} |" for c, u in weak]
    out += ["", "## Sitemap issues", "| URL | Status |", "|---|---|"]
    out += [f"| {u} | {c} |" for c, u in a["bad"][:25]] or ["| none | |"]
    out += ["", "## Recommendations (ordered)", "1. ", ""]
    print("\n".join(out))

if __name__ == "__main__":
    args = [x for x in sys.argv[1:] if x != "--report"]
    if not args:
        sys.exit(__doc__)
    result = audit(args[0], int(args[1]) if len(args) > 1 else 500)
    report(result) if "--report" in sys.argv else text(result)

We ran it on bugviso.com on 25 October 2026 (python3 structure_audit.py https://bugviso.com/ 500 --report).

It took 3 minutes 19 seconds for 289 pages. This is the unedited report, with the recommendations filled in by hand:

markdown
# Website Structure Audit: bugviso.com (2026-10-25)

## Summary
- Pages reached by links: 289 | In sitemap: 279 | Crawl complete: yes
- Pages deeper than 3 clicks: 0 (0%)
- Orphan candidates: 0 | Sitemap URLs not returning 200: 0 of 50 checked

## Click depth
| Depth | Pages |
|---:|---:|
| 0 | 1 |
| 1 | 23 |
| 2 | 265 |

## Orphan candidates
| URL | Action: link / merge / remove |
|---|---|
| none | |

## Internal link distribution
Template links (on 90%+ of pages, e.g. header and footer): 23

| Page (template links excluded, top 10) | Inbound internal links |
|---|---:|
| https://bugviso.com/blog/what-is-generative-engine-optimization-geo-guide | 31 |
| https://bugviso.com/blog/redirect-chains-and-loops-find-fix | 22 |
| https://bugviso.com/blog/why-run-site-audit-on-a-schedule | 21 |
| https://bugviso.com/blog/orphan-pages-seo-find-fix | 20 |
| https://bugviso.com/blog/ai-search-citation-sources | 19 |
| https://bugviso.com/blog/crawl-budget-explained-stop-wasting-googlebot | 19 |
| https://bugviso.com/blog/how-to-check-ai-crawler-access-robots-txt | 19 |
| https://bugviso.com/blog/canonical-tags-how-to-avoid-duplicate-content | 18 |
| https://bugviso.com/blog/how-to-reduce-ttfb-time-to-first-byte | 17 |
| https://bugviso.com/blog/website-accessibility-statistics-2026 | 17 |

| Weakest linked pages | Inbound internal links |
|---|---:|
| https://bugviso.com/blog/10-signs-your-website-needs-an-audit-right-now | 1 |
| https://bugviso.com/blog/applebot-apple-intelligence-siri-seo | 1 |
| https://bugviso.com/blog/claudebot-optimization-technical-documentation | 1 |
| https://bugviso.com/blog/dynamic-llms-txt-generator-nextjs-tutorial | 1 |
| https://bugviso.com/blog/edge-ssr-streaming-html-ttfb | 1 |

## Sitemap issues
| URL | Status |
|---|---|
| none | |

## Recommendations (ordered)
1. Add contextual links to the 5 weakest posts from related posts in the same cluster.
2. Keep the footer at 23 template links; no new sitewide links.

Two things in this report are worth copying for your own audits.

First, the template-link split. Without it, the top ten "most linked" pages were all header and footer links: contact, terms, privacy, login and the homepage, each linked from 279–288 of 289 pages.

That says nothing about structure. With the 23 template links excluded, the real contextual hubs appear (a GEO guide with 31 inbound links), and so do the weakest posts, each with a single inbound link.

Second, a clean result is a result. Zero orphans, nothing deeper than 2 clicks and a sitemap with no redirects are worth stating in the summary, because the next audit will be compared against them.


What Goes in a Website Structure Audit Report

A website structure audit report should let someone who didn't run the crawl decide what to fix first.

That means numbers in the summary, one table per check, and recommendations ordered by impact, not by the order the checks ran. The table lists each section.

Report sectionWhat it must showPriority when it's bad
SummaryPages reached, pages in the sitemap, whether the crawl finished, deep pages, orphans, sitemap errorsSets the scope; flag an unfinished crawl first
Click depthPages per depth level, with important pages at depth 4+ namedHigh for money pages, low for archives
Orphan candidatesEach URL with traffic and a decision: link, merge or removeHigh if the page has traffic or backlinks
Internal link distributionTemplate link count, contextual leaders and the weakest pagesMedium: fix by adding links from related pages
Sitemap issuesURLs that redirect, 404 or are noindexHigh: these are signals pointing at the wrong URLs
Recommendations3–7 actions, ordered, each with an owner

If you'd rather fill it in by hand, this is the empty template the script's --report output follows:

markdown
# Website Structure Audit: {site} ({date})

## Summary
- Pages reached by links: {n} | In sitemap: {n} | Crawl complete: {yes/no}
- Pages deeper than 3 clicks: {n} ({%})
- Orphan candidates: {n} | Sitemap URLs not returning 200: {n}

## Click depth
| Depth | Pages | Important pages at this depth |
|---|---|---|

## Orphan candidates
| URL | In sitemap | Traffic (last 3 months) | Action: link / merge / remove |
|---|---|---|---|

## Internal link distribution
Template links (on 90%+ of pages): {n}
| Page (template links excluded) | Inbound internal links | Should it be higher or lower? |
|---|---|---|

## Sitemap issues
| URL | Status | Fix |
|---|---|---|

## Recommendations (ordered)
1. ...

For client-facing versions, put the summary and recommendations on the first page and the tables after. Our guide to the anatomy of a website audit report covers layout for the full audit.


How BugViso Audits Site Structure

A BugViso audit crawls your site and renders pages that need JavaScript in a headless browser, so links injected by JavaScript are followed too, then builds an internal link graph from every crawled page. It reports:

  • Orphan pages with no inbound internal links among the crawled pages (marked as unconfirmed when the crawl stopped before covering the whole site).
  • Click depth from the homepage, flagging pages three or more clicks deep.
  • Pages with excessive outbound links.
  • The most internally linked pages, so you can see where link equity concentrates.

Confirmed orphans cost points in the health score (2 per orphan, capped at 8), alongside broken links, redirects and canonical problems found in the same crawl.

The internal link graph and orphan page checks page lists every rule.

The difference from the script above: links injected by JavaScript count, and the crawl is seeded from the sitemap as well, so pages only the sitemap knows about are crawled and checked for inbound links.


Common Structure Audit Mistakes

The most common structure audit mistake is seeding the crawl from the sitemap, which hides orphan pages. Five mistakes to avoid:

  • Seeding the crawl from the sitemap. Every sitemap URL then looks linked, and orphans disappear.
  • Auditing the rendered DOM only. Links that need JavaScript are invisible to many crawlers. Compare raw and rendered.
  • Counting footer links as structure. A link from every page's footer says little about topical relationships. On our own site, the 23 template links made every raw "most linked" ranking useless until we excluded them.
  • Ignoring pagination. Deep pagination pushes old content far from the homepage; add category hubs or "related posts" links.
  • Leaving redirects in the sitemap. One in four sitemaps we sampled listed redirecting URLs.

FAQ

What is a website structure audit?

A review of how a site's pages are organised and linked: click depth, orphan pages, internal link distribution, URL hierarchy, navigation and sitemap accuracy.

What is a good click depth for SEO?

Keep important pages within three clicks of the homepage. Deeper pages are crawled less often and usually receive fewer internal links.

How do I find orphan pages?

Crawl the site by following links from the homepage, then compare the pages you reached with your sitemap and analytics landing pages. URLs that appear in the sitemap or analytics but not in the crawl are orphans.

What should a website structure audit report include?

Pages crawled, click-depth distribution, orphan candidates with recommended actions, internal link distribution, sitemap issues and an ordered list of fixes. The template above covers each.

How often should I audit site structure?

After every redesign, migration or navigation change, and at least twice a year for sites that publish regularly.

Structure is the subject of Phase 5 in the step-by-step on-page SEO checklist. To fix what the audit finds, see click depth and SEO and how to find orphan pages, and for planning the structure up front, the topical authority map.


The Takeaway

Structure decides which of your pages crawlers find and value, and a BugViso crawl maps click depth and orphan pages across your site in one pass.

Written by

· BugViso Team

Kazi writes BugViso’s guides on website audits, Core Web Vitals, technical SEO, accessibility and AI search. The data in them comes from audits BugViso runs in a real Chromium browser, including our 219-site study of website health.

Found this useful? Share it.

Summarise with AI

Open this guide in your assistant.

Follow BugViso

New guides and audit data as we publish them.

AI visibility tracker

Is your brand in AI answers?

See how often AI assistants mention you, cite your site and rank you against your competitors.

  • ChatGPT
  • Gemini
  • Perplexity
  • Claude
  • AI Overviews
See how it works

See where your site stands

Run a free BugViso audit for SEO, speed, accessibility and AI search readiness — with fixes you can ship today.