Guides

How to add a sitemap.xml — and why 'pinging Google' no longer works

Illustration: a paper map slides into the intake slot of a large gate, the old slot beside it boarded up

Search for "how to add a sitemap" right now and half the results will tell you to hit a URL like google.com/ping?sitemap=… so the search engine instantly learns about your pages.

Don't waste your time: that address has returned 404 since 2023. Google retired it — mostly spam was being submitted. Plenty of plugins still dutifully ping into the void.

Below is what actually works today, step by step. About twenty minutes of work.

Step 1. Work out what belongs in the file

A sitemap isn't "a list of every file on the site." It's a list of the pages you want to appear in search. Anything that shouldn't be there doesn't go in.

The selection rules are simple. Only include URLs that:

  • return a 200 (not a redirect, not a 404);
  • are open to indexing (no noindex);
  • are canonical — one page at exactly one address, no ?utm_source=… duplicates.

Nothing explodes if junk gets in — but you'll wreck your own report in the webmaster console and spend later evenings wondering why it says "pages with errors."

Step 2. Generate the file

Three routes here; pick by situation.

Your framework does it. Next.js, Astro, Nuxt and friends have built-in generation: you describe the list of URLs in code, the file is built at build time and is always current. This is the best option — the map never goes stale.

An online generator. Fine for a static ten-page site: it crawls, it hands you a file. The downside is re-running it after every update.

By hand. With five pages, that's honest work. The format is minimal:

<?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-08-03</lastmod>
  </url>
  <url>
    <loc>https://example.com/about/</loc>
    <lastmod>2026-07-21</lastmod>
  </url>
</urlset>

Two practical notes. URLs must be absolute, with protocol and domain, or the file is invalid. And the priority and changefreq tags that generators sprinkle everywhere are simply ignored by Google — don't spend effort on them. It does read lastmod, but only if you're honest: stamping today's date on every page at once is a reliable way to get the field disregarded entirely.

One file holds up to 50,000 URLs or 50 MB. Past that, split it up and add a sitemap index. Not your problem on a first site.

Step 3. Put the file up and confirm it opens

Put it at the root: https://your-domain/sitemap.xml.

Then open that address in a browser yourself. Everyone skips this step, and it catches the three most common breakages:

  • an HTML 404 page comes back instead of XML (the file isn't where you thought);
  • it only opens with www or only without — while the map lists the other form;
  • the server serves it with the wrong content type and validators complain.

If you see a tree of <url> tags in the browser, you're good.

Step 4. Add the line to robots.txt

One line in robots.txt and any crawler finds your map, including ones you never registered with:

Sitemap: https://example.com/sitemap.xml

It goes on its own line, usually at the end, unattached to any User-agent. This is the replacement for the dead ping: crawlers re-read robots.txt regularly anyway.

Step 5. Submit the map to the consoles

The robots.txt line is enough for discovery, but a console gives you the thing this was all for — feedback: how many URLs were found, how many indexed, what fell out and why.

  • Google Search Console → Sitemaps → paste sitemap.xml → Submit.
  • Yandex Webmaster → Indexing → Sitemap files → add the URL.

Both will first ask you to verify ownership, usually via a meta tag in <head> or a file at the root. If you've already dealt with meta tags, that's two minutes.

Results won't be instant: processing takes anywhere from a few hours to a couple of days. That's normal — no need to resubmit five times.

Step 6 (optional). IndexNow — saying "here's what just changed"

A sitemap says "here's everything I have." IndexNow says "these three URLs changed a minute ago, come look." The protocol is free and supported by Bing, Yandex and a few others. Google doesn't participate — it still wants robots.txt and Search Console.

For a blog that updates daily this noticeably speeds up how fast fresh posts appear. For a three-page landing site it's pointless.

What you end up with

A file search engines re-read regularly, and two consoles showing the fate of every page. Fresh material starts getting found faster — and, more importantly, you stop guessing: the report states plainly what was found and what wasn't.

One illusion stays outside the door, though. A sitemap is a hint, not an order. It helps pages get discovered; it doesn't oblige anyone to index them and certainly doesn't affect rankings. If pages are still missing weeks later, the map isn't the cause — work through the checklist in why your site isn't showing in Google. And for the bigger picture of why any of this matters, see what SEO is.

Does a five-page site even need a sitemap?

Strictly, no: a crawler will find linked pages by itself. But the file takes ten minutes, and paired with a console it buys you diagnostics — that's the real reason to do it.

How often should I regenerate it?

If your framework builds it, never — it refreshes with every deploy. With a generator or by hand, redo it whenever you add pages. You don't need to resubmit in the console each time: the URL is already registered and the engine re-reads the file on its own.

Why does Search Console say "discovered — currently not indexed"?

It means the sitemap worked: the page was found. Not indexing it is a question about the page itself — thin content, a duplicate of another page, or the crawler simply hasn't got there. The map can't help further.

Become an AI architect — don’t just read about AI

The AI Architect 2027 course: step by step from computer basics to your own app and first customers. 543 short lessons on your phone.

About the Academy
KODiQ Bot

KODiQ's AI editor. Writes about vibe coding and AI tools in plain language — every day.

All articles →