Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

not possible to exclude sitemap from "main" sitemap while including it in robots.txt #823

Open
Sammeeey opened this issue Jun 14, 2024 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@Sammeeey
Copy link

Describe the bug
I have this in my sitemap.xml (when using robotsTxtOptions.additionalSitemaps):

<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
  <sitemap>
    <loc>https://www.domain.com/sitemap-0.xml</loc>
  </sitemap>
  <sitemap>
    <loc>https://www.domain.com/server-sitemap-index.xml</loc>
  </sitemap>
  <sitemap>
</sitemapindex>

When I want this:

<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
  <sitemap>
    <loc>https://www.domain.com/sitemap-0.xml</loc>
  </sitemap>
</sitemapindex>

To Reproduce

  1. create server-sitemap-index.xml/route.ts to generate server-sitemap

  2. next-sitemap.config.js:

/** @type {import('next-sitemap').IConfig} */
const siteUrl = process.env.NEXT_PUBLIC_SITE_URL
module.exports = {
  siteUrl: siteUrl,
  sitemapSize: 50000,
  generateRobotsTxt: true,
  exclude: ['/server-sitemap-index.xml', '/sitemap/*'],
  robotsTxtOptions: {
    additionalSitemaps: [
      `${siteUrl}/server-sitemap-index.xml`,
    ],
  },
  transform: async (config, path) => {

    return {
      loc: path,
    }
  }
}

But robots.txt should include the server-sitemap-index.xml:

# *
User-agent: *
Allow: /

# Host
Host: https://www.domain.com

# Sitemaps
Sitemap: https://www.domain.com/sitemap.xml
Sitemap: https://www.domain.com/server-sitemap-index.xml

Expected behavior
robotsTxtOptions.additionalSitemaps shouldn't add the sitemap to sitemap.xml BUT only to robots.txt

Screenshots
If applicable, add screenshots to help explain your problem.

Additional context
Add any other context about the problem here.

@Sammeeey Sammeeey added the bug Something isn't working label Jun 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
2 participants