For a hand-maintained site of a dozen or so HTML pages, the most dependable way to keep sitemap.xml current on Windows is a small local script that reads your site folder and writes the file for you. You run it after each round of edits, upload the result, and you are done—no browser tools, no installs, and nothing that needs standing access to your live server.
Picking the right approach for a tiny site
There are three realistic routes, and the best one depends on how often you touch the site:
- Online generators are fine for a one-off file, but every future edit means visiting the site again, re-entering the URL, and downloading a fresh copy. For a site you update every few weeks, that chore adds up.
- Desktop crawlers, such as the free tier of Screaming Frog SEO Spider (which handles up to 500 URLs), crawl the live site and can export a sitemap directly. This is the better choice when your published URLs don't resemble your file names—more on that below.
- A local script reads your files straight off disk, costs nothing, and is trivially repeatable. For roughly 15 pages that rarely change structure, this is usually the sweet spot.
What a useful sitemap.xml actually contains
A sitemap is just an XML list of URLs. The only mandatory element per URL is <loc>. Two details matter in practice:
<lastmod>is worth including, but only if it is honest. Deriving it from each file's modification timestamp gives search engines a real signal about what changed. Do not invent dates to make pages look fresh.<priority>and<changefreq>can be skipped entirely—search engines ignore them, so they add noise without value.
The file must also be well-formed XML, which means any & in a URL has to be escaped, and it should be saved as UTF-8 without a byte-order mark so parsers don't choke on the first bytes.
A reusable script you can rerun after every edit
Save the following as make-sitemap.ps1 somewhere outside your site folder so it never gets published by accident, then adjust the three values at the top:
# make-sitemap.ps1
$root = "C:\websites\mysite" # local copy of the site, no trailing slash
$base = "https://www.example.com" # live origin, no trailing slash
$skip = @("404.html") # filenames that should never be listed
$pages = Get-ChildItem $root -Recurse -Filter *.html -File |
Where-Object { $skip -notcontains $_.Name } |
Sort-Object FullName
$rows = [System.Collections.Generic.List[string]]::new()
$rows.Add('<?xml version="1.0" encoding="UTF-8"?>')
$rows.Add('<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">')
foreach ($p in $pages) {
$path = $p.FullName.Substring($root.Length).Replace('\', '/')
$path = $path -replace '(?i)(^|/)index\.html$', '/' # index pages become their folder
$url = [System.Security.SecurityElement]::Escape("$base$path")
$mod = $p.LastWriteTimeUtc.ToString('yyyy-MM-dd')
$rows.Add(" <url><loc>$url</loc><lastmod>$mod</lastmod></url>")
}
$rows.Add('</urlset>')
[System.IO.File]::WriteAllLines("$root\sitemap.xml", $rows)
The script walks every .html file under the root, skips anything on your exclusion list, converts backslashes to forward slashes, and writes one <url> entry per page. The escape call handles XML-special characters in URLs, and WriteAllLines produces UTF-8 without a BOM. Because the sitemap is written into the site root, it will be overwritten cleanly on the next run.
Running it
Open PowerShell in the folder where you saved the script and run:
powershell -ExecutionPolicy Bypass -File .\make-sitemap.ps1
The Bypass flag only applies to this single invocation, so you don't loosen your machine's script policy permanently.
When local file names don't match live URLs
The script assumes the URL of each page mirrors its path on disk. That breaks in two common situations:
- Index files. Handled above:
index.htmlmaps to the site root andblog/index.htmlmaps to/blog/, which is what visitors and crawlers should see. - Clean URLs. If your host rewrites
about.htmlso the public address is just/about, the script's output will disagree with reality. Your options are to keep the.htmlsuffix in your public links, add a small rename rule to the script, or switch to a crawler-based approach: point Screaming Frog's free spider at the deployed site and export its sitemap, which reflects the URLs as they actually resolve.
Whatever you list, make sure every URL returns 200 and is the canonical version—never include pages that redirect or 404.
Publish, register once, then just repeat
After generating the file:
- Upload
sitemap.xmlto your site root. - Add a line
Sitemap: https://www.example.com/sitemap.xmltorobots.txtso any crawler that reads it can find the file. - Submit the sitemap once in Google Search Console (and Bing Webmaster Tools if you like). This is a one-time registration, not a per-edit ritual.
From then on, your entire maintenance routine is: edit pages, run the script, upload the refreshed file. Search engines revisit on their own schedule; you don't need to resubmit after every change.
Frequently Asked Questions
Do I need <priority> and <changefreq> in my sitemap?
No. Google has stated it ignores both. If your generator adds them, that's harmless, but a hand-rolled file is cleaner without them. An accurate <lastmod> is the only optional field with real value.
How often should I regenerate the file?
Whenever you add, remove, or rename a page, or make a substantial content change you want reflected in <lastmod>. The file doesn't need to be "fresh" for its own sake—it just needs to match reality.
Do I have to resubmit the sitemap in Search Console after every update?
No. One submission is enough; Google re-reads the file periodically. Resubmitting doesn't speed up crawling, so save the clicks.
PowerShell refuses to run my script. What now?
That's the execution policy, not a bug. Launching with -ExecutionPolicy Bypass as shown allows that one run. If you run scripts often, Set-ExecutionPolicy RemoteSigned -Scope CurrentUser is a reasonable standing setting.
Is a sitemap even necessary for a 15-page site?
Strictly, no—a small, well-interlinked site gets crawled without one. But a sitemap speeds up discovery of brand-new pages and gives you a per-URL status view in Search Console, which is genuinely useful for spotting problems.
Can the script handle .htm files or other extensions?
Yes—change the filter to *.htm* (or add a second Get-ChildItem pass) if your site mixes extensions. Just keep file naming consistent, ideally all lowercase, because URLs on Linux-based hosts are case-sensitive even though Windows filenames are not.