Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add sitemap #130

Closed
jasongitmail opened this issue Aug 28, 2024 · 3 comments · Fixed by #132
Closed

Add sitemap #130

jasongitmail opened this issue Aug 28, 2024 · 3 comments · Fixed by #132
Labels
enhancement New feature or request

Comments

@jasongitmail
Copy link
Contributor

This looks great. Hopefully templates like these will help the SvelteKit community to grow!

For SEO, it's missing a sitemap and robots.txt.

I might suggest Super Sitemap: https://github.com/jasongitmail/super-sitemap (I'm the author & searched deeply for a good one before building this.)

// /src/routes/sitemap.xml/+server.ts
import * as sitemap from 'super-sitemap';
import type { RequestHandler } from '@sveltejs/kit';

export const prerender = true;

export const GET: RequestHandler = async () => {
  return await sitemap.response({
    origin: 'https://example.com',
    excludeRoutePatterns: [
      '.*\\(admin\\).*', // i.e. exclude routes within admin group
    ],
  });
};

If you decide to add it, remember to include the (admin) group within the excludeRoutePatterns to omit those from your sitemap, and any others you might want to exclude.

Since your blog consists of svelte files, all those routes will be included automatically.

@scosman
Copy link
Contributor

scosman commented Aug 28, 2024

Want to make a PR? 😀

@jasongitmail
Copy link
Contributor Author

Added a PR. Allows edits by maintainers.

You should run it and visit /sitemap.xml to confirm all routes you want to exclude are excluded, but otherwise it should work fine. I don't have Supabase set up to run CMSaasStarter successfully.

@scosman scosman added the enhancement New feature or request label Aug 29, 2024
@scosman
Copy link
Contributor

scosman commented Aug 29, 2024

Thanks! I'll take a look soon!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants