Next.js Discord

Discord Forum

Stale dynamic sitemap

Unanswered
Mini Rex posted this in #help-forum
Open in Discord
Avatar
Mini RexOP
I am trying to create dynamic sitemap but after first time it is not updating the sitemap can anyone help me fix this issue?
code:-https://github.com/pradeep800/striver-sheet-webiste/blob/main/app/sitemap.ts

46 Replies

Avatar
Mini RexOP
Can anyone please help i am struggling with issue for while
Avatar
Philippine Crocodile
What's the issue? What is it returning?
Avatar
Mini RexOP
https://striversheet.pradeepbisht.com/sitemap.xml it doesn't change my sitemap when i am changing my user name
it only updating it when i am redeploying it
Image
Avatar
Philippine Crocodile
That is how it works. Sitemap only generates when the next build is ran
Avatar
Mini RexOP
how can i genrate dynamic sitemap then?
what will seo know that his name is changed ?
Avatar
Philippine Crocodile
When do you want to generate a sitemap?
Avatar
Mini RexOP
i want to generate it whenever i am requesting
Avatar
Philippine Crocodile
I personally like generating a sitemap once a day for my projects
Avatar
Mini RexOP
if i send request it should be changed
how do you do that?
Avatar
Philippine Crocodile
I haven't tried this. But you should be able to run the sitemap.ts/js file manually and swap out the sitemap.xml in the public folder
I use a custom service for doing this daily, so you can do that too. There is also https://pro-sitemaps.com/
Avatar
Mini RexOP
ohh okay can you help me one more problem?
Avatar
Philippine Crocodile
what's up
Avatar
Mini RexOP
whenever i am trying to go to /sheet it is automatically updating it to /Sheet that causing problem in next js 13 why
you can see in this video
Avatar
Philippine Crocodile
I can't find a good way to handle that
You could redirect /Sheet to /sheet
Avatar
Mini RexOP
okay do you know why this is happening?
becaus of this [username]
Image
Avatar
Philippine Crocodile
{
  source: '/Sheet',
  destination: '/sheet',
  permanent: true,
},
Avatar
Mini RexOP
where should i do that
which file
i am using next 13
Avatar
Philippine Crocodile
next.config.js
async redirects() {
    return [
      {
        source: '/legal/:page',
        destination: '/docs/:page',
        permanent: true,
      },
    ];
  },
add that
Avatar
Mini RexOP
okay
can you give me documentation link of this i really like to read it
Avatar
Philippine Crocodile
oops but /Sheet to /sheet
Avatar
Mini RexOP
?
thank you
Avatar
Philippine Crocodile
async redirects() {
    return [
      {
        source: '/Sheet',
        destination: '/sheet',
        permanent: true,
      },
    ];
  },
should work
Avatar
Mini RexOP
do you know why this is happening
why it is automatically adding it to url
anything to do with [username] and sheet collision?
Avatar
Philippine Crocodile
??
what do you mean
Avatar
Mini RexOP
you can see in video when i am going to /sheet it is automatically redirectly me to /Sheet why it is happening
when i am clicking to link it is not redirecting me to /sheet (that mean correctly)
Avatar
Philippine Crocodile
check private messages