Skip to main content
SlapMyWeb

SEO fix

How to Add an XML Sitemap

Publish a list of the URLs you want discovered, and tell search engines where it is.

Difficulty
Easy
Impact
Medium
Time
30 min

Before

GET /sitemap.xml -> 404

After

<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
  <url>
    <loc>https://example.com/</loc>
    <lastmod>2026-09-03</lastmod>
  </url>
</urlset>
Before and after code for: How to Add an XML Sitemap

A missing XML sitemap does not stop a site being indexed, but it removes the fastest route to discovery: which matters most for large sites and for pages few internal links point at. The sitemap should list only canonical, indexable URLs; including redirects or noindex pages weakens the signal it carries.

Why it matters

Around half of audited sites have no sitemap. It is also a diagnostic: Search Console reports how many submitted URLs were indexed, which is the clearest available answer to "is Google actually taking these pages".

How to fix it

  1. Generate it from real data

    Build the list from your actual published content so it cannot drift. A hand-maintained sitemap is out of date within a month.
  2. Include only indexable canonicals

    No redirects, no noindex pages, no parameter variants. Every entry should be a URL you want indexed exactly as written.
  3. Split it if it is large

    50,000 URLs or 50 MB per file. Beyond that use a sitemap index pointing at several files.
  4. Advertise and submit it

    Add a Sitemap: line to robots.txt and submit it in Search Console and Bing Webmaster Tools.

The code

Beforexml
GET /sitemap.xml -> 404
Afterxml
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
  <url>
    <loc>https://example.com/</loc>
    <lastmod>2026-09-03</lastmod>
  </url>
</urlset>

On your platform

WordPress

WordPress generates one at /wp-sitemap.xml; most SEO plugins replace it with their own. Do not leave both live.

Next.js

app/sitemap.ts generates it. Read the URL list from your content source rather than hardcoding it.

Sources

Fixed that one.
Now find the rest.

A free audit ranks every issue on your site by the score points it costs, and links each one straight to its guide.

Run a free audit
Free foreverNo signupLive scan progress