{"id":15386662,"url":"https://github.com/zerodevx/static-sitemap-cli","last_synced_at":"2025-08-21T12:30:35.582Z","repository":{"id":35035318,"uuid":"199038728","full_name":"zerodevx/static-sitemap-cli","owner":"zerodevx","description":"CLI to generate XML sitemaps for static sites from local filesystem","archived":false,"fork":false,"pushed_at":"2024-09-12T06:43:42.000Z","size":594,"stargazers_count":23,"open_issues_count":0,"forks_count":3,"subscribers_count":4,"default_branch":"main","last_synced_at":"2024-12-10T10:03:53.389Z","etag":null,"topics":["cli","sitemap-generator","static-site","xml"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zerodevx.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"zerodevx"}},"created_at":"2019-07-26T15:16:26.000Z","updated_at":"2024-10-26T15:52:59.000Z","dependencies_parsed_at":"2024-06-21T19:18:53.908Z","dependency_job_id":"ddf7a8fa-2d9a-4c3a-8539-2c34412b6a1d","html_url":"https://github.com/zerodevx/static-sitemap-cli","commit_stats":{"total_commits":49,"total_committers":1,"mean_commits":49.0,"dds":0.0,"last_synced_commit":"0ef2e03b65f6f721f1c2e37f3264af4986d0a83a"},"previous_names":[],"tags_count":28,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zerodevx%2Fstatic-sitemap-cli","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zerodevx%2Fstatic-sitemap-cli/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zerodevx%2Fstatic-sitemap-cli/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zerodevx%2Fstatic-sitemap-cli/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zerodevx","download_url":"https://codeload.github.com/zerodevx/static-sitemap-cli/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":230511479,"owners_count":18237657,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cli","sitemap-generator","static-site","xml"],"created_at":"2024-10-01T14:50:05.767Z","updated_at":"2024-12-19T23:14:39.275Z","avatar_url":"https://github.com/zerodevx.png","language":"JavaScript","funding_links":["https://github.com/sponsors/zerodevx"],"categories":[],"sub_categories":[],"readme":"[![npm (tag)](https://img.shields.io/npm/v/static-sitemap-cli/latest)](https://www.npmjs.com/package/static-sitemap-cli)\n[![npm](https://img.shields.io/npm/dm/static-sitemap-cli)](https://www.npmjs.com/package/static-sitemap-cli)\n\n# static-sitemap-cli\n\n\u003e CLI to generate XML sitemaps for static sites from local filesystem.\n\nQuick and easy CLI to generate [XML](https://www.sitemaps.org/protocol.html) or\n[TXT](https://developers.google.com/search/docs/advanced/sitemaps/build-sitemap#text) sitemaps by\nsearching your local filesystem for `.html` files. Automatically exclude files containing the\n`noindex` meta. Can also be used as a Node module.\n\n**NOTE:** This is the V2 branch. If you're looking for the older version, see the\n[V1 branch](https://github.com/zerodevx/static-sitemap-cli/tree/v1). V2 contains **breaking\nchanges**. Find out what changed on the\n[releases](https://github.com/zerodevx/static-sitemap-cli/releases) page.\n\n## Install\n\n```\n$ npm i -g static-sitemap-cli\n```\n\n## Usage\n\n```\n$ sscli -b https://example.com -r public\n```\n\nThis trawls the `public/` directory for files matching `**/*.html`, then parses each file for the\n`noindex` robots meta tag - excluding that file if the tag exists - and finally generates both\n`sitemap.xml` and `sitemap.txt` into the `public/` root.\n\nSee below for more usage [examples](#examples).\n\n## Options\n\n```\nUsage: sscli [options]\n\nCLI to generate XML sitemaps for static sites from local filesystem\n\nOptions:\n  -b, --base \u003curl\u003e                       base URL (required)\n  -r, --root \u003cdir\u003e                       root working directory (default: \".\")\n  -m, --match \u003cglob...\u003e                  globs to match (default: [\"**/*.html\"])\n  -i, --ignore \u003cglob...\u003e                 globs to ignore (default: [\"404.html\"])\n  -c, --changefreq \u003cglob,changefreq...\u003e  comma-separated glob-changefreq pairs\n  -p, --priority \u003cglob,priority...\u003e      comma-separated glob-priority pairs\n  --no-robots                            do not parse html files for noindex meta\n  --concurrent \u003cmax\u003e                     concurrent number of html parsing ops (default: 32)\n  --no-clean                             do not use clean URLs\n  --slash                                add trailing slash to all URLs\n  -f, --format \u003cformat\u003e                  sitemap format (choices: \"xml\", \"txt\", \"both\", default: \"both\")\n  -o, --stdout                           output sitemap to stdout instead\n  -v, --verbose                          be more verbose\n  -V, --version                          output the version number\n  -h, --help                             display help for command\n```\n\n#### HTML parsing\n\nBy default, all matched `.html` files are piped through a fast\n[HTML parser](https://github.com/fb55/htmlparser2) to detect if the `noindex`\n[meta tag](https://developers.google.com/search/docs/advanced/crawling/block-indexing#meta-tag) is\nset - typically in the form of `\u003cmeta name=\"robots\" content=\"noindex\" /\u003e` - in which case that file\nis excluded from the generated sitemap. To disable this behaviour, pass option `--no-robots`.\n\nFor better performance, file reads are streamed in `1kb` chunks, and parsing stops immediately when\neither the `noindex` meta, or the `\u003c/head\u003e` closing tag, is detected (the `\u003cbody\u003e` is not parsed).\nThis operation is performed concurrently with an\n[async pool](https://github.com/rxaviers/async-pool) limit of 32. The limit can be tweaked using the\n`--concurrent` option.\n\n#### Clean URLs\n\nHides the `.html` file extension in sitemaps like so:\n\n```\n./rootDir/index.html -\u003e https://example.com/\n./rootDor/foo/index.html -\u003e https://example.com/foo\n./rootDor/foo/bar.html -\u003e https://example.com/foo/bar\n```\n\nEnabled by default; pass option `--no-clean` to disable.\n\n#### Trailing slashes\n\nAdds a trailing slash to all URLs like so:\n\n```\n./rootDir/index.html -\u003e https://example.com/\n./rootDir/foo/index.html -\u003e https://example.com/foo/\n./rootDir/foo/bar.html -\u003e https://example.com/foo/bar/\n```\n\nDisabled by default; pass option `--slash` to enable.\n\n**NOTE:** Cannot be used together with `--no-clean`. Also, trailing slashes are\n[always added](https://github.com/zerodevx/static-sitemap-cli/tree/v1#to-slash-or-not-to-slash) to\nroot domains.\n\n#### Match or ignore files\n\nThe `-m` and `-i` flags allow multiple entries. By default, they are set to the `[\"**/*.html\"]` and\n`[\"404.html\"]` respectively. Change the glob patterns to suit your use-case like so:\n\n```\n$ sscli ... -m '**/*.{html,jpg,png}' -i '404.html' 'ignore/**' 'this/other/specific/file.html'\n```\n\n#### Glob-[*] pairs\n\nThe `-c` and `-p` flags allow multiple entries and accept `glob-*` pairs as input. A `glob-*` pair\nis a comma-separated pair of `\u003cglob\u003e,\u003cvalue\u003e`. For example, a glob-changefreq pair may look like\nthis:\n\n```\n$ sscli ... -c '**,weekly' 'events/**,daily'\n```\n\nLatter entries override the former. In the above example, paths matching `events/**` have a `daily`\nchangefreq, while the rest are set to `weekly`.\n\n#### Using a config file\n\nOptions can be passed through the `sscli` property in `package.json`, or through a `.ssclirc` JSON\nfile, or through other [standard conventions](https://github.com/davidtheclark/cosmiconfig).\n\n## Examples\n\n#### Dry-run sitemap entries\n\n```\n$ sscli -b https://x.com -f txt -o\n```\n\n#### Generate XML sitemap to another path\n\n```\n$ sscli -b https://x.com -r dist -f xml -o \u003e www/sm.xml\n```\n\n#### Get subset of a directory\n\n```\n$ sscli -b https://x.com/foo -r dist/foo -f xml -o \u003e dist/sitemap.xml\n```\n\n#### Generate TXT sitemap for image assets\n\n```\n$ sscli -b https://x.com -r dist -m '**/*.{jpg,jpeg,gif,png,bmp,webp,svg}' -f txt\n```\n\n## Programmatic Use\n\n`static-sitemap-cli` can also be used as a Node module.\n\n```js\nimport {\n  generateUrls,\n  generateXmlSitemap,\n  generateTxtSitemap\n} from 'static-sitemap-cli'\n\nconst options = {\n  base: 'https://x.com',\n  root: 'path/to/root',\n  match: ['**/*html'],\n  ignore: ['404.html'],\n  changefreq: [],\n  priority: [],\n  robots: true,\n  concurrent: 32,\n  clean: true,\n  slash: false\n}\n\ngenerateUrls(options).then((urls) =\u003e {\n  const xmlString = generateXmlSitemap(urls)\n  const txtString = generateTxtSitemap(urls)\n  ...\n})\n```\n\nUsing the XML sitemap generator by itself:\n\n```js\nimport { generateXmlSitemap } from 'static-sitemap-cli'\n\nconst urls = [\n  { loc: 'https://x.com/', lastmod: '2022-02-22' },\n  { loc: 'https://x.com/about', lastmod: '2022-02-22' },\n  ...\n]\n\nconst xml = generateXmlSitemap(urls)\n```\n\n## Development\n\nStandard Github [contribution workflow](https://github.com/firstcontributions/first-contributions)\napplies.\n\n#### Tests\n\nTest specs are at `test/spec.js`. To run the tests:\n\n```\n$ npm run test\n```\n\n## License\n\nISC\n\n## Changelog\n\nChanges are logged in the [releases](https://github.com/zerodevx/static-sitemap-cli/releases) page.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzerodevx%2Fstatic-sitemap-cli","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzerodevx%2Fstatic-sitemap-cli","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzerodevx%2Fstatic-sitemap-cli/lists"}