Skip to main content

getSitemapIndex

Generate a sitemap index that links to separate child sitemaps for different resource types. Returns a standard Response object.

required

Promise<Response>
Examples
import {getSitemapIndex} from '@shopify/hydrogen';

export async function loader({request, context: {storefront}}) {
const response = await getSitemapIndex({
storefront,
request,
types: [
'products',
'pages',
'collections',
'metaObjects',
'articles',
'blogs',
],
});

// Set any custom headers on the sitemap response
response.headers.set('Cache-Control', `max-age=${60 * 60 * 24}`);

return response;
}
Was this page helpful?