Discuss and resolve questions on Liquid, JavaScript, themes, sales channels, and site speed enhancements.
I am using the next-sitemap package
api/pages/server-sitemap.ts looks like this:
import { NextApiRequest, NextApiResponse } from 'next'; import { getServerSideSitemap, ISitemapField } from 'next-sitemap'; import getAllProductsOperation from '../../../packages/shopify/dist/api/operations/get-all-products'; import getAllProductsQuery from "../../../packages/shopify/dist/utils/queries/get-all-products-query"; const generateSitemap = async (req: NextApiRequest, res: NextApiResponse) => { try { const getAllProducts = getAllProductsOperation({ commerce: { locale: 'tr-TR', shopId: 'yukselensepets', }, }); const { products } = await getAllProducts({ query: getAllProductsQuery, variables: {}, config: {}, }); const productURLs: ISitemapField[] = products.map((product: { slug: string; updatedAt: Date }) => ({ loc: `https://www.example.com/product/${product.slug}`, lastmod: product.updatedAt.toISOString(), changefreq: 'daily', priority: '0.7', })); const sitemapContent = await getServerSideSitemap(productURLs); res.setHeader('Content-Type', 'text/xml'); res.write(sitemapContent); res.end(); } catch (error) { console.error('Sitemap oluşturma hatası:', error); res.status(500).end(); } }; export default generateSitemap;
and next-server.config.js in my root folder:
const siteUrl = "https://www.example.com/"; module.exports = { siteUrl, generateRobotsTxt: true, robotsTxtOptions: { policies: [ { userAgent: "*", allow: "/" }, ], additionalSitemaps: [ `${siteUrl}/sitemap.xml`, `${siteUrl}/server-sitemap.xml`, ], }, };
How can I create it? can you help me please?
i can't output..
Shopify and our financial partners regularly review and update verification requiremen...
By Jacqui Mar 14, 2025Unlock the potential of marketing on your business growth with Shopify Academy's late...
By Shopify Mar 12, 2025Learn how to increase conversion rates in every stage of the customer journey by enroll...
By Shopify Mar 5, 2025