Adding sitemap in SvelteKit

How to improve SEO by adding sitemap to prerendered SvelteKit website

To add a sitemap to a dynamic or statically generated website, we can use the following package:

To install this:

npm i -D svelte-sitemap

There is no configuration needed. All you have to do is run it by passing your domain name.

Now add it to your package.json as follows:

  "scripts": {
    "dev": "svelte-kit dev",
    "build": "svelte-kit build",
    "sitemap": "svelte-sitemap --domain"

Now run the command:

npm run sitemap

It would produce:

 |---> robots.txt
 |---> sitemap.xml