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

Dynamic rendering pages are not included in sitemap (Next 13) #743

Closed
pranavks opened this issue Dec 7, 2023 · 7 comments
Closed

Dynamic rendering pages are not included in sitemap (Next 13) #743

pranavks opened this issue Dec 7, 2023 · 7 comments
Assignees
Labels
bug Something isn't working no-issue-activity

Comments

@pranavks
Copy link

pranavks commented Dec 7, 2023

Describe the bug
Routes which are dynamically rendered (server side rendered) due to the use of Nextjs's Dynamic Functions are not included in sitemap.

Version : Next 13.5.1

To Reproduce

  1. Use any dynamic function like cookies() or headers() in a page. This will opt the route into dynamic rendering at request time.
  2. These pages are not included in sitemap.

Expected behavior
Dynamically rendered routes should be included in sitemap.

Screenshots
image
These dynamically rendered pages come under
λ (Server) server-side renders at runtime (uses getInitialProps or getServerSideProps)
in the next build's report.

@pranavks pranavks added the bug Something isn't working label Dec 7, 2023
@Hydrock
Copy link

Hydrock commented Dec 17, 2023

@pranavks may watch this https://youtu.be/FukseskiIkE?si=8pJrBw0tZTxJAykW&t=1485

I think it's logical that dynamic routes are not generated in the sitemap, because the plugin simply does not know the id of existing records at the stage. Otherwise, at the assembly stage, planin would have to go to the database for data. In any case, you would have to configure everything manually. I think the video above shows a great example of how to do it correctly and without additional plugins.

It seems that if you use getStaticPaths (https://snappify.com/blog/how-to-generate-a-sitemap-for-your-nextjs-application#dynamic-routes) you can generate the sitemap correctly

But it still doesn't solve the problem. If you have a dynamic site, the content on your site is constantly being generated, and you do not plan to rebuild the project, then the sitemap will remain unchanged - this is not what we expect

The sitemap must be dynamic

@pranavks
Copy link
Author

pranavks commented Dec 17, 2023

@Hydrock The issue is not with "Dynamic routes" which we create using square brackets in folder name.

This is regarding "Routes which are dynamically rendered at request time" (Server side rendered routes) because of the use of Next 13's "Dynamic Functions". These can be either static or dynamic routes.

And the list of server side rendered routes are available in the next build command's report in command line (where we can see all the list of urls which are generated using generateStaticParams). So next-sitemap should be able to get these urls and add them to sitemap.

@totofk
Copy link

totofk commented Dec 18, 2023

Is this problem related to these following section on readme

@pranavks
Copy link
Author

@totofk No

@pranavks pranavks changed the title Dynamic rendering pages are not included in sitemap Dynamic rendering pages are not included in sitemap (Next 13) Dec 18, 2023
@SVendittelli
Copy link

I am also running into this issue, static vs dynamic rendering of server components is covered in these Next.js docs:

@dannyDNS
Copy link

Same here.

We're using dynamic rendering to enable different features based on authentication status, but these are public pages that we'd like to have in the sitemap.

Copy link

Closing this issue due to inactivity.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Apr 20, 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 no-issue-activity
Projects
None yet
Development

No branches or pull requests

6 participants