1.3.0 • Published 4 years ago

@letgowebteam/sitemap-generator v1.3.0

Weekly downloads
3
License
ISC
Repository
github
Last release
4 years ago

@letgowebtools/sitemap-generator

This package generates sitemap files with a limit of URLs per file given a list of URL.

Installing

npm install @letgowebteam/sitemap-generator

Usage

ParameterTypePurpose
sitemapRemoteLocationUrlstringRoot URL where the sitemaps should be hosted.
outputFilenamestringPrefix filename of index file and the rest of the sitemaps.
limitByFilenumberMaximum number of URLs in a single sitemap.
urlsstring[]List of URLs to create the sitemaps from.
outputDirstringDestination folder where all the sitemaps are going to be stored.

Example:

const sitemapGenerator = require('@letgowebtools/sitemap-generator');

(async() => {
	const sitemapRemoteLocationUrl = 'https://www.letgo.com';
	const outputFilename = 'my_amazing_sitemap';
	const limitByFile = 50000;
  const urls = [
    'https://www.example.com/test_1',
    'https://www.example.com/test_2'
  ];
  const outputDir = '/tmp/';
	
  await sitemapGenerator(
		sitemapRemoteLocationUrl,
    outputFilename,
    limitByFile,
    urls,
    outputDir
 	);
})();

Will output:

/tmp/my_amazing_sitemap-index.xml.gz
<?xml version="1.0" encoding="UTF-8"?>
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
    <sitemap>
        <loc>https://www.letgo.com/my_amazing_sitemap-0.xml</loc>
    </sitemap>
</sitemapindex>
/tmp/my_amazing_sitemap-0.xml.gz
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" 
    xmlns:news="http://www.google.com/schemas/sitemap-news/0.9" 
    xmlns:xhtml="http://www.w3.org/1999/xhtml" 
    xmlns:image="http://www.google.com/schemas/sitemap-image/1.1" 
    xmlns:video="http://www.google.com/schemas/sitemap-video/1.1">
    <url>
        <loc>https://www.example.com/test_1</loc>
    </url>
    <url>
        <loc>https://www.example.com/test_2</loc>
    </url>
</urlset>
1.3.0

4 years ago

1.2.0

4 years ago

1.1.0

4 years ago