Generate a sitemap for your assemble generated site.
Here is a simple example of generating some html files from handle bars (.hbs) files.
'use strict';
var app = require('assemble')();
var path = require('path');
var ext = require('gulp-extname');
app.option('layout', 'default');
app.layouts(path.join(__dirname, 'src/layouts/**/*.hbs'));
app.task('default', function () {
//Here we are using a gulp plugin to replace the .hbs ext with .html for all the pages.
return app.src('src/pages/**/*.hbs', { layout: 'default' })
.pipe(app.renderFile())
.pipe(ext()))
.pipe(app.dest('wwwroot'));
});
module.exports = app;
Now that we have some html files generated, we need to include a sitemap for the bots. This can be done easily using a gulp plugin. This is possible beacause assemble supports can use any gulp plugin. So, we simply add the gulp-sitemap plugin, configure it will the sites base url and configure the tasks so that the sitemap is created after the pages generated.
'use strict';
var app = require('assemble')();
var path = require('path');
var ext = require('gulp-extname');
var sitemap = require('gulp-sitemap');
app.option('layout', 'default');
app.layouts(path.join(__dirname, 'src/layouts/**/*.hbs'));
app.task('pages', function () {
//Here we are using a gulp plugin to replace the .hbs ext with .html for all the pages.
return app.src('src/pages/**/*.hbs', { layout: 'default' })
.pipe(app.renderFile())
.pipe(ext())
.pipe(app.dest('wwwroot'));
});
app.task('default', ['pages'], function () {
//Here we are using a gulp plugin to generate a sitemap for the files generated by the pages task.
return app.src('wwwroot/**/*.html')
.pipe(sitemap({
siteUrl: 'http://whatever.site'
}))
.pipe(app.dest('wwwroot'));
});
module.exports = app;