Prompt
I’m building a tool to detect broken canonicals and redirects, what data do I need?
Latest observation
Oct 23, 2026
OpenAI APIWeb search: off
To detect broken canonicals and redirects reliably, you’ll want to collect a mix of URL-level, HTTP-level, HTML-level, and graph/state data.
1) Core URL inventory
You need a canonical list of URLs you intend to audit.
Include:
urlstatusof discovery source (sitemap, crawl, CMS export, analytics, etc.)type(HTML, PDF, image, etc.)last_seenpriority/importance
Why: you need a starting set to test against, and a way to compare intended URLs vs actual reachable URLs.
2) HTTP response data
For every URL you fetch, store:
requested_urlfinal_urlafter redirectsredirect_chain(each hop with status code and location)status_codecontent_typeresponse_headersresponse_timefetch_timestamp
Why:
- Broken redirects often show up as 3xx chains ending in 4xx/5xx
- Canonical targets may be redirecting unexpectedly
- You can detect redirect loops, long chains, and soft failures
3) HTML canonical data
For each HTML page, parse:
<link rel="canonical" href="...">- Whether it is:
- absolute or relative
- valid URL
- self-referential
- cross-domain
- Page source URL vs canonical target
Also store:
canonical_targetcanonical_presentbooleancanonical_parse_errors
Why:
- Broken canonical tags can point to 404s, redirects, non-canonical variants, or malformed URLs
4) Indexability / page directives
Store:
meta robotscontentX-Robots-Tagheaderrobots.txtcrawl allowance statusnoindex/nofollowflags
Why:
- A canonical target that is blocked or noindexed may indicate a conflicting setup
- Helps explain why a page is not behaving as expected
5) Redirect mapping data
Maintain a redirect graph:
source_urltarget_urlstatus_coderedirect_type(301, 302, 307, 308)hop_numberchain_id
And derived properties:
- loop detection
- chain length
- final destination
- whether target is canonicalized elsewhere
Why:
- You’ll need this to identify broken redirect rules, chains, loops, and non-final destinations
6) Canonical graph / cluster data
Build relationships between:
- page URL
- declared canonical
- final redirect destination
- preferred indexable URL
Useful fields:
cluster_idprimary_urlalternate_urlsconflict_reason
Why:
- The best bug detection comes from comparing multiple signals:
- canonical tag
- redirect destination
- sitemap URL
- actual indexed/preferred version
7) Crawl context
Store crawl metadata:
- user-agent used
- crawl depth
- source page
- referrer
- crawl date/time
- locale/device if relevant
Why:
- Some canonicals/redirects vary by user-agent, location, or device
- Useful for reproducing issues
8) Optional but very useful signals
If available, add:
- sitemap URLs and lastmod
- Google Search Console or indexing data
- server logs
- CMS canonical settings
- analytics landing page data
- hreflang mappings
Why:
- Helps distinguish “technically broken” from “strategically wrong”
Minimum viable dataset
If you want the smallest useful set, capture these fields:
For every URL:
urlstatus_codefinal_urlredirect_chaincontent_type
For HTML pages:
canonical_targetcanonical_presentmeta_robotsx_robots_tag
For analysis:
crawl_timestampsourceresponse_headers
Common issues you can detect with this data
- Canonical points to 404/500
- Canonical points to a redirecting URL
- Canonical points to a non-indexable page
- Self-canonical missing or malformed
- Redirect chain too long
- Redirect loop
- Mixed signals: page A canonicalizes to B, but B redirects back to A
- Canonical target differs from final redirect destination
- Canonical URL uses http vs https or www vs non-www inconsistently
Suggested data model
A practical schema could include tables like:
urlsfetchesredirect_hopscanonicalsrobots_directivesclusters
If you want, I can also give you:
- a database schema,
- a JSON structure, or
- a crawl pipeline design for this tool.