easy-express-sitemap-generator
v0.0.3
Published
This is an npm package for creating sitemaps easily with Express.
Downloads
2
Maintainers
Readme
easy-express-sitemap-generator
This is an npm package for creating sitemaps easily with Express.
Install
npm install easy-express-sitemap-generator
# or
yarn add easy-express-sitemap-generator
Usage
const express = require('express');
const app = express();
const generateSitemap = require('easy-express-sitemap-generator');
app.get('/', (req, res) => {
res.send('path: "https://example.com/"');
});
app.get('/about', (req, res) => {
res.send('path: "https://example.com/about"');
});
const YOUR_SITE_URL = 'http://example.com';
const sitemap = generateSitemap(app, YOUR_SITE_URL);
console.log(sitemap);
↓
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc>
http://example.com/
</loc>
</url>
<url>
<loc>
http://example.com/about
</loc>
</url>
</urlset>