npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

starzplayarabia-sitemap

v1.8.0

Published

Sitemap-generating framework based on Eugene Kalinin sitemap library

Downloads

24

Readme

sitemap.js

sitemap.js is a high-level sitemap-generating framework that makes creating sitemap XML files easy.

Build Status

Table of Contents

TOC created by gh-md-toc

Installation

It's recommended to install via npm:

npm install --save sitemap

Usage

The main functions you want to use in the sitemap module are

var sm = require('sitemap')
// Creates a sitemap object given the input configuration with URLs
var sitemap = sm.createSitemap({ options });
// Generates XML with a callback function
sitemap.toXML( function(err, xml){ if (!err){ console.log(xml) } });
// Gives you a string containing the XML data
var xml = sitemap.toString();

Example of using sitemap.js with express:

var express = require('express')
  , sm = require('sitemap');

var app = express()
  , sitemap = sm.createSitemap ({
      hostname: 'http://example.com',
      cacheTime: 600000,        // 600 sec - cache purge period
      urls: [
        { url: '/page-1/',  changefreq: 'daily', priority: 0.3 },
        { url: '/page-2/',  changefreq: 'monthly',  priority: 0.7 },
        { url: '/page-3/'},    // changefreq: 'weekly',  priority: 0.5
        { url: '/page-4/',   img: "http://urlTest.com" }
      ]
    });

app.get('/sitemap.xml', function(req, res) {
  sitemap.toXML( function (err, xml) {
      if (err) {
        return res.status(500).end();
      }
      res.header('Content-Type', 'application/xml');
      res.send( xml );
  });
});

app.listen(3000);

Example of synchronous sitemap.js usage:

var express = require('express')
  , sm = require('sitemap');

var app = express()
  , sitemap = sm.createSitemap ({
      hostname: 'http://example.com',
      cacheTime: 600000,  // 600 sec cache period
      urls: [
        { url: '/page-1/',  changefreq: 'daily', priority: 0.3 },
        { url: '/page-2/',  changefreq: 'monthly',  priority: 0.7 },
        { url: '/page-3/' } // changefreq: 'weekly',  priority: 0.5
      ]
    });

app.get('/sitemap.xml', function(req, res) {
  res.header('Content-Type', 'application/xml');
  res.send( sitemap.toString() );
});

app.listen(3000);

Example of dynamic page manipulations into sitemap:

var sitemap = sm.createSitemap ({
      hostname: 'http://example.com',
      cacheTime: 600000
    });
sitemap.add({url: '/page-1/'});
sitemap.add({url: '/page-2/', changefreq: 'monthly', priority: 0.7});
sitemap.del({url: '/page-2/'});
sitemap.del('/page-1/');

Example of pre-generating sitemap based on existing static files:

var sm = require('sitemap')
    , fs = require('fs');

var sitemap = sm.createSitemap({
    hostname: 'http://www.mywebsite.com',
    cacheTime: 600000,  //600 sec (10 min) cache purge period
    urls: [
        { url: '/' , changefreq: 'weekly', priority: 0.8, lastmodrealtime: true, lastmodfile: 'app/assets/index.html' },
        { url: '/page1', changefreq: 'weekly', priority: 0.8, lastmodrealtime: true, lastmodfile: 'app/assets/page1.html' },
        { url: '/page2'    , changefreq: 'weekly', priority: 0.8, lastmodrealtime: true, lastmodfile: 'app/templates/page2.hbs' } /* useful to monitor template content files instead of generated static files */
    ]
});

fs.writeFileSync("app/assets/sitemap.xml", sitemap.toString());

Example of images with captions:

var sitemap = sm.createSitemap({
      urls: [{
        url: 'http://test.com/page-1/',
        img: [
          {
            url: 'http://test.com/img1.jpg',
            caption: 'An image',
            title: 'The Title of Image One',
            geoLocation: 'London, United Kingdom',
            license: 'https://creativecommons.org/licenses/by/4.0/'
          },
          {
            url: 'http://test.com/img2.jpg',
            caption: 'Another image',
            title: 'The Title of Image Two',
            geoLocation: 'London, United Kingdom',
            license: 'https://creativecommons.org/licenses/by/4.0/'
          }
        ]
      }]
    });

Example of videos:

Description specifications. Required fields are thumbnail_loc, title, and description.

var sitemap = sm.createSitemap({
      urls: [{
        url: 'http://test.com/page-1/',
        video: [
          { thumbnail_loc: 'http://test.com/tmbn1.jpg', title: 'A video title', description: 'This is a video' },
          {
            thumbnail_loc: 'http://test.com/tmbn2.jpg',
            title: 'A video with an attribute',
            description: 'This is another video',
            'player_loc': 'http://www.example.com/videoplayer.mp4?video=123',
            'player_loc:autoplay': 'ap=1'
          }
        ]
      }]
    });

Example of indicating alternate language pages:

Description in the google's Search Console Help.

var sitemap = sm.createSitemap({
      urls: [{
        url: 'http://test.com/page-1/',
        changefreq: 'weekly',
        priority: 0.3,
        links: [
          { lang: 'en', url: 'http://test.com/page-1/', },
          { lang: 'ja', url: 'http://test.com/page-1/ja/', },
        ]
      },]
    });

Example of indicating Android app deep linking:

Description in the google's Search Console Help.

var sitemap = sm.createSitemap({
      urls: [{
        url: 'http://test.com/page-1/',
        changefreq: 'weekly',
        priority: 0.3,
        androidLink: 'android-app://com.company.test/page-1/'
      }]
    });

Example of Sitemap Styling

var sitemap = sm.createSitemap({
      urls: [{
        url: 'http://test.com/page-1/',
        changefreq: 'weekly',
        priority: 0.3,
        links: [
          { lang: 'en', url: 'http://test.com/page-1/', },
          { lang: 'ja', url: 'http://test.com/page-1/ja/', },
        ]
      },],
      xslUrl: 'sitemap.xsl'
    });

Example of mobile URL

Description in the google's Search Console Help.

var sitemap = sm.createSitemap({
      urls: [{
        url: 'http://mobile.test.com/page-1/',
        changefreq: 'weekly',
        priority: 0.3,
        mobile: true
      },],
      xslUrl: 'sitemap.xsl'
    });

Example of using HH:MM:SS in lastmod

var sm = require('sitemap')
  , sitemap = sm.createSitemap({
      hostname: 'http://www.mywebsite.com',
      urls: [{
        url: 'http://mobile.test.com/page-1/',
        lastmodISO: '2015-06-27T15:30:00.000Z',
        changefreq: 'weekly',
        priority: 0.3
      }]
    });

Example of Sitemap Index as String

var sm = require('sitemap')
  , smi = sm.buildSitemapIndex({
      urls: ['https://example.com/sitemap1.xml', 'https://example.com/sitemap2.xml'],
      xslUrl: 'https://example.com/style.xsl' // optional
    });

Example of Sitemap Index

var sm = require('sitemap')
  , smi = sm.createSitemapIndex({
      cacheTime: 600000,
      hostname: 'http://www.sitemap.org',
      sitemapName: 'sm-test',
      sitemapSize: 1,
      targetFolder: require('os').tmpdir(),
      urls: ['http://ya.ru', 'http://ya2.ru']
      // optional:
      // callback: function(err, result) {}
    });

Testing

➥ git clone https://github.com/ekalinin/sitemap.js.git
➥ cd sitemap.js
➥ make env
➥ . env/bin/activate
(env) ➥ make test
./node_modules/expresso/bin/expresso ./tests/sitemap.test.js

   100% 33 tests

License

See LICENSE file.