handlebars-helper-sitemap
Handlebars helpers and templates for generating a sitemap.
Install
Install with npm:
$ npm install --save handlebars-helper-sitemap
Quickstart
Register the sitemap helpers and templates with assemble:
var assemble = ;var sitemap = ; // sitemap helpers and templatesvar templates = sitemaptemplates;var helpers = sitemaphelpers; // register the helpersapp; // create a "view" for the sitemap and tell // assemble the engine to use for renderingvar view = app; // load "pages" for siteapp;
Or you can do it as separate tasks if you want
// load "pages" for siteapp; // generate sitemapapp; app;
Defining sitemap data
Global data
The only required value is sitemap.url
, which will be prefixed to all of the relative paths for each <loc>
tag:
appdata'sitemap.url' 'https://breakdance.io';
Item data
An item
is represents a single URL in the sitemap (since you might be generating a sitemap that includes multiple collections, like "pages" and "posts", item
is used to avoid ambiguity.
You can set item.data
using yaml-front matter, or using any gulp or assemble plugin that does this, or an assemble middleware. Example:
app;
Sitemap tags
The following tags are generated using the global sitemap data and/or the item.data
for each file in the sitemap:
| Tag | Description |
| <lastmod>
| the date of last modification of the file. See the FAQ section for more details about <lastmod>
|
| <loc>
| URL of the page. This URL must begin with the protocol (such as http) and end with a trailing slash, if your web server requires it. This value must be less than 2,048 characters. |
| <changefreq>
| How frequently the page is likely to change. |
| <priority>
| The priority of this URL relative to other URLs on your site. |
See the sitemaps protocol documentation for more information about these tags.
Example sitemap
Generates a sitemap like the following:
https://breakdance.io/aaa.html 2017-02-11 daily 0.8 https://breakdance.io/bbb.html 2017-02-02 daily 0.8 https://breakdance.io/ccc.html 2017-02-02 daily 0.8
About
Contributing
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.
Please read the contributing guide for advice on opening issues, pull requests, and coding standards.
Building docs
(This project's readme.md is generated by verb, please don't edit the readme directly. Any changes to the readme must be made in the .verb.md readme template.)
To generate the readme, run the following command:
$ npm install -g verbose/verb#dev verb-generate-readme && verb
Running tests
Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:
$ npm install && npm test
Author
Jon Schlinkert
License
Copyright © 2017, Jon Schlinkert. Released under the MIT License.
This file was generated by verb-generate-readme, v0.6.0, on July 20, 2017.