How to Update Your Sitemap
When and how to update your XML sitemap: triggers for updates, manual vs automatic approaches, CMS-specific guidance, re-submitting to Google, and lastmod best practices.
A sitemap isn't a set-it-and-forget-it file. Every time you add a page, remove a page, or change a URL, your sitemap needs to reflect that. An outdated sitemap sends search engines to pages that don't exist and hides pages that do.
Here's when to update your sitemap, how to do it, and how to make sure search engines notice.
When to Update Your Sitemap
Not every site change requires a sitemap update, but most structural changes do. Here are the triggers:
You published new pages
You deleted or unpublished pages
You changed URLs
You changed canonical URLs
You made significant content updates
<lastmod> date to signal freshness. Don't update lastmod for trivial changes like fixing a typo.You migrated to HTTPS
http:// to https://. This is easy to miss and causes indexing confusion.Manual vs. Automatic Updates
How you update your sitemap depends on how your site is built.
Automatic Sitemap Generation
Most modern CMS platforms and frameworks generate sitemaps automatically. This is the best approach for most sites because it eliminates the risk of human error.
How it works: The system queries your database or file system for all published pages and generates a fresh sitemap on each build or on each request. When you publish a new page, it appears in the sitemap automatically. When you unpublish a page, it disappears.
Platforms with automatic sitemaps:
| Platform | Sitemap Location | Auto-Updates |
|---|---|---|
| WordPress (Yoast SEO) | /sitemap_index.xml | Yes, on publish/unpublish |
| WordPress (core) | /wp-sitemap.xml | Yes, on publish/unpublish |
| Shopify | /sitemap.xml | Yes, every few hours |
| Squarespace | /sitemap.xml | Yes, on publish |
| Wix | /sitemap.xml | Yes, on publish |
| Next.js (app router) | /sitemap.xml | Yes, on build or per-request |
| Gatsby | /sitemap-index.xml | Yes, on build |
Build-time vs. runtime sitemaps
Static site generators like Gatsby and Hugo generate sitemaps at build time. If you publish content but don't rebuild, the sitemap won't update. Dynamic frameworks like WordPress and Shopify generate sitemaps on-the-fly, so they're always current. Next.js supports both approaches depending on your configuration.
Manual Sitemap Updates
If your site uses a hand-coded sitemap (a static XML file), you need to edit it yourself whenever the site changes.
Open your sitemap.xml file
Find the sitemap file in your project. It's usually at the root of your public/static directory.
Add new URLs
For each new page, add a <url> block inside the <urlset> element:
<url>
<loc>https://example.com/new-page</loc>
<lastmod>2025-06-15</lastmod>
</url>
Remove deleted URLs
Delete the entire <url> block for any page that no longer exists or has been redirected.
Update lastmod dates
For pages with significant content changes, update the <lastmod> element to today's date.
Validate the updated file
Run the updated sitemap through a validator to catch XML syntax errors before deploying. A missing closing tag can invalidate the entire file.
Deploy and re-ping
Upload the updated file and notify search engines (covered below).
Manual sitemaps work fine for small, static sites. But once you're managing more than a few dozen pages, the manual approach becomes a liability. It's too easy to forget.
CMS-Specific Guidance
WordPress
WordPress has included a built-in sitemap at /wp-sitemap.xml since version 5.5. It updates automatically when you publish, update, or delete content.
Most WordPress sites use an SEO plugin instead (Yoast, Rank Math, or All in One SEO), which provides more control. These plugins let you exclude specific posts, pages, or taxonomies from the sitemap and typically generate a sitemap index with separate sitemaps for posts, pages, categories, and tags.
To force a refresh with Yoast: Go to Yoast SEO > General > Features tab and toggle the XML Sitemaps switch off and back on.
Shopify
Shopify generates your sitemap automatically. You cannot directly edit it. The sitemap updates every few hours when content changes. If you need an immediate update after a major change, there's no manual trigger -- you'll need to wait or re-submit in Search Console.
Static Sites (Next.js, Gatsby, Hugo)
For static site generators, the sitemap updates when you rebuild and redeploy. Make sure your CI/CD pipeline triggers a build whenever content changes. If you're using a headless CMS with a static frontend, set up a webhook to trigger a rebuild when content is published.
Is your sitemap up to date?
Validate your sitemap after every update. Catch errors before search engines do.
Re-Submitting After Updates
After updating your sitemap, you want search engines to re-crawl it. There are three ways to make this happen:
1. Google Search Console
Go to Indexing > Sitemaps in Google Search Console and re-submit your sitemap URL. Google will re-fetch it and process the changes. This is the most reliable method.
2. Ping URL
You can ping Google directly by requesting this URL:
https://www.google.com/ping?sitemap=https://example.com/sitemap.xml
This tells Google your sitemap has changed. You can automate this as part of your deployment process.
3. Wait for Regular Crawling
If you don't do anything, Google will eventually re-crawl your sitemap on its own schedule. For most sites, this happens within a few days. For high-authority sites with frequent updates, it can happen within hours. For new or low-traffic sites, it might take a week or more.
Don't re-submit constantly
Re-submitting your sitemap every time you change a comma doesn't help. Google treats excessive pings the same as no pings. Submit when you've made meaningful changes -- new pages, removed pages, or structural updates.
Lastmod Best Practices
The <lastmod> element tells search engines when a page was last meaningfully changed. Used correctly, it helps search engines prioritize what to re-crawl. Used incorrectly, it destroys your credibility.
Do:
- Set
<lastmod>to the date the page content was substantively updated - Use W3C Datetime format:
2025-06-15or2025-06-15T14:30:00+00:00 - Let your CMS set this automatically based on the actual modification date
Don't:
- Set all
<lastmod>dates to today's date -- Google will learn to ignore them - Update
<lastmod>for trivial changes (CSS tweaks, footer updates, typo fixes) - Use
<lastmod>on pages that haven't actually changed - Omit
<lastmod>entirely -- it's optional but genuinely useful when accurate
Google has explicitly stated that they use <lastmod> as a signal when it's consistently accurate. If your lastmod dates don't correlate with actual content changes, Google will stop trusting them for your entire site.
Setting Up an Update Process
The best sitemap update strategy is one that requires zero manual effort. Here's a practical approach:
Use automatic generation
Configure your CMS or framework to generate the sitemap dynamically. Don't maintain a static file if you can avoid it.
Validate after changes
Add sitemap validation to your deployment pipeline. If the sitemap has errors after a build, catch them before they go live.
Monitor regularly
Check your sitemap's status in Google Search Console at least monthly. Look for error spikes, unexpected URL count changes, and fetch issues.
Audit quarterly
Every few months, compare your sitemap URLs against your actual site. Look for URLs that exist on the site but aren't in the sitemap (missing pages) and URLs in the sitemap that don't exist on the site (stale entries).
An outdated sitemap is worse than no sitemap. If search engines can't trust your sitemap to reflect reality, they'll rely on crawling alone -- which means slower discovery and wasted resources for both you and them.
Related Articles
The best sitemap is one that updates itself.
Validate your XML sitemap
Check your sitemap for errors, broken URLs, and indexing issues. Free instant validation.