← Back to Index

XML Sitemap

FigureStructure of a Sitemap Index. It acts as a container for multiple sub-sitemaps (e.g., Posts, Products), keeping things organized.

What is an XML Sitemap?

Think of your website as a city. Googlebot is a tourist. Internal links are the streets. An XML Sitemap is the official map provided by the city planner. While the tourist might find everything by wandering around (following links), the map ensures they don't miss the new library built in the suburbs (your new blog post) or the isolated cul-de-sac (orphan pages).

Why it Matters for SEO

1. Faster Indexing

For new websites with few backlinks, a sitemap is the primary way Google discovers your pages. Without it, indexing can take weeks or months.

2. Deep Page Discovery

Complex sites (like e-commerce stores with 10,000 products) often have pages buried 5+ clicks deep. A sitemap flattens this hierarchy for the bot, giving instant access to every product URL.

3. Content Freshness

The <lastmod> tag in your sitemap tells Google exactly when a page was updated, encouraging them to re-crawl and update your ranking based on new content.

Code Implementation

A standard sitemap looks like this. It must be UTF-8 encoded.

xml
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
   <url>
      <loc>https://www.example.com/</loc>
      <lastmod>2024-03-20</lastmod>
      <changefreq>daily</changefreq>
      <priority>1.0</priority>
   </url>
   <url>
      <loc>https://www.example.com/blog/seo-guide</loc>
      <lastmod>2024-03-19</lastmod>
      <priority>0.8</priority>
   </url>
</urlset>

Common Pitfalls & How to Fix

The "Dirty" Sitemap

The Mistake: Including URLs that redirect (3xx), are broken (4xx), or blocked by robots.txt.

The Fix: A sitemap should only contain indexable, canonical, 200 OK status URLs. If you feed Google garbage, they may stop trusting your sitemap entirely.

Forgetting to Update

The Mistake: Manually creating a sitemap and forgetting to add new pages.

The Fix: Use a dynamic sitemap generator (plugins for WordPress, next-sitemap for Next.js) that updates automatically whenever content is published.

Size Limits

The Mistake: A single sitemap file exceeding 50,000 URLs or 50MB.

The Fix: Use a Sitemap Index file to group multiple sitemaps (e.g., sitemap-products.xml, sitemap-posts.xml).

How to Audit with Mygom

Mygom checks:

  1. If sitemap.xml exists in standard locations.
  2. If the XML syntax is valid.
  3. If it is correctly linked from your robots.txt file.