Freelance web and mobile developer - Edinburgh, UK

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

January 21, 2015

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); });
  • On success, err will be undefined.

  • On error, err will be set to an error message. This happens if the sitemap URL could not be reached or any of the sitemap submission attempts failed.

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

Looking for an experienced full stack developer for your web or mobile project?
I'm available for contract work in Edinburgh and can also work remotely.