Socket
Book a DemoInstallSign in
Socket

sitemap-xmls

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sitemap-xmls

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

1.4.1
latest
Source
npmnpm
Version published
Maintainers
1
Created
Source

sitemap-xmls

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

Installation

npm install sitemap-xmls --save

Usage

const smXml = require('sitemap-xmls');

const sitemapXml = new smXml('demo', 'https://demo.com/sitemap/',{
  releasePath: './release/'
});

// add a sitemap with type of 'apps'
sitemapXml.addSitemapType('apps', 'monthly', 0.8);

sitemapXml.addLine('apps', 'https://demo.com/apps-demo-1.html');
sitemapXml.addLine('apps', 'https://demo.com/apps-demo-2.html');
sitemapXml.addLine('apps', 'https://demo.com/apps-demo-3.html', {
  lastmod: '2018-10-01',
  changefreq: 'daily',
  priority: 0.6
});

// important: don't forget the 'end()'
sitemapXml.end('apps');


// add another sitemap with type of 'topics'
sitemapXml.addSitemapType('topics', 'daily', 0.9);

sitemapXml.addLine('topics', 'https://demo.com/topics-demo-1.html');
sitemapXml.addLine('topics', 'https://demo.com/topics-demo-2.html');
sitemapXml.addLine('topics', 'https://demo.com/topics-demo-3.html');

// important: don't forget the 'end()'
sitemapXml.end('topics');


// finally, generate the index file
sitemapXml.createIndex();

after that, it will generator sitemap just like in ./release/demo/:

  • demo/index.json
  • demo/index.xml
  • demo/apps_10000.xml.gz
  • demo/topics_10000.xml.gz

【demo/index.json】

{"index":"demo/index.xml","files":["demo/apps_10000.xml.gz","demo/topics_10000.xml.gz"]}

【demo/index.xml】

<?xml version="1.0" encoding="UTF-8"?>
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:mobile="http://www.google.com/schemas/sitemap-mobile/1.0" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1" xmlns:video="http://www.google.com/schemas/sitemap-video/1.1">
<sitemap>
<loc>https://demo.com/sitemap/demo/apps_10000.xml.gz</loc>
<loc>https://demo.com/sitemap/demo/topics_10000.xml.gz</loc>
</sitemap>
</sitemapindex>

【demo/apps_10000.xml.gz】

<?xml version="1.0" encoding="UTF-8"?><urlset>
<url>
<loc>https://demo.com/apps-demo-1.html</loc>
<lastmod>2018-07-18</lastmod>
<changefreq>monthly</changefreq>
<priority>0.8</priority>
</url>
<url>
<loc>https://demo.com/apps-demo-2.html</loc>
<lastmod>2018-07-18</lastmod>
<changefreq>monthly</changefreq>
<priority>0.8</priority>
</url>
<url>
<loc>https://demo.com/apps-demo-3.html</loc>
<lastmod>2018-10-01</lastmod>
<changefreq>daily</changefreq>
<priority>0.6</priority>
</url>
</urlset>

【demo/topics_10000.xml.gz】

<?xml version="1.0" encoding="UTF-8"?><urlset>
<url>
<loc>https://demo.com/topics-demo-1.html</loc>
<lastmod>2018-07-18</lastmod>
<changefreq>daily</changefreq>
<priority>0.9</priority>
</url>
<url>
<loc>https://demo.com/topics-demo-2.html</loc>
<lastmod>2018-07-18</lastmod>
<changefreq>daily</changefreq>
<priority>0.9</priority>
</url>
<url>
<loc>https://demo.com/topics-demo-3.html</loc>
<lastmod>2018-07-18</lastmod>
<changefreq>daily</changefreq>
<priority>0.9</priority>
</url>
</urlset>

Params

changefreq

  • always
  • hourly
  • daily
  • weekly
  • monthly
  • yearly
  • never

priority

0.0 ~ 1.0

mobile

<mobile:mobile type="mobile"/> :移动网页      
<mobile:mobile type="pc,mobile"/>:自适应网页
<mobile:mobile type="htmladapt"/>:代码适配

无该上述 mobile 标签表示为PC网页。

附:相关文档

  • 百度 sitemap
  • sitemaps.org

Keywords

sitemap

FAQs

Package last updated on 12 Sep 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.