The problem
Search engines can crawl a small site by following links alone, but a sitemap gives them a direct, complete list instead of relying on discovery — especially useful for pages with few internal links pointing at them. Most static sites don’t generate one automatically.
Expected outcome
By the end of this guide you will have a script that scans your site’s built HTML files and writes a correct sitemap.xml, with no manual list-keeping.
Requirements and costs
- Node.js (version 18 or newer).
- A folder of built
.htmlfiles (the output of your static site generator, or just plain HTML files). - Cost: free. No dependencies.
Step-by-step implementation
- Download the generator from the link below.
- Run it against your site’s built folder and your real domain:
node generate-sitemap.js ./dist https://yoursite.com - Check the output — it writes
sitemap.xmldirectly into that folder. - Deploy it along with the rest of your site, so it ends up at
https://yoursite.com/sitemap.xml. - Submit it in Google Search Console (and Bing Webmaster Tools) under Sitemaps, or just let search engines find it at the standard URL.
A real example
Given a folder with index.html, about.html, and blog/post-one.html, the generator produces:
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url><loc>https://example.com/about</loc></url>
<url><loc>https://example.com/blog/post-one</loc></url>
<url><loc>https://example.com/</loc></url>
</urlset>
Notice index.html correctly became the bare root URL, and the nested blog/post-one.html kept its folder structure in the URL path — both handled automatically, not just the simple top-level case.
Verification and troubleshooting
What we tested, on 5 October 2026 (record TNT-TEST-2026-10-05-013): ran against a real 3-file mock site (a root index, a top-level page, and a nested page) and got exactly 3 correct URLs back, with index.html resolved to the bare root path. Separately checked the output XML: balanced opening/closing <url> tags (3 of each), a correct XML declaration, and the correct sitemap namespace — all present.
Troubleshooting:
- A page you expected is missing from the sitemap. Only files ending in
.htmlare included — check your build output actually produces that file extension, not something like.htmor an extensionless route. - URLs have the wrong domain. Double-check the base URL argument includes the correct scheme (
https://) and no typos — it’s used as-is, with no validation of the domain itself. - You regenerate the sitemap but search engines don’t notice quickly. Resubmitting it in Search Console after a significant change speeds up recrawling; it isn’t picked up instantly just because the file changed.
Limitations and alternatives
This only includes static .html files it finds on disk — it has no way to know about dynamically-generated routes that don’t correspond to a physical file, and it doesn’t set lastmod dates (a valid, simpler sitemap doesn’t require them, though some crawlers use them when present). Most static site generators (Astro, Eleventy, Hugo) have their own sitemap plugin that handles this more deeply integrated with their routing — worth using instead if you’re already on one of those.
Free resources
The download contains the generator script.
Download the sitemap generator (ZIP, 1 KB)
Is there a paid version?
Not yet. This is the complete method. TNT Review has sold nothing to date and has no checkout, so any price we discuss in future should be read as a hypothesis, not an offer.