Grunt plugin for generating XML sitemaps for search engine indexing.
This plugin requires Grunt.
If you haven't used Grunt before, be sure to check out the Getting Started guide, as it explains how to create a Gruntfile as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:
npm install grunt-xml-sitemap --save-dev
Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:
grunt.loadNpmTasks('grunt-xml-sitemap');
In your project's Gruntfile, add a section named xml_sitemap
to the data object passed into grunt.initConfig()
.
grunt.initConfig({
xml_sitemap: {
options: {
// Task-specific options go here.
},
your_target: {
// Target-specific file lists and/or options go here.
},
},
})
Type: String
Default value: 'weekly'
A string value that is used to defined the change frequency.
Type: String
Default value: 'tmp/'
A string value that is used to define the output directory.
Type: String
Default value: 'sitemap'
A string value that is used to define the filename (outputs sitemap.xml).
Type: String
Default value: 'pkg.homepage'
A string value that is used to define the site root of the URL. Defaults to homepage from package.json
.
Type: Bool
Default value: true
A boolean value that is used to determine whether to strip index.html
from the URL.
Type: String
Default value: grunt.template.today('yyyy-mm-dd\'T\'HH:MM:ss.000\'Z\'')
A string value that is used to define the last modified date. Defaults to current date using grunt.template.today( )
.
Type: String
Default value: '0.5'
A string value that is used to define the priority.
In this example, the default options are used to generate the XML sitemap.
grunt.initConfig({
xml_sitemap: {
default_options: {
files: [
{
expand: true,
cwd: 'src/',
src: [
'**/*.html'
]
}
]
}
}
});
In this example, custom options are used to generate the XML sitemap.
grunt.initConfig({
xml_sitemap: {
custom_options: {
options: {
changefreq: 'weekly',
dest: 'tmp/',
fileName: 'sitemap-custom',
siteRoot: 'http://daniel.furzeface.com/',
lastMod: '2014-10-18T09:54:31.000Z',
priority: '0.8'
},
files: [
{
expand: true,
cwd: 'src/',
src: [
'**/*.html',
'!docs/**/*.html'
]
}
]
}
}
});
To contribute either check the Waffle board or GitHub issues then work away:
- Fork it!
- Create your feature branch:
git checkout -b feature/awesome-feature
- Run:
npm install
for dependencies andnpm link
for local development - Run:
grunt develop
to build and watch for changes - Commit your changes:
git commit -m 'feat(Project): Adds awesome feature'
- Push to the branch:
git push origin feature/awesome-feature
- Submit a pull request 👍
Tips:
- In lieu of a formal styleguide, take care to maintain the existing coding style.
- Add unit tests for any new or changed functionality.
- Test your code using Grunt:
grunt test
- Install editorconfig-sublime for Sublime Text to help with consistent code formatting.
- Commit messages loosely adhere to these guidelines.
- Versioning adheres to Semver.
- 2014-10-18 v0.1.1 - Adds support for stripping
index.html
if required. - 2014-10-18 v0.1.0 - Initial release.
Copyright (c) 2014 Daniel Furze.
Licensed under the MIT license: http://danielfurze.mit-license.org