Name: handlebars-helper-sitemap
Owner: Helpers
Description: Handlebars helpers and templates for generating a sitemap.
Created: 2017-02-11 20:25:00.0
Updated: 2017-08-16 20:24:14.0
Pushed: 2017-07-20 19:22:33.0
Homepage: https://github.com/helpers/handlebars-helper-sitemap
Size: 17
Language: JavaScript
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
Handlebars helpers and templates for generating a sitemap.
Install with npm:
m install --save handlebars-helper-sitemap
Register the sitemap helpers and templates with assemble:
assemble = require('assemble');
sitemap = require('handlebars-helper-sitemap');
itemap helpers and templates
templates = sitemap.templates;
helpers = sitemap.helpers;
egister the helpers
helpers(helpers);
reate a "view" for the sitemap and tell
ssemble the engine to use for rendering
view = app.view('sitemap.xml', {
ntents: template,
gine: 'hbs'
oad "pages" for site
task('default', function() {
p.pages('templates/*.hbs');
turn app.toStream('pages')
.pipe(view.toStream()) //<= add sitemap
.pipe(app.renderFile())
.pipe(app.dest('site'));
Or you can do it as separate tasks if you want
oad "pages" for site
task('pages', function() {
p.pages('templates/*.hbs');
turn app.toStream('pages')
.pipe(app.renderFile())
.pipe(app.dest('site'));
enerate sitemap
task('sitemap', function() {
turn view.toStream()
.pipe(app.renderFile('hbs')) // you can define engine here
.pipe(app.dest('site'));
task('default', ['pages', 'sitemap']);
Global data
The only required value is sitemap.url
, which will be prefixed to all of the relative paths for each <loc>
tag:
data('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:
onLoad(/\.md$/, function(file, next) {
le.data.sitemap = file.data.sitemap || {};
(file.stem === 'index') {
file.data.sitemap.priority = '1.0';
else {
file.data.sitemap.priority = '0.5';
xt();
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.
Generates a sitemap like the following:
l version="1.0" encoding="UTF-8"?>
set xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
rl>
<loc>https://breakdance.io/aaa.html</loc>
<lastmod>2017-02-11</lastmod>
<changefreq>daily</changefreq>
<priority>0.8</priority>
url>
rl>
<loc>https://breakdance.io/bbb.html</loc>
<lastmod>2017-02-02</lastmod>
<changefreq>daily</changefreq>
<priority>0.8</priority>
url>
rl>
<loc>https://breakdance.io/ccc.html</loc>
<lastmod>2017-02-02</lastmod>
<changefreq>daily</changefreq>
<priority>0.8</priority>
url>
lset>
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.
(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:
m install -g verbose/verb#dev verb-generate-readme && verb
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:
m install && npm test
Jon Schlinkert
Copyright © 2017, Jon Schlinkert. Released under the MIT License.
This file was generated by verb-generate-readme, v0.6.0, on July 20, 2017.