sitemap-xml

Create a sitemap.xml file by streaming URLs

Usage no npm install needed!

<script type="module">
  import sitemapXml from 'https://cdn.skypack.dev/sitemap-xml';
</script>

README

sitemap.xml

Stream URLs to the sitemap.

Build Status

Usage

var sitemap = require('sitemap-xml');

// Raw node
var http = require('http');
http.createServer(function (request, response) {
    res.writeHead(200, {'Content-Type': 'application/xml'});
    var stream = sitemap();
    stream.pipe(response);
    stream.write({ loc: 'http://example.com/', lastmod: '2013-04-21' });
    stream.write({ loc: 'http://example.com/page-1', priority: '0.9' });
    stream.end();
})

// Express
app.get('/sitemap.xml', function(request, response, next) {
    var stream = sitemap();
    stream.pipe(response);
    stream.write({ loc: 'http://example.com/', lastmod: '2013-04-21' });
    stream.write({ loc: 'http://example.com/page-1', priority: '0.9' });
    stream.end();
});