grunt-xml-sitemap
v0.2.0
Published
Grunt plugin for generating XML sitemaps for search engine indexing.
Downloads
76
Readme
grunt-xml-sitemap
Grunt plugin for generating XML sitemaps for search engine indexing.
Getting Started
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');
The 'xml_sitemap' task
Overview
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.
},
},
})
Options
options.changefreq
Type: String
Default value: 'weekly'
A string value that is used to defined the change frequency.
options.dest
Type: String
Default value: 'tmp/'
A string value that is used to define the output directory.
options.fileName
Type: String
Default value: 'sitemap'
A string value that is used to define the filename (outputs sitemap.xml).
options.siteRoot
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
.
options.stripIndex
Type: Bool
Default value: true
A boolean value that is used to determine whether to strip index.html
from the URL.
options.lastMod
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( )
.
options.priority
Type: String
Default value: '0.5'
A string value that is used to define the priority.
Usage Examples
Default Options
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'
]
}
]
}
}
});
Custom Options
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'
]
}
]
}
}
});
Contributing
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
- 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 :+1:
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.
Release History
- 2014-10-18 v0.1.1 - Adds support for stripping
index.html
if required. - 2014-10-18 v0.1.0 - Initial release.
License
Copyright (c) 2014 Daniel Furze.
Licensed under the MIT license: http://danielfurze.mit-license.org