Sitemap
How we generate the sitemap for the website.
kreogen generates the sitemap for the marketing site using Next.js's built-in sitemap generation functionality (sitemap.ts). It combines a written-out list of marketing routes with whatever the CMS holds:
Page Collection
The marketing routes are an explicit list in apps/web/app/[locale]/sitemap.ts, not a directory scan.
They used to be derived from a readdirSync of app filtered to directories, and that read the wrong level of the tree: everything routable lives under app/[locale], so the sitemap it produced was /, /[locale], /health and /ready -- the two probe endpoints advertised to crawlers and not one marketing page. The scan was also cwd-relative, and the standalone runtime the Docker image runs has no app directory to read at all.
What the scan was really there for -- noticing that a new page never reached the sitemap -- is now apps/web/__tests__/routes.test.ts, which reads /sitemap.xml back off a running server and fails when it and the pages on disk disagree. Adding a marketing page therefore means adding a line to the list, and the test says so if you forget.
/blog is inside a kreogen:cms region, so a project generated without the cms capability loses it along with the blog itself.
Content Collection
The system fetches content from the CMS to include in the sitemap:
Blog Posts
- Fetches all published blog posts via
blog.getPosts()from@kreogen/cms - Extracts the
_slugfrom each post to generate URLs under/blog/
Legal Pages
- Fetches all legal pages via
legal.getPosts()from@kreogen/cms - Extracts the
_slugfrom each page to generate URLs under/legal/
Sitemap Generation
The final sitemap is generated by combining all these routes:
- Adds the base URL as the root entry
- Adds all page routes prefixed with the base URL
- Adds all blog posts under the
blog/path - Adds all legal pages under the
legal/path
Each sitemap entry includes:
- A full URL (combining the base URL with the route)
- A
lastModifiedtimestamp (set to the current date)
The sitemap is automatically regenerated during each build, ensuring it stays up to date with your content.