Gathering detailed insights and metrics for express-sitemap-xml
Gathering detailed insights and metrics for express-sitemap-xml
Gathering detailed insights and metrics for express-sitemap-xml
Gathering detailed insights and metrics for express-sitemap-xml
npm install express-sitemap-xml
Typescript
Module System
Node Version
NPM Version
JavaScript (100%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
68 Stars
31 Commits
11 Forks
4 Watchers
9 Branches
3 Contributors
Updated on May 08, 2025
Latest Version
3.1.0
Package Id
express-sitemap-xml@3.1.0
Unpacked Size
12.48 kB
Size
4.73 kB
File Count
5
NPM Version
10.5.0
Node Version
20.12.1
Published on
Apr 19, 2024
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
2
3
sitemap.xml
from a list of URLsCreate an Express middleware that serves sitemap.xml
from a list of URLs.
This package automatically handles sitemaps with more than 50,000 URLs. In these cases, multiple sitemap files will be generated along with a "sitemap index" to comply with the sitemap spec and requirements from search engines like Google.
If only one sitemap file is needed (i.e. there are less than 50,000 URLs) then
it is served directly at /sitemap.xml
. Otherwise, a sitemap index is served at
/sitemap.xml
and sitemaps at /sitemap-0.xml
, /sitemap-1.xml
, etc.
npm install express-sitemap-xml
You can see this package in action on BitMidi, a site for listening to your favorite MIDI files.
The easiest way to use this package is with the Express middleware.
1const express = require('express') 2const expressSitemapXml = require('express-sitemap-xml') 3 4const app = express() 5 6app.use(expressSitemapXml(getUrls, 'https://bitmidi.com')) 7 8async function getUrls () { 9 return await getUrlsFromDatabase() 10}
Remember to add a Sitemap
line to robots.txt
like this:
Sitemap: https://bitmidi.com/sitemap.xml
The package can also be used without the Express middleware.
1const { buildSitemaps } = require('express-sitemap-xml') 2 3async function run () { 4 const urls = ['/1', '/2', '/3'] 5 const sitemaps = await buildSitemaps(urls, 'https://bitmidi.com') 6 7 console.log(Object.keys(sitemaps)) 8 // ['/sitemap.xml'] 9 10 console.log(sitemaps['/sitemap.xml']) 11 // `<?xml version="1.0" encoding="utf-8"?> 12 // <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"> 13 // <url> 14 // <loc>https://bitmidi.com/1</loc> 15 // <lastmod>${getTodayStr()}</lastmod> 16 // </url> 17 // <url> 18 // <loc>https://bitmidi.com/2</loc> 19 // <lastmod>${getTodayStr()}</lastmod> 20 // </url> 21 // <url> 22 // <loc>https://bitmidi.com/3</loc> 23 // <lastmod>${getTodayStr()}</lastmod> 24 // </url> 25 // </urlset>` 26})
Remember to add a Sitemap
line to robots.txt
like this:
Sitemap: https://bitmidi.com/sitemap.xml
middleware = expressSitemapXml(getUrls, base)
Create a sitemap.xml
middleware. Both arguments are required.
The getUrls
argument specifies an async function that resolves to an array of
URLs to be included in the sitemap. Each URL in the array can either be an
absolute or relative URL string like '/1'
, or an object specifying additional
options about the URL:
1{ 2 url: '/1', 3 lastMod: new Date('2000-02-02'), // optional (specify `true` for today's date) 4 changeFreq: 'weekly' // optional 5}
For more information about these options, see the sitemap spec. Note that the priority
option is not supported because Google ignores it.
The getUrls
function is called at most once per 24 hours. The resulting
sitemap(s) are cached to make repeated HTTP requests faster.
The base
argument specifies the base URL to be used in case any URLs are
specified as relative URLs. The argument is also used if a sitemap index needs
to be generated and sitemap locations need to be specified, e.g.
${base}/sitemap-0.xml
becomes https://bitmidi.com/sitemap-0.xml
.
sitemaps = expressSitemapXml.buildSitemaps(urls, base)
Create an object where the keys are sitemap URLs to be served by the server and the values are strings of sitemap XML content. (This function does no caching.)
The urls
argument is an array of URLs to be included in the sitemap. Each URL
in the array can either be an absolute or relative URL string like '/1'
, or an
object specifying additional options about the URL. See above for more info
about the options.
The base
argument is the same as above.
The return value is an object that looks like this:
1{ 2 '/sitemap.xml': '<?xml version="1.0" encoding="utf-8"?>...' 3}
Or if multiple sitemaps are needed, then the return object looks like this:
1{ 2 '/sitemap.xml': '<?xml version="1.0" encoding="utf-8"?>...', 3 '/sitemap-0.xml': '<?xml version="1.0" encoding="utf-8"?>...', 4 '/sitemap-1.xml': '<?xml version="1.0" encoding="utf-8"?>...' 5}
MIT. Copyright (c) Feross Aboukhadijeh.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
Reason
Found 2/22 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
Reason
security policy file not detected
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More