Need a developer?

submit-sitemap: Node.js module to submit sitemaps to search engines

I’ve just uploaded a small Node.js module for submitting/pinging sitemaps to search engines called submit-sitemap. This is meant to be used after you’ve made updates to your site to encourage crawlers to reindex your pages.

The module currently submits your sitemap to Google and Bing. This saves you from having to use Google’s webmaster tools and Bing’s webmaster tools to submit your sitemap manually.

For example, I’ve used this in the last stage of Gulp build scripts that generate and deploy static sites in the following way:

  1. Generate a static site using Jekyll.
  2. Generate a sitemap file for the static site using gulp-sitemap.
  3. Upload the site and sitemap to Github pages using gulp-gh-pages.
  4. Finally, use submit-sitemap to submit the sitemap to search engines for indexing.

To install the module:

npm install submit-sitemap --save-dev

To submit your sitemap:

var submitSitemap  = require('submit-sitemap').submitSitemap;
var yourSitemapUrl = "https://www.seanw.org/sitemap.xml";

submitSitemap(yourSitemapUrl);

The optional callback parameter can be used to respond to success and failure:

submitSitemap(yourSitemapUrl, function(err) { console.error(err); });

You can find out more about the submit-sitemap module on npmjs.com and GitHub.