How to Create a Sitemap from Website Pages for SEO
Create a sitemap from your website pages, publish it for Google, and avoid common URL and formatting mistakes. A sitemap helps discovery but cannot guarantee indexing.

A sitemap is a file that lists pages and other files on your site to help search engines discover them. To create one, first check whether your CMS already publishes it; otherwise, make a list of the canonical URLs you want in search results, write them in XML or a simpler supported format, publish the file, then submit it in Google Search Console or reference it in robots.txt. A sitemap is a discovery hint, not a promise that Google will crawl or index every URL.
For a small site with a few dozen pages, a manually maintained XML or text file may be enough. For a larger or frequently changing site, generate it from your CMS or site database so new and removed pages are reflected automatically. In either case, include only full, canonical URLs you want surfaced in search.
1. Check whether your site already has a sitemap
Many common content management systems create sitemaps automatically. Before writing code or a file by hand, inspect your CMS settings and try the sitemap location it documents. Common paths may include /sitemap.xml, but CMS defaults and configurations vary, so verify your own site rather than assuming a particular address.
You can also look for a Sitemap: directive in your site’s robots.txt, often at https://example.com/robots.txt. If you find a sitemap, open it and inspect the URLs. Make sure it includes the pages you want indexed, uses the right canonical host and protocol, and excludes staging, duplicate, private, or otherwise unwanted URLs.
If the sitemap is correct, you generally do not need to create another one. Submit the existing file in Search Console if you want to track its processing, or make sure it is referenced in robots.txt.
2. Decide which website pages belong in it
A sitemap should represent your preferred URLs, not every address that happens to load. For each page, include the absolute canonical URL: the full URL with scheme and hostname, such as https://www.example.com/guides/sitemap/. Google attempts to crawl URLs as listed, so spelling, case, hostname, and trailing-slash conventions should match your canonical setup.
- Include pages you want available in search results and that search engines can crawl.
- Use one canonical URL for content available through multiple variants, such as tracking parameters or alternate paths.
- Leave out URLs that redirect, return errors, require a login, or are intentionally excluded from search.
- Do not use a sitemap as an access-control mechanism. Keep private content behind authentication.
Build an inventory from your CMS, database, or site export. For a small site, a spreadsheet with one URL per row is a practical source list. Review it before generating the final file: accidental URL variants are easier to catch in a list than after submission.
3. Choose a sitemap format
Google does not prefer one sitemap format over another. Choose based on whether you need structured metadata, what your CMS already emits, and how you will maintain the file.
| Format | Good fit | Limits and notes |
|---|---|---|
| XML | Most general-purpose sites; extensions for images, video, news, or localized URLs | Structured and extensible; XML characters must be escaped and the file must be UTF-8. |
| Plain text | A simple list of indexable URLs | One URL per line; supports URLs for HTML and other indexable textual content, but not the richer XML metadata. |
| RSS or Atom | A CMS that already exposes a feed | Convenient for recent content, but a feed may not contain a complete inventory of older pages. |
For a typical site starting from scratch, XML is a flexible default. A text file is sufficient if all you need is a URL list. Reuse a supported feed when it already covers the URLs you intend to expose.
4. Create a basic XML sitemap
Save the following as sitemap.xml, replacing the example URLs with your own canonical URLs. Ensure the document is UTF-8 encoded.

<?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>2026-09-20</lastmod>
</url>
<url>
<loc>https://www.example.com/about/</loc>
</url>
<url>
<loc>https://www.example.com/guides/sitemap/</loc>
<lastmod>2026-09-28</lastmod>
</url>
</urlset>
Each <url> entry contains a <loc> with the absolute URL. The optional <lastmod> value should reflect the last significant change to that page. It can be a date or a more precise timestamp with a time zone. If your publishing system cannot produce accurate values, omit the field rather than filling it with a misleading date.
Characters with special meaning in XML must be entity-escaped. For example, an ampersand in a URL query string is written as &. Prefer canonical, clean URLs without tracking parameters, which also reduces this issue. The Sitemap Protocol’s XML namespace and structure are documented by [the Sitemap Protocol](https://www.sitemaps.org/protocol.html); Google-specific guidance is in [Google’s sitemap documentation](https://developers.google.com/search/docs/crawling-indexing/sitemaps/build-sitemap).
Generate a plain text sitemap
If you only need a list, create a UTF-8 text file with one absolute URL on each line, such as:
https://www.example.com/
https://www.example.com/about/
https://www.example.com/guides/sitemap/
Publish it as a file such as sitemap.txt. This format is intentionally simple; use XML if you need sitemap extensions or structured per-URL metadata.
5. Automate sitemap generation for a changing site
Manually editing a sitemap becomes error-prone as pages are added, removed, or moved. For a larger or frequently updated site, generate the URL set from the same CMS or database that owns the pages. The following Python example illustrates writing a basic XML sitemap from a list of canonical URLs. It uses only the standard library, so it can run with Python 3.
from datetime import date
from xml.etree.ElementTree import Element, SubElement, ElementTree
urls = [
"https://www.example.com/",
"https://www.example.com/about/",
"https://www.example.com/guides/sitemap/",
]
namespace = "http://www.sitemaps.org/schemas/sitemap/0.9"
urlset = Element("urlset", xmlns=namespace)
today = date.today().isoformat()
for url in urls:
entry = SubElement(urlset, "url")
SubElement(entry, "loc").text = url
# Set lastmod only when this date reflects a significant page update.
SubElement(entry, "lastmod").text = today
ElementTree(urlset).write("sitemap.xml", encoding="utf-8", xml_declaration=True)
print(f"Wrote sitemap.xml with {len(urls)} URLs")
In production, replace the example list with a database or CMS query that selects only published, canonical, indexable pages. Do not stamp every URL with today’s date on each build: that suggests every page had a meaningful change. Store a page’s real significant-update timestamp and emit it only when the source data is reliable.
As a release check, parse or validate generated XML, confirm each URL belongs to the expected site, and compare the count with your published page inventory. Run generation as part of publishing or on a schedule appropriate to your content cadence. The sitemap should be reproducible from source data, so a deployment does not depend on hand edits to a generated file.
6. Handle large sites with multiple sitemap files
One sitemap file can contain at most 50,000 URLs and be at most 50 MB uncompressed. If either limit would be exceeded, split the URL set across multiple sitemap files. A sitemap index can then list the component files for submission as a group.

<?xml version="1.0" encoding="UTF-8"?>
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<sitemap>
<loc>https://www.example.com/sitemaps/pages-1.xml</loc>
</sitemap>
<sitemap>
<loc>https://www.example.com/sitemaps/pages-2.xml</loc>
</sitemap>
</sitemapindex>
Keep each component file below both limits. Google documents a limit of 50,000 sitemap index files per site in a Search Console account. The location of referenced files has same-site requirements unless cross-site submission is configured, so keep the index and its component sitemaps in a suitable site location and consult [Google’s sitemap index guidance](https://developers.google.com/search/docs/crawling-indexing/sitemaps/large-sitemaps) if you need to serve files across hosts.
Split along useful, stable boundaries, such as content type or date ranges, if that helps you troubleshoot which part of the inventory is stale. The order of URLs within a sitemap does not improve priority in Google’s processing.
7. Publish and make the sitemap discoverable
- Put the file on your site. Google recommends the site root as a suitable location unless you submit the sitemap through Search Console. Use a stable, publicly fetchable address, for example
https://www.example.com/sitemap.xml. - Check the response. Open the sitemap URL in a browser or request it from a command line. Confirm it returns the intended file, not an HTML error page, login screen, or redirect to an unrelated location.
- Add a robots.txt reference, if useful. Add a line such as
Sitemap: https://www.example.com/sitemap.xmlto the site’srobots.txt. For multiple files, point to the sitemap index. - Submit it in Search Console. Use the sitemap reporting workflow for the relevant verified property. Submission can help Google discover the file and gives you a place to review processing status and reported issues.
- Keep internal links crawlable. Link important pages through ordinary crawlable site navigation and contextual links. A sitemap complements the site’s link structure; it does not replace it.
Submission is not a guarantee of download, crawling, or indexing. Google describes sitemap submission as a hint. A URL can be present in a sitemap and still not be indexed, so use Search Console and the URL inspection workflow to investigate individual pages when needed.
8. Keep the sitemap accurate over time
When content changes, update the sitemap from the source of truth. Remove deleted URLs, replace moved URLs with their canonical destinations, and add new indexable pages. A sitemap should not become a historical list of every URL the site has ever served.
- Use meaningful
lastmodvalues. Update them for significant changes, such as a main content revision, structured data change, or important link change. A cosmetic footer or copyright-year change is not a meaningful page update. - Skip
priorityandchangefreqfor Google. Google ignores these values, so maintaining them adds no Google-specific benefit. - Do not treat sitemap order as ranking. Reordering entries does not make one page more important to Google.
- Keep exclusion rules separate.
robots.txtcontrols crawling, but it does not reliably prevent a URL from being indexed. If a page must stay out of search, use an appropriatenoindexdirective or access restriction. A crawler must be able to fetch a page to see anoindextag.
For small sites of about 500 pages or fewer, Google notes that a sitemap may not be necessary if all pages are properly linked and can be reached from the homepage. It can still be useful operationally, especially when you want an explicit inventory or Search Console reporting.
Or skip the browser setup
If you need page screenshots while reviewing how pages render, ScreenshotNeo provides a one-request screenshot API and an MCP server for AI agents. It is separate from sitemap generation: a screenshot can help inspect rendered pages, while the sitemap lists URLs for discovery.
curl -G "https://api.screenshotneo.com/v1/shot" \
-d access_key=YOUR_API_KEY \
--data-urlencode url=https://stripe.com \
-o shot.webp
See the [ScreenshotNeo API docs](https://screenshotneo.com/docs/) for request options. ScreenshotNeo accepts cookie and consent banners and removes more than 60 known consent platforms, newsletter popups, and chat widgets before capture; each step can be turned off. Bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and the response indicates the page verdict and billing status in headers. Its MCP server offers take_screenshot, get_page_info, and capture_pdf for Claude, Cursor, or any MCP client. The free plan includes 1,000 screenshots a month with no card; paid plans start at $5 for 3,000 shots.
Sign up for ScreenshotNeo’s free 1,000 screenshots a month, with no card required.
Troubleshooting common sitemap problems
| Problem | Likely cause | What to do |
|---|---|---|
| Sitemap URL returns 404 | The file was not deployed at that path, or the CMS uses another location. | Check the CMS sitemap setting and deployed file path; update Search Console and robots.txt to the actual stable URL. |
| Google reports a fetch or parsing issue | The URL serves an HTML error/login page, malformed XML, wrong encoding, or invalid escaping. | Fetch the exact public URL, confirm UTF-8 XML and the sitemap namespace, and escape special XML characters. |
| URLs are excluded or not indexed | They may redirect, be blocked, have noindex, be duplicates, or otherwise not be selected for indexing. |
Inspect an affected URL, canonical and robots directives; correct the underlying page signal. Sitemap inclusion alone cannot force indexing. |
| Some expected pages are missing | The generator queries only recent records, filters drafts incorrectly, or the CMS feed is incomplete. | Compare sitemap entries with the published canonical URL inventory; adjust the query or use an index of complete sitemap files. |
| Search Console shows a URL variant you did not expect | The source inventory contains tracking parameters, alternate hosts, or inconsistent trailing slashes. | Normalize to the canonical absolute URL before writing the sitemap and review redirects and canonical declarations. |
| File exceeds a size or URL limit | Too many entries or a large uncompressed XML file. | Split the list into files of no more than 50,000 URLs and 50 MB uncompressed each, then reference them from an index. |
lastmod values all change on every build |
The generator uses build time instead of content modification time. | Read meaningful page update timestamps from the CMS, or omit lastmod where you cannot provide reliable values. |
Performance, reliability, and cost considerations
A sitemap is a small published data file; the engineering cost is mostly keeping its URL inventory correct. A manual file has almost no setup overhead for a small, stable site, but maintenance effort grows with page count and URL churn. Automated generation reduces routine editing, but it must use correct canonical and publication rules or it can reproduce mistakes at scale.
For reliability, generate the sitemap from the same authoritative content source used to publish pages, publish it atomically with site changes where possible, and monitor that its public URL responds successfully. For a frequently changing site, choose a regeneration cadence that matches publishing needs. Avoid a generator that silently emits an empty or partial file when the CMS query fails; preserve the prior valid sitemap or fail the deployment visibly.
There is no paid tool required by the sitemap workflow described here. CMS features and Search Console cover common generation and submission needs. Larger sites may need engineering time for reliable inventory extraction, validation, sharding, and monitoring. Keep screenshot inspection tools separate from sitemap submission: ScreenshotNeo can capture rendered pages, but it does not replace the URL list, sitemap protocol, or Search Console process.
Quick checklist
- Checked the CMS for an existing sitemap and inspected its contents.
- Included only full canonical URLs intended for search.
- Selected XML, text, or an existing RSS/Atom feed to fit the site.
- Kept XML UTF-8 and escaped special characters.
- Used accurate significant-change
lastmodvalues, or omitted them. - Stayed within 50,000 URLs and 50 MB uncompressed per sitemap.
- Published a publicly fetchable file and submitted it or referenced it in
robots.txt. - Maintained crawlable internal links and checked Search Console for processing issues.
FAQ
Does every website need a sitemap?
No. A small, well-linked site may be discoverable without one. A sitemap is useful when you want to provide a URL inventory, have pages that are difficult to discover through links, or want Search Console sitemap reporting.
Will submitting a sitemap make every page rank or get indexed?
No. It gives Google a discovery hint. Google decides what to crawl and index; submission does not guarantee either outcome.
Should I add priority or changefreq?
You do not need to maintain them for Google, which ignores those fields. Accurate lastmod values are the useful optional signal described here.
How often should I regenerate it?
Regenerate it whenever the underlying published URL inventory changes, or run generation as part of your publishing process. The right cadence depends on how often the site adds, removes, or materially updates pages.
Can I list a URL blocked by robots.txt?
A sitemap does not override crawl restrictions. Keep the sitemap aligned with URLs you intend search engines to crawl, and use the appropriate page-level indexing or access control for exclusion goals.


