Skip to content

Instantly share code, notes, and snippets.

@t18n
Last active May 19, 2020 19:32
Show Gist options
  • Save t18n/26070caf9e4a495a6083b3d4b57ce623 to your computer and use it in GitHub Desktop.
Save t18n/26070caf9e4a495a6083b3d4b57ce623 to your computer and use it in GitHub Desktop.
[Generate sitemap with sitemap-generator] Javascript snippet for generating sitemap with sitemap-generator #javascript
// Install sitemap-generator first
const SitemapGenerator = require('sitemap-generator');
// create generator
var generator = SitemapGenerator('http://localhost:8080/', {
maxDepth: 10,
filepath: 'src/sitemap.xml',
maxEntriesPerFile: 50000,
stripQuerystring: true
});
// register event listeners
generator.on('done', () => {
console.log('-> Sitemap Generated');
});
// start the crawler
generator.start();
// -> node Generate-site-map.js
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment