Skip to content

fix: add xmlns:xhtml to sitemap#6920

Open
amosbastian wants to merge 1 commit intoTanStack:mainfrom
amosbastian:fix/create-sitemap-xmlns-xhtml
Open

fix: add xmlns:xhtml to sitemap#6920
amosbastian wants to merge 1 commit intoTanStack:mainfrom
amosbastian:fix/create-sitemap-xmlns-xhtml

Conversation

@amosbastian
Copy link

@amosbastian amosbastian commented Mar 13, 2026

Currently the generated sitemap will show an error if you try to validate it:

Namespace prefix xhtml on link is not defined

By adding

xmlns:xhtml="https://www.w3.org/1999/xhtml"

to the root of the sitemap it won't show any validation errors anymore

Summary by CodeRabbit

  • Bug Fixes
    • Fixed sitemap generation to include the XHTML namespace declaration, ensuring proper standards compliance for search engine indexing.

@changeset-bot
Copy link

changeset-bot bot commented Mar 13, 2026

⚠️ No Changeset found

Latest commit: 340e714

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 13, 2026

📝 Walkthrough

Walkthrough

This change adds the XHTML namespace declaration (xmlns:xhtml="http://www.w3.org/1999/xhtml") to the root sitemap element in the XML generation logic. It's a single-line modification that enhances XML namespace compliance without altering functional behavior.

Changes

Cohort / File(s) Summary
XHTML Namespace Addition
packages/start-plugin-core/src/build-sitemap.ts
Added XHTML namespace declaration to the urlset/sitemapindex root element in the generated sitemap XML to improve standards compliance.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

Poem

🐰 A whisker-twitch of XML delight,
Where namespaces shine ever so bright,
XHTML joins the sitemap dance,
With one little line—what a grand prance! 🌐

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately and concisely describes the main change: adding the xmlns:xhtml namespace declaration to the sitemap element to fix a validation error.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
📝 Coding Plan
  • Generate coding plan for human review comments

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Tip

CodeRabbit can approve the review once all CodeRabbit's comments are resolved.

Enable the reviews.request_changes_workflow setting to automatically approve the review once all CodeRabbit's comments are resolved.

@github-actions
Copy link
Contributor

Bundle Size Benchmarks

  • Commit: 79cd4d5afa22
  • Measured at: 2026-03-13T21:34:55.345Z
  • Baseline source: history:6069eba64369
  • Dashboard: bundle-size history
Scenario Current (gzip) Delta vs baseline Raw Brotli Trend
react-router.minimal 87.08 KiB 0 B (0.00%) 274.09 KiB 75.72 KiB ██████████▁
react-router.full 90.07 KiB 0 B (0.00%) 284.34 KiB 78.34 KiB ██████████▁
solid-router.minimal 36.42 KiB 0 B (0.00%) 109.29 KiB 32.74 KiB ▅▅▅▅▅▅▅▅▅▅▅
solid-router.full 40.75 KiB 0 B (0.00%) 122.27 KiB 36.58 KiB ▅▅▅▅▅▅▅▅▅▅▅
vue-router.minimal 52.29 KiB 0 B (0.00%) 149.34 KiB 47.01 KiB ▅▅▅▅▅▅▅▅▅▅▅
vue-router.full 57.08 KiB 0 B (0.00%) 164.85 KiB 51.27 KiB ▅▅▅▅▅▅▅▅▅▅▅
react-start.minimal 99.65 KiB 0 B (0.00%) 313.24 KiB 86.25 KiB ██████████▁
react-start.full 102.97 KiB 0 B (0.00%) 322.97 KiB 89.06 KiB ██████████▁
solid-start.minimal 48.75 KiB 0 B (0.00%) 146.89 KiB 43.14 KiB ▅▅▅▅▅▅▅▅▅▅▅
solid-start.full 54.21 KiB 0 B (0.00%) 162.75 KiB 47.88 KiB ▅▅▅▅▅▅▅▅▅▅▅

Trend sparkline is historical gzip bytes ending with this PR measurement; lower is better.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
packages/start-plugin-core/src/build-sitemap.ts (1)

202-209: ⚠️ Potential issue | 🟠 Major

The xhtml namespace fix is correct, but image: and news: namespaces are also missing.

The added xmlns:xhtml declaration properly resolves the reported validation error for xhtml:link elements. However, the code also uses image:image (line 98) and news:news (line 111) prefixes without declaring their namespaces, which will cause identical validation errors when those features are used.

🔧 Proposed fix to add all required namespace declarations
 function createXml(elementName: 'urlset' | 'sitemapindex'): XMLBuilder {
   return create({ version: '1.0', encoding: 'UTF-8' })
     .ele(elementName, {
       xmlns: 'https://www.sitemaps.org/schemas/sitemap/0.9',
       'xmlns:xhtml': 'http://www.w3.org/1999/xhtml',
+      'xmlns:image': 'http://www.google.com/schemas/sitemap-image/1.1',
+      'xmlns:news': 'http://www.google.com/schemas/sitemap-news/0.9',
     })
     .com(`This file was automatically generated by TanStack Start.`)
 }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/start-plugin-core/src/build-sitemap.ts` around lines 202 - 209, The
createXml function currently adds only xmlns and xmlns:xhtml but omits the image
and news namespaces used elsewhere; update the element attributes in createXml
(the ele call that takes elementName) to also include xmlns:image with
"http://www.google.com/schemas/sitemap-image/1.1" and xmlns:news with
"http://www.google.com/schemas/sitemap-news/0.9" so that image:image and
news:news prefixed elements validate correctly.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@packages/start-plugin-core/src/build-sitemap.ts`:
- Around line 202-209: The createXml function currently adds only xmlns and
xmlns:xhtml but omits the image and news namespaces used elsewhere; update the
element attributes in createXml (the ele call that takes elementName) to also
include xmlns:image with "http://www.google.com/schemas/sitemap-image/1.1" and
xmlns:news with "http://www.google.com/schemas/sitemap-news/0.9" so that
image:image and news:news prefixed elements validate correctly.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: f18b2fc0-f3a1-4e2f-af34-b1a44a4eb5ce

📥 Commits

Reviewing files that changed from the base of the PR and between 79cd4d5 and 340e714.

📒 Files selected for processing (1)
  • packages/start-plugin-core/src/build-sitemap.ts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant