https://github.com/astronomersiva/sitemap-static
https://github.com/astronomersiva/sitemap-static
Last synced: about 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/astronomersiva/sitemap-static
- Owner: astronomersiva
- License: other
- Created: 2018-12-02T07:25:22.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2020-06-30T16:59:32.000Z (almost 5 years ago)
- Last Synced: 2025-02-22T20:36:04.898Z (2 months ago)
- Language: JavaScript
- Size: 61.5 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# sitemap-static
Generate a sitemap for a static website based on files on disk.
This is a fork of [sitemap-static](https://github.com/tmcw/sitemap-static/) that
adds several features and removes certain existing functionality.### install
`npm install --save @astronomersiva/sitemap-static`
### Usage
```javascript
let generateSitemap = require('sitemap-static');
let fs = require('fs');let writer = fs.createWriteStream('/path/to/your/sitemap.xml');
generateSitemap(writer, {
findRoot: '.',
ignoreFiles: [/ ** An array of files to ignore in the sitemap */],
prefix: 'https://www.sivasubramanyam.me/',
pretty: false
})
```### findRoot
The base directory whose contents you want a sitemap for.
### Ignore Files
An array of files and directories to ignore in the sitemap. Example,
```javascript
[
'ignore-me.html',
'ignore-everything-in-me/'
]
```### 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 |
| --- | --- |
| `http://www.example.com/index.html` | `http://www.example.com/` |
| `http://www.example.com/about.html` | `http://www.example.com/about` |
| `http://www.example.com/author/index.html` | `http://www.example.com/author` |
| `http://www.example.com/author/main.html` | `http://www.example.com/author/main` |### addTrailingSlash
If you pass this as `true` when `--pretty` is also true, a trailing slash will be added to the URLs.
For example,| !addTrailingSlash | addTrailingSlash |
| --- | --- |
| `http://www.example.com/` | `http://www.example.com/` |
| `http://www.example.com/about` | `http://www.example.com/about/` |
| `http://www.example.com/author` | `http://www.example.com/author/` |
| `http://www.example.com/author/main` | `http://www.example.com/author/main/` |