Skip to content
🛠️ToolsShed

Sitemap XML Generator

Generate sitemap.xml files with URLs, priorities, and change frequencies.

About this tool

A sitemap is a roadmap that tells search engines which pages on your website exist and how often they change. The Sitemap XML Generator creates properly formatted sitemap.xml files that help Google, Bing, and other search engines crawl and index your content more efficiently. This is especially valuable for large websites with hundreds or thousands of pages, where manual discovery by search bots might otherwise take months.

To use this tool, enter your website's URLs one per line, then optionally assign each URL a priority (0.0 to 1.0, where 1.0 is highest) and specify how often it changes—daily, weekly, monthly, or yearly. The tool instantly generates a valid XML sitemap that follows the official sitemaps protocol. You can then download the file, upload it to your web server's root directory, and submit it to Google Search Console and Bing Webmaster Tools for faster indexing.

Sitemaps are particularly useful when your website structure is complex or when pages lack sufficient internal linking. While not a replacement for good site architecture, they accelerate the time search engines need to discover new or updated content, making them essential for SEO. Most modern websites—blogs, e-commerce stores, news sites, and documentation portals—benefit from having a sitemap registered with search engines.

Frequently Asked Questions

Code Implementation

from datetime import date
from xml.etree.ElementTree import Element, SubElement, tostring
from xml.dom import minidom

def generate_sitemap(urls: list[dict]) -> str:
    """
    Generate sitemap.xml string.
    Each url dict: { loc, lastmod?, changefreq?, priority? }
    """
    root = Element("urlset")
    root.set("xmlns", "http://www.sitemaps.org/schemas/sitemap/0.9")
    for entry in urls:
        url_el = SubElement(root, "url")
        SubElement(url_el, "loc").text = entry["loc"]
        if "lastmod" in entry:
            SubElement(url_el, "lastmod").text = entry["lastmod"]
        if "changefreq" in entry:
            SubElement(url_el, "changefreq").text = entry["changefreq"]
        if "priority" in entry:
            SubElement(url_el, "priority").text = str(entry["priority"])
    raw = tostring(root, encoding="unicode")
    dom = minidom.parseString(raw)
    return dom.toprettyxml(indent="  ")

urls = [
    {"loc": "https://example.com/",        "lastmod": str(date.today()), "changefreq": "daily",   "priority": 1.0},
    {"loc": "https://example.com/about",   "lastmod": str(date.today()), "changefreq": "monthly", "priority": 0.8},
    {"loc": "https://example.com/contact", "lastmod": str(date.today()), "changefreq": "monthly", "priority": 0.5},
]
print(generate_sitemap(urls))

Comments & Feedback

Comments are powered by Giscus. Sign in with GitHub to leave a comment.