How Can I Generate A Sitemap?

I'm days away from releasing an SSR SolidStart project that has 150+ pages. I was hoping to dynamically create a sitemap, but I'm not having much luck. I tried this: https://github.com/jbaubree/vite-plugin-pages-sitemap Unfortunately, the docs weren't super clear. I configured all of the settings (shown below), but I couldn't figure out how to generate the actual sitemap. If anyone has an easy solution for creating a sitemap, I'm all ears. Thanks!
import { defineConfig } from "@solidjs/start/config";
/* @ts-ignore */
import pkg from "@vinxi/plugin-mdx";
import Pages from "vite-plugin-pages";
import generateSitemap from "vite-plugin-pages-sitemap";

const { default: mdx } = pkg;
export default defineConfig({
ssr: true,
server: { preset: "vercel" },
extensions: ["mdx", "md"],
vite: {
plugins: [
mdx.withImports({})({
jsx: true,
jsxImportSource: "solid-js",
providerImportSource: "solid-mdx",
}),
Pages({
onRoutesGenerated: (routes) =>
generateSitemap({
routes,
hostname: "https://www.example.com/",
readable: true,
exclude: [
"/account",
"/admin-dashboard",
"/app-dashboard",
"/checkout",
"/api",
],
}),
}),
],
},
});
import { defineConfig } from "@solidjs/start/config";
/* @ts-ignore */
import pkg from "@vinxi/plugin-mdx";
import Pages from "vite-plugin-pages";
import generateSitemap from "vite-plugin-pages-sitemap";

const { default: mdx } = pkg;
export default defineConfig({
ssr: true,
server: { preset: "vercel" },
extensions: ["mdx", "md"],
vite: {
plugins: [
mdx.withImports({})({
jsx: true,
jsxImportSource: "solid-js",
providerImportSource: "solid-mdx",
}),
Pages({
onRoutesGenerated: (routes) =>
generateSitemap({
routes,
hostname: "https://www.example.com/",
readable: true,
exclude: [
"/account",
"/admin-dashboard",
"/app-dashboard",
"/checkout",
"/api",
],
}),
}),
],
},
});
GitHub
GitHub - jbaubree/vite-plugin-pages-sitemap: vite-plugin-pages base...
vite-plugin-pages based sitemap generator. Contribute to jbaubree/vite-plugin-pages-sitemap development by creating an account on GitHub.
2 Replies
Madaxen86
Madaxen864mo ago
You can check this thread: https://discord.com/channels/722131463138705510/1274626005838860369/1274637679899971614 It was for sanity cms to be updated via web hook. But you can adjust it to run as an npm script as part of your build process:
ChrisThornham
ChrisThornhamOP4mo ago
@Madaxen86 Thanks! I'll dig into this.
Want results from more Discord servers?
Add your server