Closed toddpadwick closed 11 months ago
Hey @toddpadwick, thanks for the issue.
You can look at disabling inferStaticPagesAsRoutes
, I'll need to add a new config to skip the prerender discovery.
Can I ask the use case though? The only time I know this is useful is for i18n when you're overriding the routes.
Hey @harlan-zw thanks for responding so quickly. I have tried the prerendering discovery and although its awesome, it just doesn't have the control I need. Also, unless I'm mistaken, it doesn't seem to pick up all entries, such as ones that are not linked anywhere. I know in general, every page should be linked somewhere for SEO and for static generation, but sometimes the client doesn't do this. so I treat the sitemap as a failsafe so ensure they are still crawlable. I noticed, for example, when I query the CMS for generating URLs, I get 120 or so. but the auto generated discovery returns 96. So this is also a useful thing to refer back to the sitemap as the source of truth for the client to ensure all pages are linked too.
regarding your suggestion, does this require the config update to the module before I can action it?
Hi @harlan-zw, Hi @toddpadwick,
I've run into the same issue. We want to create the sitemap only from a list of dynamic URLs (via a request to our CMS). This might also include URLs not visible from the static generated pages, and might also exclude pages that are visible from the static generated pages.
Therefore I came up with sth like this: https://stackblitz.com/edit/github-segxhh-l6rytt?file=nuxt.config.ts
But also with having the server/api/_sitemap-urls.ts
script as well as the inferStaticPagesAsRoutes: false
config in nuxt.config.ts
in place, it does still include the unwanted statically found urls like https://test.com/another
.
<url>
<lastmod>2023-10-25T06:36:53+00:00</lastmod>
<loc>https://test.com/</loc>
</url>
<url>
<lastmod>2023-10-25T06:36:53+00:00</lastmod>
<loc>https://test.com/another</loc>
</url>
<url>
<lastmod>2023-10-25T06:36:53+00:00</lastmod>
<loc>https://test.com/test/hello</loc>
</url>
But I want it to look like
<url>
<lastmod>2023-10-25T06:36:53+00:00</lastmod>
<loc>https://test.com/test/hello</loc>
</url>
as seen in
export default defineEventHandler(async () => {
return [
{
loc: 'test/hello',
},
];
});
Describe the bug
I am using an async function to generate our sitemap URLs. we do not want to use the pre-render crawling feature. But it still seems to be generating an auto-created sitemap instead of from the function:
Our config:
and here is the getSitemaps() function:
The above function generates something like this:
Reproduction
No response
System / Nuxt Info