Introduction
This is a pretty straightforward example of creating a sitemap.xml
page on your SvelteKit website. In this example we'll be including URLs for the homepage, the contact page, the blog, all the blog posts, and all the tag pages.
We're going to be getting pages from a Prismic repository but the same process can be done using any API that returns pages or you could just add static pages if you don't have any dynamically created pages.
Create the sitemap
Creating the sitemap is pretty simple. In your routes
directory create a sitemap.xml
folder with a +server.js
file inside. Then you just need to export a GET
handler that returns the xml.
routes/sitemap.xml/+server.js
Was this post helpful?