Skip to content

fix: ensure sitemap.xml emits a single XML declaration - #375

Open
fatima-Sami55 wants to merge 1 commit into
physicshub:mainfrom
fatima-Sami55:fix/sitemap-xml-declaration
Open

fix: ensure sitemap.xml emits a single XML declaration#375
fatima-Sami55 wants to merge 1 commit into
physicshub:mainfrom
fatima-Sami55:fix/sitemap-xml-declaration

Conversation

@fatima-Sami55

Copy link
Copy Markdown

Summary

  • Fixes the root cause of [Bug]: Google Search Console can't index sitemap.xml #107: live sitemap.xml still ships with a duplicated <?xml?> prolog, which Google Search Console rejects as invalid XML (browsers hide the problem).
  • Hardens scripts/sitemap-generator.js to strip any XML declarations, emit exactly one, require a leading <urlset>, and fail the build if that invariant breaks.
  • Regenerates public/sitemap.xml with a single declaration and refreshed lastmod dates.

Why this matters

Production currently returns:

<?xml version=1.0 encoding=UTF-8?>
<?xml version=1.0 encoding=UTF-8?>

This PR makes generation idempotent so a future prepend/format change cannot reintroduce the duplicate.

Test plan

  • Compared live vs local: live has 2 declarations, this branch has 1
  • Ran the same strip/emit logic against the live broken file → produces exactly one declaration and a valid <urlset>
  • Confirmed local sitemap has 32 <url> entries and closes </urlset>
  • After merge: run Release and Build (workflow_dispatch) so GitHub Pages picks up the new file
  • Resubmit sitemap.xml in Google Search Console and confirm it is no longer rejected

Fixes #107

Google Search Console rejects duplicated <?xml?> prologs that browsers still accept. Strip any declarations, emit exactly one, validate <urlset>, and fail the build if the invariant breaks.
@vercel

vercel Bot commented Jul 27, 2026

Copy link
Copy Markdown

@fatima-Sami55 is attempting to deploy a commit to the PhysicsHub's projects Team on Vercel.

A member of the Team first needs to authorize it.

@fatima-Sami55

Copy link
Copy Markdown
Author

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Google Search Console can't index sitemap.xml

1 participant