{"id":13408397,"url":"https://github.com/algolia/algolia-sitemap","last_synced_at":"2025-06-19T15:42:29.474Z","repository":{"id":20327636,"uuid":"89497193","full_name":"algolia/algolia-sitemap","owner":"algolia","description":"a node library allowing you to generate sitemaps from an Algolia index. ","archived":false,"fork":false,"pushed_at":"2025-05-30T20:46:55.000Z","size":610,"stargazers_count":35,"open_issues_count":59,"forks_count":13,"subscribers_count":65,"default_branch":"master","last_synced_at":"2025-05-31T06:49:19.120Z","etag":null,"topics":["algolia","seo","sitemap","sitemap-generator"],"latest_commit_sha":null,"homepage":"https://yarn.pm/algolia-sitemap","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/algolia.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2017-04-26T15:28:21.000Z","updated_at":"2024-09-02T07:24:10.000Z","dependencies_parsed_at":"2022-08-19T03:31:11.563Z","dependency_job_id":"db1ad00c-c001-45cb-a896-e61363a367e5","html_url":"https://github.com/algolia/algolia-sitemap","commit_stats":{"total_commits":142,"total_committers":8,"mean_commits":17.75,"dds":"0.45070422535211263","last_synced_commit":"85de0f941b85f064f1a8265c5cebcbf9004bbcf8"},"previous_names":[],"tags_count":16,"template":false,"template_full_name":null,"purl":"pkg:github/algolia/algolia-sitemap","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/algolia%2Falgolia-sitemap","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/algolia%2Falgolia-sitemap/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/algolia%2Falgolia-sitemap/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/algolia%2Falgolia-sitemap/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/algolia","download_url":"https://codeload.github.com/algolia/algolia-sitemap/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/algolia%2Falgolia-sitemap/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260781428,"owners_count":23062235,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["algolia","seo","sitemap","sitemap-generator"],"created_at":"2024-07-30T20:00:52.623Z","updated_at":"2025-06-19T15:42:24.462Z","avatar_url":"https://github.com/algolia.png","language":"JavaScript","funding_links":[],"categories":["Heavy Weights","JavaScript","Algolia"],"sub_categories":["Algolia"],"readme":"# Algolia sitemap generator\n\nThis is a node library allowing you to generate sitemaps from an Algolia index.\n\n\u003e Requires node v6+ (make an issue if this is a problem for you).\n\nIt will create sitemaps, and a sitemap index in a folder of your choosing (for example `/sitemaps`). Then you can upload `/sitemaps/sitemap-index.xml` to Google for good indexing of your pages!\n\n## How does it work?\n\n1. [Browse](https://www.algolia.com/doc/api-client/javascript/advanced/#backup--export-an-index) over all entries in an Algolia index\n2. Per [50 000](https://support.google.com/webmasters/answer/183668?hl=en) links, a sitemap.n.xml is generated in the chosen folder (where n is the index)\n3. Once all Algolia data has been browsed over, a final sitemap-index.xml is being generated\n4. Let search engines know about sitemap-index.xml either by [letting them know](https://support.google.com/webmasters/answer/183668?hl=en#addsitemap) or putting it in [robots.txt](https://support.google.com/webmasters/answer/183668?hl=en#addsitemap)\n\nThis process is a script that should be ran periodically to keep the sitemaps up to date, no \"watch\" feature has been put in place (yet?)\n\n## How to use\n\nFirst install the module from `npm` (or with `yarn`):\n\n```sh\n$ npm install algolia-sitemap --save[-dev]\n$ yarn add algolia-sitemap [--dev]\n```\n\n```js\n// import the dependency\nconst algoliaSitemap = require('algolia-sitemap');\n\nalgoliaSitemap({\n  algoliaConfig,\n  sitemapLoc: 'https://yoursite.com/sitemaps',\n  outputFolder: 'sitemaps',\n  hitToParams,\n});\n```\n\nWhere `algoliaConfig` holds the setup for your index. Make sure that the API key you use has the \"browse\" capability\n\n```js\n// set up your API keys\nconst algoliaConfig = {\n  appId: 'XXXXX',\n  apiKey: 'xxxxxx', // make sure the key has \"browse\" capability\n  indexName: 'xxxxxx',\n};\n```\n\nAnd hitToParams is a function that transforms a hit into a parameters object. This function can return an object of type `Param`, an array of `Param`s or false.\n\n```js\nfunction hitToParams({ objectID, modified, downloadsRatio }) {\n  const url = ({ lang, objectID }) =\u003e\n    `https://${lang}.yoursite.com/${lang}/detail/${objectID}`;\n  const loc = url({ lang: 'en', objectID });\n  const lastmod = new Date().toISOString();\n  const priority = Math.random();\n  return {\n    loc,\n    lastmod,\n    priority,\n    alternates: {\n      languages: ['fr', 'pt-BR', 'zh-Hans'],\n      hitToURL: lang =\u003e url({ lang, objectID }),\n    },\n  };\n}\n```\n\nThese parameters mean:\n\n```js\n/**\n * @typedef {Object} Params\n * @property {string} loc the link of this hit\n * @property {string} [lastmod] the last time this link was modified (ISO8601)\n * @property {number} [priority] the priority you give to this link (between 0 and 1)\n * @property {Object} [alternates] alternative versions of this link (useful for multi-language)\n * @property {Array} [alternates.languages] list of languages that are enabled\n * @property {Array} [images] list of images links related to the hit\n * @property {function} [alternates.hitToURL] function to transform a language into a url of this object\n */\n```\n\n### Image Sitemaps\n\nIf you want your sitemap to include [Google image extensions](https://support.google.com/webmasters/answer/178636?hl=en), return an array for each hit containing objects with the following keys:\n\n```js\n/**\n * @typedef {Object} Image\n * @property {string} loc the link of this image\n * @property {string} [title] image title\n * @property {string} [caption] image caption\n * @property {string} [geo_location] geographic location (e.g. 'Limerick, Ireland')\n * @property {string} [license] the link to the image's license\n */\n```\n\nFor example:\n\n```js\nfunction hitToParams({\n  objectID,\n  modified,\n  downloadsRatio,\n  profilePic,\n  coverPhoto,\n  name,\n}) {\n  const url = ({ lang, objectID }) =\u003e\n    `https://${lang}.yoursite.com/${lang}/detail/${objectID}`;\n  const loc = url({ lang: 'en', objectID });\n  const lastmod = new Date().toISOString();\n  const priority = Math.random();\n  return {\n    loc,\n    lastmod,\n    priority,\n    images: [\n      {\n        loc: `https://media.yoursite.com/images/${profilePic}`,\n        title: name,\n      },\n      {\n        loc: `https://media.yoursite.com/images/${coverPhoto}`,\n        title: name,\n      },\n    ],\n    alternates: {\n      languages: ['fr', 'pt-BR', 'zh-Hans'],\n      hitToURL: lang =\u003e url({ lang, objectID }),\n    },\n  };\n}\n```\n\nFor more information, see https://support.google.com/webmasters/answer/178636?hl=en\n\n## Custom queries\n\nYou can pass a `params` parameter to `algoliaSitemap`. This allows you to narrow down the returned results. For instance, in order to have `hitToParams` called for every products in the `phone` category, we could do:\n\n```js\nalgoliaSitemap({\n  algoliaConfig,\n  sitemapLoc: 'https://yoursite.com/sitemaps',\n  outputFolder: 'sitemaps',\n  params: {\n    filters: 'category: phone',\n  },\n  hitToParams,\n});\n```\n\nNote that a query can also be passed to `params`.\n\n## Examples\n\nYou can also take a look at `examples` folder for how it works.\n\n* To generate a sitemap of all the hits in an index, check the [detail pages example](examples/details)\n* To generate a sitemap of all the category pages, check the [category pages example](examples/category)\n\n# License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falgolia%2Falgolia-sitemap","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falgolia%2Falgolia-sitemap","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falgolia%2Falgolia-sitemap/lists"}