Next.js Discord

Discord Forum

Sitemap.xml is not updating

Unanswered
Cornish Rex posted this in #help-forum
Open in Discord
Cornish RexOP
I use both dynamic and static sitemap.xml i have updated everything but it for some reason still showing old URL.

6 Replies

Cornish RexOP
import { MetadataRoute } from 'next'

export default function sitemap(): MetadataRoute.Sitemap {
const baseUrl = process.env.NEXTAUTH_URL || 'https://freemovieplus.com'

return [
{
url: baseUrl,
lastModified: new Date(),
changeFrequency: 'daily',
priority: 1,
},
{
url: ${baseUrl}/movies,
lastModified: new Date(),
changeFrequency: 'daily',
priority: 0.9,
},
{
url: ${baseUrl}/tv-shows,
lastModified: new Date(),
changeFrequency: 'daily',
priority: 0.9,
},
{
url: ${baseUrl}/search,
lastModified: new Date(),
changeFrequency: 'weekly',
priority: 0.8,
},
{
url: ${baseUrl}/library,
lastModified: new Date(),
changeFrequency: 'weekly',
priority: 0.7,
},
{
url: ${baseUrl}/favorites,
lastModified: new Date(),
changeFrequency: 'weekly',
priority: 0.6,
},
{
url: ${baseUrl}/watchlist,
lastModified: new Date(),
changeFrequency: 'weekly',
priority: 0.6,
},
{
url: ${baseUrl}/profile,
lastModified: new Date(),
changeFrequency: 'monthly',
priority: 0.5,
},
{
url: ${baseUrl}/auth/signin,
lastModified: new Date(),
changeFrequency: 'monthly',
priority: 0.4,
},
{
url: ${baseUrl}/auth/signup,
lastModified: new Date(),
changeFrequency: 'monthly',
priority: 0.4,
},
]
}
above is how i generate dynamic sitemap\
statis sitemap is one in public folder sitemap.xml
@Cornish Rex I use both dynamic and static sitemap.xml i have updated everything but it for some reason still showing old URL.
fwiw its updated for me, so maybe your host has some cache?
Cornish RexOP
I figured out
problem was that i was using env to set url to sitemap function
which i forgot to change when i updated a domain
but that url is also one used by authentication system
so i cant really change it rn i dont want to mess up production