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

This XML Sitemap contains 0 URLs #287

Closed
gianluigibitboss opened this issue Jun 18, 2024 · 6 comments
Closed

This XML Sitemap contains 0 URLs #287

gianluigibitboss opened this issue Jun 18, 2024 · 6 comments

Comments

@gianluigibitboss
Copy link

gianluigibitboss commented Jun 18, 2024

Hello, I'm unsure how to go about resolving an issue as it appears the package is not working at all for me and always resolves 0 urls?
I have this debug JSON:

  "nitroOrigin": "http://localhost:3000/",
  "sitemaps": {
    "index": {
      "sitemapName": "index",
      "_route": "sitemap_index.xml",
      "sitemaps": [
        {
          "sitemap": "http://localhost/sitemap.xml"
        }
      ],
      "include": [],
      "exclude": [],
      "sources": []
    }
  },
  "runtimeConfig": {
    "isI18nMapped": false,
    "sitemapName": "sitemap.xml",
    "isMultiSitemap": true,
    "excludeAppSources": [],
    "cacheMaxAgeSeconds": 0,
    "autoLastmod": false,
    "defaultSitemapsChunkSize": 1000,
    "sortEntries": true,
    "debug": false,
    "discoverImages": true,
    "isNuxtContentDocumentDriven": false,
    "xsl": "/__sitemap__/style.xsl",
    "xslTips": true,
    "xslColumns": [
      {
        "label": "URL",
        "width": "50%"
      },
      {
        "label": "Images",
        "width": "25%",
        "select": "count(image:image)"
      },
      {
        "label": "Last Updated",
        "width": "25%",
        "select": "concat(substring(sitemap:lastmod,0,11),concat(' ', substring(sitemap:lastmod,12,5)),concat(' ', substring(sitemap:lastmod,20,6)))"
      }
    ],
    "credits": true,
    "version": "5.1.0"
  },
  "globalSources": [
    {
      "sourceType": "user",
      "fetch": "/api/__sitemap__/urls",
      "context": {
        "name": "fetch",
        "tips": []
      },
      "timeTakenMs": 182,
      "urls": [
        {
          "loc": "/about-us",
          "_sitemap": "pages"
        }
      ]
    },
    {
      "timeTakenMs": 0,
      "context": {
        "name": "sitemap:urls",
        "description": "Set with the `sitemap.urls` config."
      },
      "urls": [],
      "sourceType": "user"
    },
    {
      "timeTakenMs": 0,
      "context": {
        "name": "nuxt:pages",
        "description": "Generated from your static page files.",
        "tips": [
          "Can be disabled with `{ excludeAppSources: ['nuxt:pages'] }`."
        ]
      },
      "urls": [
        {
          "loc": "/blog"
        },
        {
          "loc": "/dev"
        },
        {
          "loc": "/faq"
        },
        {
          "loc": "/"
        },
        {
          "loc": "/sitemap.xml"
        }
      ],
      "sourceType": "app"
    }
  ]
}

And this settings that for some reasons are the same as another project but they don't work anymore:

{
		includeAppSources: true,
		defaults: {
			priority: 0.9,
		},
		sitemaps: {
			index: [
				{
					sitemap: `${process.env.BACK_URL}/sitemap.xml`,
				},
			],
		},
		experimentalCompression: true,
		exclude: [],

		sources: ['/api/__sitemap__/urls'],
		// 24 hours
		cacheMaxAgeSeconds: 3600 * 24,
	}

And the sitemap is simply empty

@harlan-zw
Copy link
Collaborator

Thanks for the issue, I think the issue may have to do with the fact you're mixing multi-sitemap config with single sitemap config.

If you provide sitemaps then it's expected you configure each sitemap, see https://nuxtseo.com/sitemap/guides/multi-sitemaps.

I'd test out commenting out the sitemaps lines and see how you go. Otherwise please provide a reproduction.

@gianluigibitboss
Copy link
Author

Ok removing the sitemaps key which previously linked an external sitemap allows me to see the app sources sitemap.
Now I'm not sure how to link the external sitemap tho.
Could you point me to how to handle displaying both?

@harlan-zw
Copy link
Collaborator

just copy your config into any key on sitemaps

	sitemaps: {
           pages: {
              includeAppSources: true,
		      sources: ['/api/__sitemap__/urls'],
           },
			index: [
				{
					sitemap: `${process.env.BACK_URL}/sitemap.xml`,
				},
			],
		},

@gianluigibitboss
Copy link
Author

gianluigibitboss commented Jun 20, 2024

I have a strage behaviour were my current config is:

sitemap: {
		sitemaps: {
			pages: {
				includeAppSources: true,
			},
			index: [{ sitemap: `${process.env.BACK_URL}/sitemap.xml` }],
		},
	},

The pages sitemap is empty if nuxt-simple-robots is added in the modules.

Here's a repro: url

If you remove nuxt-simple-robots the pages sitemap works. If you restore it the pages sitemap has 0 urls.

@harlan-zw
Copy link
Collaborator

harlan-zw commented Jun 24, 2024

The sitemap module integrates with the robots module. You are telling the robots module that no pages should be indexable.

  robots: {
    disallow: ['/'],
    sitemap: [`/sitemap_index.xml`],
  },

The sitemap module does not add pages to that sitemap that shouldn't be indexed.

Also the sitemap module automatically adds the sitemap entry so you can remove that line also.

harlan-zw added a commit that referenced this issue Jul 1, 2024
harlan-zw added a commit that referenced this issue Jul 1, 2024
@harlan-zw
Copy link
Collaborator

I've Available in v5.3.0, thanks again! when your config has these types of conflicts, not much else I can do on this issue so going to close.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants