Skip to content

Dynamic Sitemap #6107

Locked Answered by fu-sen
goppi0 asked this question in Help
Apr 13, 2021 · 1 comments · 1 reply
Discussion options

You must be logged in to vote

You run a Serverless Function that generates a sitemap.xml in /api:
https://vercel.com/docs/serverless-functions/introduction

If you want it to be visible in /sitemap.xml:
https://vercel.com/docs/configuration#project/rewrites

For example, vercel.json:

{
  "rewrites": [
    { "source": "/sitemap.xml", "destination": "/api/sitemap.js" },
  ]
}

Refer to the function directly instead of generating file sitemap.xml. Vercel has a cache feature that you can take advantage of:
https://vercel.com/docs/edge-network/caching

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@goppi0
Comment options

Answer selected by goppi0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
2 participants