A metalsmith plugin for generating a sitemap.xml file.
npm install metalsmith-sitemap> A metalsmith plugin for generating a sitemap
This plugin allows you to generate a sitemap.xml from your source files. By default it looks for any .html files and processes them with sitemap.js.
``bash`
$ npm install metalsmith-sitemap
Configuration in metalsmith.json:
`json`
{
"plugins": {
"metalsmith-sitemap": {
"hostname": "http://www.website.com"
}
}
}
You can pass options to metalsmith-sitemap with the Javascript API or CLI. The options are:
##### hostname
* required
The hostname used for generating the urls.
##### changefreq
* optionaldefault: weekly
*
Change the default changefreq.
##### pattern
* optionaldefault: '/.html'
A multimatch pattern. Only files that match this pattern will be included in the sitemap. Can be a string or an array of strings.
##### priority
* optionaldefault: '0.5'
*
Change the default priority.
##### output
* optionaldefault: 'sitemap.xml'
*
Change the output file for the sitemap.
##### lastmod
* optional
Add a lastmodified date to the sitemap. Should be a Date object and can be passed through the Javascript API or the frontmatter.
##### links
* optional
Allows you to define alternate language pages. This accepts nested properties in dot notation via lodash.get.
##### omitExtension
* optionaldefault: false
*
Will remove extensions from the urls in the sitemap. Useful when you're rewriting urls.
##### omitIndex
* optionaldefault: false
*
Will replace any paths ending in index.html with ''. Useful when you're using metalsmith-permalinks.
##### modifiedProperty
* optionaldefault: lastmod
*
Allows you to choose which property to use as the last modified string. This accepts nested properties in dot notation via lodash.get.
##### urlProperty
* optionaldefault: canonical
*
Allows you to choose which property to use as the canonical url in the frontmatter. This accepts nested properties in dot notation via lodash.get.
##### privateProperty
* optionaldefault: private
*
Allows you to choose which property to use for ignoring a file in the frontmatter. This accepts nested properties in dot notation via lodash.get.
##### priorityProperty
* optionaldefault: priority
*
Allows you to choose which property to use for your sitemap priority in the frontmatter. This accepts nested properties in dot notation via lodash.get.
Some values can also be set on a file-to-file basis from a file's frontmatter, the options are:
* canonical: will override the filename used to generate the url. The path is relative to the hostname.changefreq
* : will override any other settings for changefreq for the current file.lastmod
* : will override any other settings for lastmod for the current file.priority
* : will override any other settings for priority for the current file.private
* : will exclude the file from the sitemap when set to true.
For example:
`html``
---
canonical: 'different'
changefreq: always
lastmod: 2014-12-01
priority: 1.0
private: true
---
MIT
[npm-badge]: https://img.shields.io/npm/v/metalsmith-sitemap.svg
[npm-url]: https://www.npmjs.com/package/metalsmith-sitemap
[travis-badge]: https://travis-ci.org/ExtraHop/metalsmith-sitemap.svg?branch=master
[travis-url]: https://travis-ci.org/ExtraHop/metalsmith-sitemap