Skip to Content

No sitemap link in the page head

What Is This Issue

This issue checks whether your web pages include a <link rel="sitemap"> tag in the HTML head section that points to your XML sitemap location.

A passing implementation includes a link tag in the <head> section that explicitly declares the location of your XML sitemap:

Example of correct implementation:

<link rel="sitemap" type="application/xml" href="/sitemap.xml" />

This tag helps search engines and other crawlers discover your sitemap directly from the HTML source, providing an additional method of sitemap discovery beyond the traditional /sitemap.xml URL and the Sitemap: directive in robots.txt.

Why Is This Important

Including a <link rel="sitemap"> tag in your HTML head provides several SEO benefits:

  • Enhanced discoverability: While most search engines check for /sitemap.xml automatically, the link tag provides an explicit signal about your sitemap location, ensuring it’s found even if standard methods fail.

  • Crawler efficiency: Some crawlers and SEO tools check the HTML head for sitemap references, which can speed up the discovery process.

  • Multiple discovery paths: Having your sitemap discoverable through multiple methods (direct URL, robots.txt, and HTML head) creates redundancy and increases the likelihood that all search engines will find it.

  • Comprehensive SEO: This is a relatively simple addition that demonstrates attention to technical SEO detail, contributing to a well-optimized website.

While this is not a critical issue (search engines will typically find your sitemap through other methods), implementing it shows technical SEO maturity and can help ensure complete indexation of your site.

Resolving this issue improves your SEO health score by demonstrating comprehensive technical optimization and providing additional pathways for search engines to discover your content.

How XeoPix Detects This

XeoPix performs the following checks to detect this issue:

  1. HTML parsing: The crawler extracts the <head> section from the page’s HTML content.

  2. Link tag search: It looks for a <link> tag with the attribute rel="sitemap".

  3. Attribute validation: If the tag is found, XeoPix checks for:

    • The presence of an href attribute (should point to the sitemap URL)
    • The optional type="application/xml" attribute (recommended for clarity)
  4. Pass/Fail determination:

    • Passes: If a <link rel="sitemap"> tag is present in the HTML head section with a valid href attribute
    • Fails: If no <link rel="sitemap"> tag is found in the HTML head

The detection is straightforward: the crawler simply checks for the existence of this specific link tag in the head section. It does not validate whether the sitemap file actually exists at the specified location (that would be a separate check).

How To Fix

Follow these steps to add the sitemap link tag to your HTML:

  1. Identify your sitemap URL: Determine the correct path to your XML sitemap (typically /sitemap.xml or /sitemap_index.xml).

  2. Add the link tag to your HTML head: Place the following line inside the <head> section of your HTML document:

    <link rel="sitemap" type="application/xml" href="/sitemap.xml" />
  3. Adjust the href value if needed: If your sitemap is located at a different path, update the href attribute accordingly:

    <link rel="sitemap" type="application/xml" href="/path/to/your/sitemap.xml" />
  4. For multiple sitemaps: If you have multiple sitemaps, you can include multiple link tags:

    <link rel="sitemap" type="application/xml" href="/sitemap-pages.xml" /> <link rel="sitemap" type="application/xml" href="/sitemap-images.xml" />
  5. Verify implementation: Use View Page Source or browser developer tools to confirm the tag appears correctly in the rendered HTML.

Note: This tag should be present on all pages of your website for consistency, though it’s most important on the homepage.

What We Store

Storage Level

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


Database Table / Prisma Model

PageHtmlHeadAudit


Stored Fields

FieldTypeDescription
sitemapLinkUrlString?The URL found in the sitemap link tag

Detection Dependencies

  • The following data sources are required to evaluate this issue:
  • HTML Document — The crawler parses the HTML head section to find the sitemap link tag
  • Link Tag Extraction — The <link rel="sitemap"> tag is extracted

Examples

Example 1: Correct Implementation

Scenario: A properly configured page with sitemap link tag.

Correct State (Passes):

<head> <meta charset="UTF-8" /> <meta name="viewport" content="width=device-width, initial-scale=1" /> <link rel="sitemap" type="application/xml" href="/sitemap.xml" /> <title>Page Title</title> </head>

Scenario: Page has no sitemap link tag in the head.

Problematic State (Fails):

<head> <meta charset="UTF-8" /> <meta name="viewport" content="width=device-width, initial-scale=1" /> <title>Page Title</title> </head>

Why it fails: Search engines and crawlers won’t discover the sitemap through this HTML discovery method.

Corrected State (Passes):

<head> <meta charset="UTF-8" /> <meta name="viewport" content="width=device-width, initial-scale=1" /> <link rel="sitemap" type="application/xml" href="/sitemap.xml" /> <title>Page Title</title> </head>

Example 3: Multiple Sitemaps

Scenario: Site has multiple sitemaps for different content types.

Correct State (Passes):

<head> <link rel="sitemap" type="application/xml" href="/sitemap-pages.xml" /> <link rel="sitemap" type="application/xml" href="/sitemap-images.xml" /> <link rel="sitemap" type="application/xml" href="/sitemap-videos.xml" /> <title>Page Title</title> </head>

Example 4: Sitemap at Non-Standard Location

Scenario: Sitemap is located at a non-standard path.

Correct State (Passes):

<head> <link rel="sitemap" type="application/xml" href="/feeds/sitemap.xml" /> <title>Page Title</title> </head>

Note: The href attribute should point to the actual location of your sitemap file.

Scenario: Sitemap link is most important on the homepage.

Correct State (Passes):

<!-- Homepage (https://example.com/) --> <head> <meta charset="UTF-8" /> <meta name="viewport" content="width=device-width, initial-scale=1" /> <link rel="sitemap" type="application/xml" href="/sitemap.xml" /> <title>Home - Example Site</title> </head>

Note: While it’s best to include the sitemap link on all pages, it’s most critical on the homepage since that’s often the first page crawled.

Unit Test

Test File

__tests__/seo-audit-checks/htmlHeadTags/issue-130-link-rel-sitemap.test.js

Purpose

Validates the detection of missing or incorrectly configured <link rel="sitemap"> tags in the HTML <head>. Ensures pages are flagged when the sitemap link is missing, the type attribute is missing, or the type is not application/xml.

Tested Function

runHtmlHeadTags() from toggleGroups/htmlHeadTags.js

Issue Information

  • Issue Number: 130
  • Issue Code: LINK_REL_SITEMAP
  • Toggle Group: htmlHeadTags

Test Scenarios

Positive Test Cases

  • Page has <link rel="sitemap" type="application/xml" href="https://example.com/sitemap.xml"> — no issue reported
  • Page has <link rel="sitemap" type="application/xml" href=""> (empty href but tag present) — no issue reported
  • Multiple sitemap links where the first one has the correct type — no issue reported
  • Malformed HTML with a valid sitemap link — no issue reported, no crash

Negative Test Cases

  • Page has no sitemap link tag — issue reported with message "Link rel=\"sitemap\" tag is missing."
  • Sitemap link is present but type attribute is missing — issue reported with message "Sitemap link type should be \"application/xml\"." and sitemapType: null
  • Sitemap link has incorrect type (text/xml instead of application/xml) — issue reported with sitemapType: "text/xml"

Boundary Cases

None present.

Edge Cases

  • Empty HTML (<html></html>): issue reported (sitemap link is missing)
  • Malformed HTML: function handles without crashing; correctly detects sitemap when present
  • Empty href: href="" is accepted as present
  • Multiple sitemap links: only the first link’s type is checked
  • Case sensitivity: type APPLICATION/XML (uppercase) is not accepted as valid

Expected Outcome

Pass

The issue should be reported when:

  • The <link rel="sitemap"> tag is completely absent
  • The tag exists but lacks a type attribute
  • The tag exists but the type attribute is not application/xml (case-sensitive)

Fail

The issue should not be reported when:

  • <link rel="sitemap" type="application/xml"> is present (any href value)
  • Multiple sitemap links exist and the first one has the correct type

Validation

  • Correct detection of missing sitemap link tag
  • Correct detection of missing type attribute
  • Correct detection of incorrect type value
  • Case-sensitive type comparison (uppercase APPLICATION/XML is flagged)
  • Multiple sitemap link handling (first link is used)
  • Graceful handling of malformed HTML
  • Cache mechanism prevents duplicate issue entries on repeated calls
  • toggleGroups/htmlHeadTags.js
  • issueCodes.js

Coverage Summary

  • Positive cases: 3 (correct type, empty href, multiple links first valid)
  • Negative cases: 3 (missing tag, missing type, wrong type)
  • Edge cases: 3 (empty HTML, malformed HTML, case sensitivity)
  • Cache validation: 1

References

Last updated on