Google News, image and video sitemap

    Adding Values from Google News, image and video sitemap.


    Url set can contain additional sitemaps defined by google. These are Google News sitemap, image sitemap or video sitemap.

    You can add the values for these sitemaps by updating entry in transform function or adding it with additionalPaths.

    You have to return a sitemap entry in both cases, so it's the best place for updating the output. This example will add an image and news tag to each entry but IRL you would of course use it with some condition or within additionalPaths result.

    /** @type {import('next-sitemap').IConfig} */
    const config = {
      transform: async (config, path) => {
        return {
          loc: path, // => this will be exported as http(s)://<config.siteUrl>/<path>
          changefreq: config.changefreq,
          priority: config.priority,
          lastmod: config.autoLastmod ? new Date().toISOString() : undefined,
          images: [{ loc: 'https://example.com/image.jpg' }],
          news: {
            title: 'Article 1',
            publicationName: 'Google Scholar',
            publicationLanguage: 'en',
            date: new Date(),
          },
        }
      },
    }
     
    export default config

    Created by: Vishnu Sankar & Contributors. 

    Font From: Fontshare. 

    Website Source.