How to Create a Sitemap: Manual, CMS, and Generator Methods
Step-by-step guide to creating XML sitemaps manually, with CMS tools like WordPress and Shopify, using generators, and building dynamic sitemaps.
Last updated: 2026-02-17
Why Create a Sitemap?
A sitemap ensures search engines can discover every page you want indexed. Without one, crawlers rely on following links -- a method that misses orphan pages, new content, and deeply nested URLs.
Creating a sitemap is one of the fastest technical SEO wins available. Whether you build it by hand, let your CMS generate it, or use a dedicated tool, the result is the same: a clear, machine-readable list of your site's important URLs.
This guide covers every method, from manual XML creation to platform-specific auto-generation.
Method 1: Create a Sitemap Manually
Manual creation works for small sites with a stable set of pages. If your site has fewer than 50 pages and changes infrequently, writing the XML by hand is perfectly reasonable.
Create the XML file
Create a new file named sitemap.xml in your site's root directory. Start with the XML declaration and the urlset root element with the Sitemap Protocol namespace.
Add URL entries
Add a url block for each page you want indexed. Include the full absolute URL in the loc tag, and a lastmod date if you know when the page was last updated.
Save and upload
Save the file and upload it to your web server's root directory so it is accessible at https://yourdomain.com/sitemap.xml.
Validate the XML
Open the sitemap URL in a browser to confirm it renders as valid XML. Use an online XML validator to catch syntax errors.
Here is a minimal but complete manual sitemap:
<?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-02-15</lastmod>
</url>
<url>
<loc>https://example.com/about</loc>
<lastmod>2026-01-10</lastmod>
</url>
<url>
<loc>https://example.com/contact</loc>
<lastmod>2025-12-01</lastmod>
</url>
</urlset>
The drawback of manual sitemaps is maintenance. Every time you add or remove a page, you need to update the file. For sites that change frequently, automated methods are far better.
Method 2: CMS Auto-Generation
Most modern content management systems generate sitemaps automatically. This is the easiest approach for most website owners.
WordPress
WordPress has included built-in sitemap generation since version 5.5. Your sitemap is automatically available at /wp-sitemap.xml.
For more control, SEO plugins provide enhanced sitemap features:
- Yoast SEO generates sitemaps at
/sitemap_index.xmlwith separate sitemaps for posts, pages, categories, and custom post types. You can exclude specific post types or individual pages. - Rank Math offers similar functionality with additional options for including images in sitemaps and controlling
lastmodbehavior. - All in One SEO provides granular control over which content types appear in your sitemap.
If you use an SEO plugin, disable WordPress's built-in sitemap to avoid serving two competing sitemaps. Most SEO plugins handle this automatically.
Shopify
Shopify generates a sitemap automatically at /sitemap.xml. It includes products, collections, blog posts, and pages. The sitemap updates whenever you publish or modify content.
You cannot directly edit Shopify's auto-generated sitemap. If you need to exclude specific URLs, you must use the noindex meta tag on those pages instead.
Squarespace
Squarespace generates sitemaps at /sitemap.xml automatically. It includes all published pages, blog posts, products, and gallery images. No configuration is needed.
Wix
Wix auto-generates sitemaps that include all site pages, blog posts, and dynamic pages. The sitemap is at /sitemap.xml and updates automatically.
Method 3: Framework-Based Generation
If you are building with a JavaScript framework or static site generator, sitemap generation is typically handled through configuration or build plugins.
Next.js
Next.js (App Router) supports native sitemap generation. Create a sitemap.ts file in your app directory:
import { MetadataRoute } from 'next'
export default async function sitemap(): Promise<MetadataRoute.Sitemap> {
const posts = await fetchBlogPosts()
const blogUrls = posts.map((post) => ({
url: `https://example.com/blog/${post.slug}`,
lastModified: post.updatedAt,
}))
return [
{ url: 'https://example.com', lastModified: new Date() },
{ url: 'https://example.com/pricing', lastModified: new Date() },
...blogUrls,
]
}
For large sites, implement generateSitemaps() to split across multiple files:
export async function generateSitemaps() {
const totalProducts = await getProductCount()
const sitemaps = []
for (let i = 0; i < Math.ceil(totalProducts / 50000); i++) {
sitemaps.push({ id: i })
}
return sitemaps
}
Astro
Use the @astrojs/sitemap integration:
// astro.config.mjs
import sitemap from '@astrojs/sitemap'
export default defineConfig({
site: 'https://example.com',
integrations: [sitemap()],
})
Gatsby
Install gatsby-plugin-sitemap:
// gatsby-config.js
module.exports = {
siteMetadata: { siteUrl: 'https://example.com' },
plugins: ['gatsby-plugin-sitemap'],
}
Hugo
Hugo generates sitemaps by default at /sitemap.xml. You can customize the template in layouts/sitemap.xml or configure defaults in config.toml.
Monitor Your Sitemap After Creation
Creating a sitemap is step one. Site Watcher continuously monitors it for errors, broken URLs, and unexpected changes.
Method 4: Online Sitemap Generators
If your site does not have built-in sitemap generation, online tools can crawl your site and produce a sitemap file.
How Online Generators Work
These tools start at your homepage and follow every link they can find, building a list of URLs. They then output that list as an XML sitemap file you can download and upload to your server.
Popular Options
XML-Sitemaps.com
Free for sites up to 500 URLs. Crawls your site and generates a downloadable XML file. Simple and effective for small sites.
Screaming Frog SEO Spider
A desktop application that crawls your site and can export sitemaps. Handles complex sites with JavaScript rendering. Free for up to 500 URLs; paid version has no limit.
Yoast SEO (standalone)
Beyond the WordPress plugin, Yoast provides general sitemap guidance. For non-WordPress sites, consider their recommendations as a reference.
Limitations of Generator Tools
Online generators only find pages they can reach by following links. If a page has no inbound links (an orphan page), the generator will miss it. They also may not handle JavaScript-rendered content well.
For dynamic sites with frequently changing content, a generated sitemap becomes stale quickly. Automated, server-side generation is always preferable for active sites.
What to Include in Your Sitemap
Not every URL belongs in your sitemap. Be deliberate about what you include.
| Include | Exclude |
|---|---|
| Canonical, indexable pages | Pages with noindex tags |
| Published blog posts and articles | Redirected URLs (301, 302) |
| Product and category pages | Duplicate/non-canonical pages |
| Landing pages | Admin and login pages |
| Important media pages | URL parameter variations |
The guiding principle: if you want it in search results, include it. If you do not, leave it out.
What to Exclude and Why
Certain URL types should never appear in your sitemap:
Redirects. Including URLs that return 301 or 302 status codes wastes crawl budget and signals poor sitemap maintenance. Always list the final destination URL instead.
Error pages. URLs returning 404 or 410 status codes indicate dead content. They should be removed from your sitemap immediately.
Paginated URLs. Pages like /blog?page=2 typically do not need to be in the sitemap unless each paginated page contains unique, indexable content.
Filtered and sorted URLs. E-commerce sites often generate thousands of URL variations through filters (color, size, price). These usually should not be indexed and do not belong in your sitemap.
Staging and development URLs. If your sitemap generator runs against a staging environment, make sure it does not include staging URLs in the production sitemap.
Testing Your Sitemap
After creating your sitemap, verify it works correctly before submitting to search engines.
Open it in a browser
Navigate to https://yourdomain.com/sitemap.xml. You should see properly formatted XML. If you see an error or a blank page, the file is not being served correctly.
Validate the XML
Use an XML validator to check for syntax errors -- unclosed tags, missing namespaces, or encoding problems.
Spot-check URLs
Click on several URLs from your sitemap to verify they load correctly and return 200 status codes. Pay attention to edge cases like URLs with special characters.
Check the URL count
Make sure the number of URLs matches your expectations. If your site has 500 pages but the sitemap lists 50, something is missing. If it lists 5,000, you are probably including URLs that should be excluded.
Verify robots.txt reference
Open your robots.txt file and confirm it includes a Sitemap: directive pointing to your sitemap URL.
After testing locally, submit your sitemap to Google Search Console for the definitive validation. Google will report any errors it finds during processing.
Dynamic vs. Static Sitemaps
The choice between dynamic and static sitemaps depends on how frequently your content changes.
Static sitemaps are generated once (at build time or manually) and served as a fixed XML file. They are simple, fast to serve, and work well for sites that change infrequently.
Dynamic sitemaps are generated on each request by querying a database or API. They always reflect the current state of your content. They require more server resources but eliminate the risk of stale data.
Hybrid approach: Generate the sitemap on a schedule (every hour, every day) and cache the result. This gives you near-real-time accuracy without the overhead of generating the sitemap on every request.
For most sites, the CMS or framework handles this decision for you. If you are building a custom solution, the hybrid approach offers the best balance.
The best sitemap is the one that stays in sync with your actual content -- pick the generation method that makes that automatic.
Keep Your Sitemap Accurate
Site Watcher monitors your sitemap alongside SSL, DNS, uptime, and vendor dependencies. Catch issues before they affect search indexing. Free for 3 targets, $39/mo unlimited.