How do I also generate a sitemap for my facets?

I am using algolia-sitemap to generate a loc for each of my record types, and this is seemingly working just fine.

My site also supports faceted search which can be specified with query string parameter, and I would like to be able to instruct the Google Bot on these URL’s as well. The instructions at seem to suggest this is possible.

An example of a faceted search URL for my site looks like:

I have all of these facet strings saved in an array, which I can easily map over. The doc’s seem to suggest that I can do this as so:

	sitemapLoc: '',
	outputFolder: 'sitemaps',
	params: {
		facets: =>

}).then(() => {

However, when I run this script, the final sitemap does not include any of these facets query string parameters. There is no script error, but also no results. It’s basically ignored.

My first question is: What am I doing wrong here?

And related to that is: Do I need to generate a 2nd sitemap? I am seeing that Google supports this, but it’s not clear from the Algolia doc’s how to add in a 2nd sitemap for the same site.

Hey there!

Could you add the complete code snippet, it seems like it’s missing parts :slight_smile:

The example here is more how to only add one per category from the Algolia data. In the example we didn’t consider yet what would happen if you want both a configuration for all hits, but also for all categories. What you can do is this:

const algoliaSitemap = require('algolia-sitemap');

const algoliaConfig = {
  appId: 'APP_ID',
  apiKey: 'API_KEY',
  indexName: 'NAME',

const alreadyAdded = {};

function getCategories({ category }) {
  if (!category || !category.length || category.some(c => alreadyAdded[c])) {
    return false;
  category.forEach(c => (alreadyAdded[c] = c));
  return => ({
    loc: `${c}`,

const getDetail = ({ objectID }) => ({
  loc: `${objectID}`,
  lastmod: new Date().toISOString(),
  priority: Math.random(),

function hitToParams(hit) {
  const categories = getCategories(hit);
  const detail = getDetail(hit);
  return categories.concat(detail);

  sitemapLoc: '',
  outputFolder: 'sitemaps',
  .then(() => {
    console.log('Done generating sitemaps'); // eslint-disable-line no-console
  .catch(console.error); // eslint-disable-line no-console

Does that help you?