Skip to Content

AMP version not linked from the canonical page

What Is This Issue


What is this issue?

This issue checks whether pages that have an Accelerated Mobile Pages (AMP) counterpart declare a <link rel="amphtml"> tag in the canonical page <head> pointing to the AMP version.

A passing implementation requires:

  • A <link rel="amphtml"> tag in the canonical page head
  • The href attribute must be a fully qualified absolute URL (including scheme and domain)
  • The AMP page URL must return HTTP 200 status
  • The AMP page should also contain a corresponding <link rel="canonical"> tag pointing back to the canonical page

Example: If your canonical page is at https://example.com/article, and you have an AMP version at https://example.com/article/amp, you should declare an amphtml link tag on the canonical page pointing to the AMP version.

Why Is This Important


Why is this issue important?

The AMP HTML link tag is crucial for search engines to discover and serve AMP versions of web pages in applicable search contexts.

Impacts on SEO and mobile search visibility:

  • Search engine discovery: Google and other search engines use the <link rel="amphtml"> tag to discover AMP versions of pages. Without this tag, search engines may not find the AMP version during crawling, preventing it from appearing in AMP-eligible search results.

  • Mobile search performance: AMP pages can appear in special search features like the Top Stories carousel (for news publishers) and may display an AMP badge in search results. Missing the amphtml tag means losing these visibility opportunities.

  • Page experience signals: While AMP is not a direct ranking factor, AMP pages typically load faster on mobile devices, which can improve page experience metrics that do influence rankings.

  • Content freshness: The amphtml tag helps search engines understand the relationship between canonical and AMP versions, ensuring content freshness signals are properly attributed to the canonical page.

Resolving this issue improves the overall SEO health score by ensuring AMP pages are discoverable by search engines, which can lead to increased mobile search visibility, better page experience metrics, and potential inclusion in AMP-specific search features.

How XeoPix Detects This


How XeoPix detects this

XeoPix uses a straightforward detection process to identify AMP HTML link tag implementation:

  1. Fetch the page: XeoPix issues an HTTP GET request to the target URL and reads the raw HTML response without executing JavaScript.

  2. Scan for amphtml link tags: The crawler scans the <head> block for all <link> tags and searches for a tag where the rel attribute equals amphtml.

  3. Extract href value: For the matched tag, XeoPix extracts the href attribute value.

  4. Validate amphtml presence: The crawler checks whether a <link rel="amphtml"> tag exists in the page head and whether the href value is a valid non-empty URL.

  5. Check for absolute URL: XeoPix verifies whether the amphtml href is a fully qualified absolute URL (including scheme and domain), as Google requires absolute URLs for amphtml tags.

  6. Test AMP URL accessibility: XeoPix issues a secondary HTTP GET request to the AMP href URL and records the HTTP status code.

  7. Determine pass/fail: The issue passes if an amphtml link tag is present, the href is an absolute URL, and the AMP page URL returns HTTP 200. The issue fails if the tag is missing, the href is not an absolute URL, or the AMP page URL returns a non-2xx status code.

How To Fix


How to fix it

Add the AMP link tag to the canonical page <head> section:

<link rel="amphtml" href="https://example.com/article/?amp=1" />

Ensure the AMP page links back to the canonical:

<!-- On the AMP page --> <link rel="canonical" href="https://example.com/article/" />

Step-by-step recommendations:

  1. Verify AMP page exists: Confirm that the AMP version of the page actually exists and is accessible.

  2. Add the amphtml tag: Place the <link rel="amphtml"> tag in the <head> section of the canonical (non-AMP) page.

  3. Use absolute URLs: Ensure the href attribute is a fully qualified absolute URL including the scheme (https://) and domain. Google requires absolute URLs for amphtml tags.

  4. Add canonical back-reference: On the AMP page, ensure there’s a <link rel="canonical"> tag pointing back to the canonical page.

  5. Verify AMP page accessibility: Confirm the AMP page URL returns HTTP 200 when accessed directly.

  6. Check robots.txt: Ensure the AMP page URL is not blocked by Disallow rules in robots.txt, which would prevent search engines from crawling it.

  7. Remove if AMP no longer exists: If the AMP version has been removed or deprecated, remove the <link rel="amphtml"> tag from the canonical page entirely.

What We Store


What We Store

Storage Level

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


Database Table / Prisma Model

PageLinkRelTag


Stored Fields

FieldTypeDescription
ampHtmlUrlsJsonAMP HTML URLs found on the page

Detection Dependencies

  • The following data sources are required to evaluate this issue:
  • HTML Document — The crawler extracts the <link rel="amphtml"> tag from the HTML head

Examples


Examples

Scenario: A news article has both canonical and AMP versions properly linked.

Passes because:

  • A <link rel="amphtml"> tag is present in the canonical page head
  • The href attribute is a fully qualified absolute URL
  • The AMP page URL returns HTTP 200 status
  • The AMP page also has a corresponding <link rel="canonical"> tag
<!-- On the canonical page: https://example.com/article/ --> <head> <title>My Article</title> <link rel="canonical" href="https://example.com/article/" /> <link rel="amphtml" href="https://example.com/article/?amp=1" /> </head>

Example 2: Missing amphtml tag

Scenario: A page has an AMP version but the canonical page doesn’t declare the amphtml link tag.

Fails because:

  • No <link rel="amphtml"> tag is present on the canonical page
  • The AMP version exists at https://example.com/article/?amp=1
  • Search engines cannot discover the AMP version via the canonical page
<!-- On the canonical page --> <head> <title>My Article</title> <link rel="canonical" href="https://example.com/article/" /> <!-- Missing <link rel="amphtml"> tag --> </head>

Corrected version:

<head> <title>My Article</title> <link rel="canonical" href="https://example.com/article/" /> <link rel="amphtml" href="https://example.com/article/?amp=1" /> </head>

Example 3: Relative URL instead of absolute

Scenario: The amphtml tag uses a relative URL instead of an absolute URL.

Fails because:

  • The <link rel="amphtml"> tag is present
  • But the href attribute is a relative URL (/article/?amp=1)
  • The requirement is to use a fully qualified absolute URL (including scheme and domain)
<head> <title>My Article</title> <link rel="amphtml" href="/article/?amp=1" /> </head>

Corrected version:

<head> <title>My Article</title> <link rel="amphtml" href="https://example.com/article/?amp=1" /> </head>

Unit Test

Test File

xeopix-crawling-v2/__tests__/seo-audit-checks/linkRelTags/issue-134-link-rel-amphtml.test.js

Purpose

This unit test validates that the SEO audit correctly detects when an AMP page is missing the required <link rel="amphtml"> tag, or when a canonical page mentions an AMP version but lacks the amphtml link relation.

Tested Function

runLinkRelTags() from toggleGroups/linkRelTags

Issue Information

  • Issue Number: #134
  • Issue Code: LINK_REL_AMPHTML
  • Toggle Group: linkRelTags

Test Scenarios

Positive Test Cases

  • Should not detect issue when an AMP page has <link rel="amphtml"> in the <head>
  • Should not detect issue when a page is not an AMP page (no /amp path, ?amp param, or AMP mention in body)
  • Should not detect issue when a canonical page mentions AMP and has the amphtml link

Negative Test Cases

  • Should detect issue when an AMP page is missing the amphtml link relation — message: “AMP page is missing amphtml link relation”
  • Should detect issue when a canonical page mentions an AMP version but <link rel="amphtml"> is missing from <head> — message: “Canonical page mentions an AMP version but <link rel=“amphtml”> is missing from <head>”

Boundary Cases

None.

Edge Cases

  • AMP via /amp URL: A page with /amp in the URL path is detected as an AMP page
  • AMP via ?amp query: A page with ?amp in the URL query is detected as an AMP page
  • Case insensitive body text: Body text mentioning “AMP Version” (mixed case) triggers AMP detection
  • “Accelerated Mobile Pages” mention: Body text mentioning “accelerated mobile pages” triggers AMP detection
  • Empty body: Should handle gracefully without throwing — no issue detected

Expected Outcome

Pass

The issue should be reported (i.e., added to ctx.issues) when:

  • The page URL indicates it is an AMP page (contains /amp or ?amp) and the <link rel="amphtml"> is missing
  • The page body text mentions “AMP” or “accelerated mobile pages” and the <link rel="amphtml"> is missing

Fail

The issue should not be reported when:

  • The page has a valid <link rel="amphtml"> in the <head>
  • The page is not recognised as an AMP page (no AMP indicators in URL or body text)

Validation

  • Correct issue detection for AMP pages missing amphtml link
  • Correct issue detection for canonical pages mentioning AMP but missing amphtml link
  • No false positives for non-AMP pages
  • URL-based AMP detection (/amp path, ?amp query)
  • Body text scanning for “AMP” and “accelerated mobile pages” (case-insensitive)
  • Two distinct error messages depending on context (AMP page vs canonical page mentioning AMP)
  • Graceful handling of empty body
  • Payload validation: extracts ampHtmlUrls array with correct href values
  • xeopix-crawling-v2/toggleGroups/linkRelTags.js
  • xeopix-crawling-v2/issueCodes.js

Coverage Summary

  • Validates positive (AMP with link, non-AMP page, canonical with link), negative (AMP missing link, canonical mentioning AMP missing link), and edge cases (URL-based AMP detection, body text scanning, case-insensitive matching)
  • Covers both URL-based and content-based AMP detection strategies
  • Validates payload structure with correct URL resolution
  • Handles empty body gracefully without throwing

References

Last updated on