generate a sitemap for a static website

Downloads in past


3120.4.46 years ago10 years agoMinified + gzip package size for sitemap-static in KB


CircleCI Greenkeeper badge
Make a sitemap for a static website based on files on disk


npm install -g sitemap-static


Use in the root directory of the files on the site. This will only add files with .html extensions to the sitemap.
sitemap-static --prefix= . > sitemap.xml

library API

var generateSitemap = require('sitemap-static');
var fs = require('fs');

var writer = fs.createWriteStream('/path/to/your/sitemap.xml');

generateSitemap(writer, {
    findRoot: '.',
    ignoreFile: '',
    prefix: 'http://somesi.te/',
    pretty: false

Ignore File

Added in v0.0.1 you can pass the name of a json file to load. File file needs to be in your current working directory and should be an array of file names (without the / at the front) that you want ignored. You can ignore entire directories by leaving off the .html. Example JSON:
Example Command:
sitemap-static --ignore-file=ignore.json --prefix= . > sitemap.xml

Pretty URLs

If you pass --pretty to the CLI (or pretty: true to the JS API), sitemap-static will output pretty URLs rather than the whole path to each file. For example:
| Not pretty | Pretty | | --- | --- | | | | | | | | | | | | |
Example Command:
sitemap-static --prefix= --pretty . > sitemap.xml