|
1 | 1 | # static-sitemap-cli |
2 | | -CLI to generate static sitemaps in 10 minutes. |
| 2 | + |
| 3 | +Simple CLI to pre-generate XML sitemaps for static sites locally. |
| 4 | + |
| 5 | +Built in 10 minutes. :stuck_out_tongue_winking_eye: |
| 6 | + |
| 7 | + |
| 8 | +### Install |
| 9 | + |
| 10 | +``` |
| 11 | +npm i -g static-sitemap-cli |
| 12 | +``` |
| 13 | + |
| 14 | + |
| 15 | +### Usage |
| 16 | + |
| 17 | +Syntax: `static-sitemap-cli <BASEURL> <options>` |
| 18 | + |
| 19 | +At its simplest, just go to your `dist` folder and run: |
| 20 | + |
| 21 | +``` |
| 22 | +static-sitemap-cli https://example.com > sitemap.xml |
| 23 | +``` |
| 24 | + |
| 25 | +By default outputs to `stdout`. So that you can pipe it to do other stuff. |
| 26 | + |
| 27 | + |
| 28 | +### Arguments |
| 29 | + |
| 30 | +| Argument | Description | |
| 31 | +|----------|-------------| |
| 32 | +| BASEURL | Base URL that is prefixed to all location entries. For example: https://example.com/ | |
| 33 | + |
| 34 | + |
| 35 | +### Options |
| 36 | + |
| 37 | +| Option | Long | Description | |
| 38 | +|--------|--------------|-----------------------------------------------------------------| |
| 39 | +| -h | --help | show CLI help | |
| 40 | +| -v | --version | show CLI version | |
| 41 | +| -r | --root | [default: .] root dir to start from | |
| 42 | +| -m | --match | [default: .html] comma-separated list of extensions to match | |
| 43 | +| -i | --ignore | [default: 404.html] comma-separated list of globs to ignore | |
| 44 | +| -p | --priority | comma-separated glob/priority pair; eg: foo/*.html,0.1 | |
| 45 | +| -f | --changefreq | comma-separated glob/changefreq pair; eg: foo/*.html,daily | |
| 46 | +| -n | --no-clean | disable clean URLs | |
| 47 | +| -s | --slash | add trailing slash to all URLs | |
| 48 | + |
| 49 | +**Clean URLs** |
| 50 | + |
| 51 | +Whether or not to include the `.html` extension. By default, something like: |
| 52 | + |
| 53 | +`https://example.com/foo/index.html` becomes `https://example.com/foo`. |
| 54 | + |
| 55 | +Pass `-n` option to disable this behavior. |
| 56 | + |
| 57 | +**Trailing Slashes** |
| 58 | + |
| 59 | +Control whether or not URLs should include trailing slashes. For example: |
| 60 | + |
| 61 | +`https://example.com/bar/index.html` becomes `https://example.com/bar/`. |
| 62 | + |
| 63 | +For obvious reasons, this cannot be used together with `-n`. |
| 64 | + |
| 65 | + |
| 66 | +### Examples |
| 67 | + |
| 68 | +**Create sitemap for `dist/` folder** |
| 69 | + |
| 70 | +``` |
| 71 | +static-sitemap-cli https://example.com -r dist/ > dist/sitemap.xml |
| 72 | +``` |
| 73 | + |
| 74 | +Note: Just put `dist/` for that location, not `dist/.` or `./dist/**`. |
| 75 | + |
| 76 | +**Ignore a bunch of files** |
| 77 | + |
| 78 | +``` |
| 79 | +static-sitemap-cli https://example.com -i 404.html,foo/*.html > sm.xml |
| 80 | +``` |
| 81 | + |
| 82 | +**Set priority of certain pages** |
| 83 | + |
| 84 | +By default, the optional `<priority>` label ([protocol reference](https://www.sitemaps.org/protocol.html)) is excluded, |
| 85 | +so every pages' default is 0.5. To change the *relative* priority (to 0.1) of certain pages: |
| 86 | + |
| 87 | +``` |
| 88 | +static-sitemap-cli https://example.com -p **/privacy-policy/**,0.1 **/terms-of-service/**,0.1 > sm.xml |
| 89 | +``` |
| 90 | + |
| 91 | + |
| 92 | +### To-do |
| 93 | + |
| 94 | +Add tests! :sweat_smile: |
| 95 | + |
| 96 | + |
| 97 | +### Changelog |
| 98 | + |
| 99 | +**v0.1.0 - 2019-07-26:** |
| 100 | +* Initial release. |
| 101 | + |
| 102 | + |
| 103 | + |
0 commit comments