Skip to Content

Canonical URL not present in the XML sitemap

What Is This Issue

This issue checks whether the canonical URL declared on a page exactly matches the URL for that page listed in the XML sitemap, ensuring consistency between these two important signals.

A passing implementation means:

  • The <link rel="canonical" href="..."> tag on the page specifies the exact same URL as the <loc> element in the sitemap
  • No discrepancies in protocol (http vs https), www vs non-www, trailing slash, or query parameters
  • Both signals point to the same preferred version of the URL

Example:

  • Sitemap entry: <loc>https://example.com/products/shoes</loc>
  • Canonical tag: <link rel="canonical" href="https://example.com/products/shoes">
  • ✅ Match - Issue passes

Example of mismatch:

  • Sitemap entry: <loc>https://example.com/products/shoes</loc>
  • Canonical tag: <link rel="canonical" href="https://www.example.com/products/shoes">
  • ❌ Mismatch - Issue fails

Why Is This Important

Google’s Canonical Selection: When the canonical tag and sitemap URL don’t match, Google may choose a different canonical than intended, potentially indexing the wrong version of the page.

Mixed Signals: Search engines receive conflicting information about which URL is the preferred version, leading to confusion and potential indexing issues.

Crawl Budget Waste: If search engines try to reconcile the mismatch, they may spend unnecessary resources crawling multiple versions.

Link Equity Consolidation: Inconsistent canonicals prevent proper consolidation of ranking signals to the intended URL.

SEO Health Score: Resolving this issue improves the technical SEO score by ensuring consistent canonical signals across sitemap and on-page elements.

How XeoPix Detects This

XeoPix performs the following checks:

  1. Parses the XML sitemap - The crawler reads the sitemap and extracts all <loc> URLs.

  2. Crawls each URL - For each URL in the sitemap, XeoPix fetches the page and extracts the canonical URL from the <link rel="canonical"> tag.

  3. Normalizes URLs - Both the sitemap URL and canonical URL are normalized (lowercased, protocol standardized, trailing slash normalized) for comparison.

  4. Compares URLs - XeoPix checks if the sitemap URL and canonical URL match exactly after normalization.

  5. Reports discrepancies - If mismatches are found, the issue is flagged and the specific discrepancies are reported (e.g., “sitemap has non-www but canonical has www”).

How To Fix

  1. Audit current state - Compare the canonical tags on your pages with the URLs listed in your XML sitemap.

  2. Standardize your preferred URL format - Decide on the canonical URL format considering:

    • Protocol (always https)
    • www vs non-www (be consistent)
    • Trailing slashes (be consistent)
    • Query parameters (usually stripped)
  3. Update canonical tags - Ensure all canonical tags use the exact preferred URL format.

  4. Update XML sitemap - Ensure all URLs in the sitemap match the canonical URL format exactly.

  5. Check for dynamic generation - If canonicals or sitemaps are generated dynamically, ensure the logic produces identical URLs.

  6. Validate with tools - Use Google Search Console’s URL Inspection tool to verify Google’s selected canonical matches your intended canonical.

What We Store

Storage Level

Page Level — This issue is evaluated for each individual page.


Database Table / Prisma Model

PageSeoBasicsData


Stored Fields

FieldTypeDescription
canonicalUrlString?The canonical URL specified in the page
canonicalMatchesSitemapBoolean?Whether the canonical URL is found in the sitemap

Detection Dependencies

  • The following data sources are required to evaluate this issue:
  • HTML Document — The crawler extracts the canonical URL from <link rel="canonical"> tag
  • XML Sitemap — The crawler checks if the canonical URL appears in any sitemap
  • HTTP Response — The page content is analyzed for canonical link element

Examples

Example 1: Protocol Mismatch

Problematic State (Fails):

  • Sitemap: <loc>http://example.com/page</loc>
  • Canonical: <link rel="canonical" href="https://example.com/page">

Corrected State (Passes):

  • Sitemap: <loc>https://example.com/page</loc>
  • Canonical: <link rel="canonical" href="https://example.com/page">

Example 2: WWW vs Non-WWW Mismatch

Problematic State (Fails):

  • Sitemap: <loc>https://example.com/page</loc>
  • Canonical: <link rel="canonical" href="https://www.example.com/page">

Corrected State (Passes):

  • Sitemap: <loc>https://www.example.com/page</loc>
  • Canonical: <link rel="canonical" href="https://www.example.com/page">

Example 3: Trailing Slash Mismatch

Problematic State (Fails):

  • Sitemap: <loc>https://example.com/products</loc>
  • Canonical: <link rel="canonical" href="https://example.com/products/">

Corrected State (Passes):

  • Sitemap: <loc>https://example.com/products/</loc>
  • Canonical: <link rel="canonical" href="https://example.com/products/">

References

Last updated on