Product
Introducing SSO
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
sitemaps
Advanced tools
Readme
A simple sitemap.xml generator.
npm i sitemaps --save
createSitemap()
Generates a sitemap XML file with the custom URLs on the specified path.
import path from 'path';
import { createSitemap } from 'sitemaps';
createSitemap({
filePath: path.join(__dirname, 'sitemap.xml'),
urls: [
{
loc: 'https://example.com',
lastmod: '2023-01-31',
changefreq: 'weekly',
priority: 1,
},
{
loc: 'https://example.com/about',
lastmod: '2022-10-21',
changefreq: 'monthly',
priority: 0.8,
},
{
loc: 'https://example.com/contact',
lastmod: '2021-04-30',
changefreq: 'yearly',
priority: 0.4,
},
],
});
// The sitemap.xml file will be created in the specified path.
Attribute | Type | Description |
---|---|---|
loc | string (required) | URL of the page. This URL must begin with the protocol (such as http). This value must be less than 2,048 characters. |
lastmod | string (optional) | The date of last modification of the page. This date should be in W3C Datetime format. This format allows you to omit the time portion, if desired, and use YYYY-MM-DD . |
changefreq | enum (optional) | How frequently the page is likely to change. Valid values are always , hourly , daily , weekly , monthly , yearly , and, never . |
priority | number (optional) | The priority of this URL relative to other URLs on your site. Valid values range from 0 to 1 . The default priority of a page is 0.5 . |
createSitemapIndex()
Generates a sitemap index XML file with the custom sitemaps on the specified path.
import path from 'path';
import { createSitemapIndex } from 'sitemaps';
createSitemapIndex({
filePath: path.join(__dirname, 'sitemap-index.xml'),
sitemaps: [
{
loc: 'https://example.com/sitemap-1.xml',
lastmod: '2023-01-31',
},
{
loc: 'https://example.com/sitemap-2.xml',
lastmod: '2023-01-31',
},
],
});
// The sitemapIndex.xml file will be created in the specified path.
Attribute | Type | Description |
---|---|---|
loc | string (required) | Identifies the location of the Sitemap. |
lastmod | string (optional) | Identifies the time that the corresponding Sitemap file was modified. The value should be in W3C Datetime format. |
Open source under the terms of the MIT License.
Maintained by Diogo Capela.
FAQs
A simple sitemap.xml generator.
The npm package sitemaps receives a total of 246 weekly downloads. As such, sitemaps popularity was classified as not popular.
We found that sitemaps demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Product
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.