Skip to main content

Sitemap

Fetch and regenerate your project's sitemap so search engines can discover and index your pages.

More information about the module's user interface: https://doc.oneentry.cloud/docs/category/sitemap (opens in a new tab)


The Sitemap module fetches and regenerates the sitemap of your OneEntry project. updateSitemap(body) generates it, and getSitemap() resolves to the URLs of the generated sitemap files.

Quickstart​

Initialize the module from defineOneEntry:


const { } = defineOneEntry(
, {
}
);

Fetch the URLs of the generated sitemap files:

// Resolves to an array of sitemap file URLs (string[]).
const sitemaps = await Sitemap.getSitemap();
if ('statusCode' in sitemaps) throw new Error(sitemaps.message);

sitemaps.forEach((url) => {
console.log(url);
});

Reading and generating​

getSitemap() resolves to an array of sitemap file URLs (string[]), for example:

[
'https://your-project.oneentry.cloud/cloud-static/files/project/sitemap/sitemap-000.xml'
]

The sitemap isn't generated automatically. Call updateSitemap(body) after adding or significantly changing pages, or after changing the site structure.

updateSitemap() reads only body.baseUrls: an object that maps each active locale code to the site's public base URL for that language, for example { en_US: "https://example.com/", ru_RU: "https://example.com/ru/" }. Every key must be an active locale code, or the call fails with a 400 error (Invalid or inactive locale). Include en_US: its URL becomes each entry's <loc>, and the other locales are added as hreflang alternate links. The platform doesn't write lastmod, changefreq or priority, so the other ISitemapQuery fields (url, lastmod, changefreq, priority) have no effect.

The sitemap lists every page that has a URL, plus each product under every catalog page it belongs to. Each run deletes the previously generated files and writes new ones, up to 50,000 URLs per file (sitemap-000.xml, sitemap-001.xml, …).

Submitting to search engines​

The module doesn't submit the sitemap to search engines. Generate it with updateSitemap(body), fetch the file URLs with getSitemap(), and submit them in Google Search Console (under Sitemaps) or Bing Webmaster Tools.


Methods​

MethodDescription
getSitemap()Fetch the sitemap file URLs
updateSitemap()Regenerate the sitemap