Skip to Content

Canonical tag not pointing at the page itself

What Is This Issue

This issue checks whether every indexable page on your website includes a self-referencing canonical tag that points to its own preferred URL.

A self-referencing canonical tag tells search engines “this page is the preferred version of itself.” For this check to pass:

  • Every indexable page must have a canonical tag
  • The canonical URL should point to the same page (self-reference), not to a different page
  • The canonical URL should match the preferred URL format for that page

Example: If your page’s preferred URL is https://example.com/blog/post, the canonical tag should be <link rel="canonical" href="https://example.com/blog/post">.

Why Is This Important

Self-referencing canonicals are important for:

  • Indexability: They explicitly tell search engines which URL should be indexed for each page
  • Duplicate content: They prevent search engines from choosing a different canonical when similar or duplicate pages exist
  • Rankings: They consolidate ranking signals to the preferred URL, even when other URL variants exist

When pages don’t have self-referencing canonicals, search engines may:

  • Choose a different URL as canonical (e.g., with tracking parameters, different casing, or trailing slash variants)
  • Split ranking signals across multiple URL variants
  • Have difficulty determining the preferred version of a page

Resolving this issue improves your SEO health score by ensuring each page clearly declares its preferred URL.

How XeoPix Detects This

XeoPix identifies missing or incorrect self-referencing canonicals through these steps:

  1. Fetches the page: XeoPix requests the URL and follows redirects to get the final URL.

  2. Extracts the canonical: The system parses the HTML and extracts the canonical URL from the <link rel="canonical"> tag.

  3. Normalizes URLs: XeoPix normalizes both the final URL and canonical URL by:

    • Standardizing protocol and host casing
    • Handling trailing slashes consistently
    • Resolving relative URLs to absolute URLs
  4. Compares URLs: The system checks whether the canonical URL matches the final URL after normalization.

  5. Flags issues: XeoPix triggers warnings when:

    • A page doesn’t have a canonical tag
    • The canonical points to a different URL (not self-referencing)
    • There’s a URL normalization mismatch between the page and its canonical

The detection uses only HTTP response data and raw HTML—no JavaScript execution is used.

How To Fix

  1. Audit your pages: Crawl your website to identify pages missing canonical tags or with canonicals pointing to different URLs.

  2. Add self-referencing canonicals: Add a canonical tag to every indexable page that points to that page’s own preferred URL.

  3. Use absolute URLs: Make sure canonical URLs are absolute (starting with https://) rather than relative.

  4. Be consistent: Ensure the canonical URL matches the page’s preferred format (protocol, trailing slash, casing, etc.).

  5. Update templates: Configure your CMS or framework to automatically generate self-referencing canonicals for every page.

  6. Avoid pointing to other pages: Unless the page is truly a duplicate, the canonical should point to itself, not to a different page.

  7. Test your changes: Recrawl your site to verify all indexable pages now have proper self-referencing canonical tags.

What We Store

Storage Level

Page Level


Database Table / Prisma Model

PageSeoBasicsData


Stored Fields

FieldTypeDescription
canonicalUrlString?The canonical URL of the page

Detection Dependencies

  • HTML Document
  • HTTP Response Headers

Examples

Example 1: Correct self-referencing canonical

Scenario: A page with a proper self-referencing canonical tag.

Passes because:

  • Page has a canonical tag
  • Canonical points to the same URL as the page itself
  • URL format is consistent
<!-- URL: https://example.com/blog/post --> <link rel="canonical" href="https://example.com/blog/post" />

Example 2: Missing canonical tag

Scenario: A page without any canonical tag.

Fails because:

  • No canonical tag is present
  • Search engines must guess the preferred URL
  • Other URL variants may be chosen as canonical
<!-- URL: https://example.com/blog/post --> <!-- No canonical tag present -->

Corrected version:

<link rel="canonical" href="https://example.com/blog/post" />

Example 3: Canonical pointing to different page

Scenario: A page with canonical pointing to a different URL.

Fails because:

  • Canonical points to a different page
  • This suggests the page is a duplicate of another
  • Not appropriate unless the page is truly a duplicate
<!-- URL: https://example.com/blog/post?utm_source=twitter --> <link rel="canonical" href="https://example.com/blog/post" />

Note: This is actually correct for tracking parameters. The issue would be if a unique page pointed to a different unique page.

Unit Test

Test File

__tests__/seo-audit-checks/pageSeoBasics/issue-174-self-referencing-canonical.test.js

Purpose

Validates that the SEO audit correctly detects pages where the canonical URL does not point to the same page URL (i.e., the canonical is not self-referencing).

Tested Function

runPageSeoBasics() from toggleGroups/pageSeoBasics.js

Issue Information

  • Issue Number: 174
  • Issue Code: SELF_REFERENCING_CANONICAL (self_referencing_canonical)
  • Toggle Group: pageSeoBasics

Test Scenarios

Positive Test Cases

  1. Canonical matches page URL — Canonical URL matches the page URL. No issue should be reported.
  2. No canonical tag — Page has no <link rel="canonical"> tag. No issue should be reported.
  3. URL normalization (trailing slash) — Page URL has a trailing slash and canonical does not (or vice versa). After normalization, no issue should be reported.

Negative Test Cases

  1. Canonical points to different URL — Canonical URL points to a different page. The issue should be reported with message 'Canonical tag is not self-referencing.'.
  2. Different protocol — Canonical uses http:// while page uses https://. The issue should be reported.
  3. Different case — Canonical URL has different casing than the page URL (e.g., /Page vs /page). The issue should be reported.
  4. Relative canonical URL — Canonical uses a relative URL (/page) that doesn’t match the absolute page URL. The issue should be reported.

Boundary Cases

None.

Edge Cases

  1. URL normalization — Trailing slash differences are handled by URL normalization and should not trigger the issue.
  2. Different protocol — Protocol mismatch is detected as non-self-referencing.
  3. Different case — Case-sensitive comparison detects casing differences.
  4. Relative canonical URL — Relative URLs are resolved and compared against the absolute page URL.
  5. Invalid page URL — The function handles invalid URLs without crashing.

Expected Outcome

Pass

The issue is not reported when the canonical URL matches the page URL after normalization, or when no canonical tag exists.

Fail

The issue is reported when the canonical URL does not match the page URL after normalization.

Validation

  • Verifies correct issue detection for non-self-referencing canonical URLs
  • Verifies no issue is reported when canonical matches page URL
  • Verifies no issue is reported when no canonical tag exists
  • Verifies URL normalization handles trailing slashes correctly
  • Verifies protocol mismatches are detected
  • Verifies case sensitivity differences are detected
  • Verifies relative canonical URLs are handled
  • Verifies invalid URLs do not cause crashes
  • toggleGroups/pageSeoBasics.js
  • issueCodes.js
  • utils/issues.js
  • utils/cheerio.js (for normalizeUrl)

Coverage Summary

  • Covers self-referencing canonical (pass)
  • Covers no canonical tag (pass)
  • Covers trailing slash normalization (pass)
  • Covers different URL canonical (fail)
  • Covers different protocol canonical (fail)
  • Covers different case canonical (fail)
  • Covers relative canonical URL (fail)
  • Covers invalid URL error handling (no crash)

References

Last updated on