Skip to content

feat(docs): add dynamic sitemap.xml generation#5728

Open
kiloconnect[bot] wants to merge 3 commits intomainfrom
docs/add-sitemap-xml
Open

feat(docs): add dynamic sitemap.xml generation#5728
kiloconnect[bot] wants to merge 3 commits intomainfrom
docs/add-sitemap-xml

Conversation

@kiloconnect
Copy link
Contributor

@kiloconnect kiloconnect bot commented Feb 6, 2026

Summary

This PR adds dynamic sitemap.xml generation for the Kilo Code documentation site.

Changes

  • New API endpoint (pages/api/sitemap.xml.ts): Dynamically generates a sitemap by scanning all markdown files in the pages directory
  • Rewrite rule in next.config.js: Routes /sitemap.xml to the API endpoint
  • Comprehensive tests (__tests__/sitemap.spec.ts): Validates sitemap generation, XML structure, and error handling

Features

  • Automatically discovers all markdown documentation pages
  • Includes lastmod dates based on file modification times
  • Calculates priority based on URL depth (homepage = 1.0, deeper pages = lower priority)
  • Caches responses for 1 hour to reduce server load
  • Properly escapes XML special characters
  • Skips the /api directory

How it works

The sitemap is served at https://kilo.ai/docs/sitemap.xml and updates automatically whenever documentation content changes. No manual regeneration is needed.


Built for Brendan by Kilo for Slack

- Add API endpoint at /api/sitemap.xml that dynamically generates sitemap
- Add rewrite rule to serve sitemap at /sitemap.xml
- Include all markdown pages with lastmod dates and priority
- Add comprehensive tests for sitemap generation
@changeset-bot
Copy link

changeset-bot bot commented Feb 6, 2026

⚠️ No Changeset found

Latest commit: 22b4be8

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@kiloconnect
Copy link
Contributor Author

kiloconnect bot commented Feb 6, 2026

Code Review Summary

Status: 3 Issues Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 0
WARNING 2
SUGGESTION 1

Fix these issues in Kilo Cloud

Issue Details (click to expand)

WARNING

File Line Issue
apps/kilocode-docs/pages/api/sitemap.xml.ts 84 Sitemap likely includes a duplicate homepage entry (/docs and /docs/)
apps/kilocode-docs/pages/api/sitemap.xml.ts N/A Root index.md is not treated as homepage (per existing inline comment)

SUGGESTION

File Line Issue
apps/kilocode-docs/pages/api/sitemap.xml.ts 39 Normalize path separators for URLs (per existing inline comment)
Files Reviewed (3 files)

olearycrew and others added 2 commits February 6, 2026 13:00
Co-authored-by: kiloconnect[bot] <240665456+kiloconnect[bot]@users.noreply.github.com>
Co-authored-by: kiloconnect[bot] <240665456+kiloconnect[bot]@users.noreply.github.com>
</url>`)

for (const filePath of markdownFiles) {
const urlPath = filePathToUrlPath(filePath, pagesDir)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WARNING: Potential duplicate homepage entry in sitemap

findMarkdownFiles() will include pages/index.md, and filePathToUrlPath() maps it to /. The loop will then emit a second homepage-like URL (typically https://kilo.ai/docs/) in addition to the explicit homepage entry (https://kilo.ai/docs). Consider skipping urlPath === "/" in the loop or excluding the root index.md from markdownFiles.

</url>`)

for (const filePath of markdownFiles) {
const urlPath = filePathToUrlPath(filePath, pagesDir)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WARNING: Sitemap likely includes a duplicate homepage entry (/docs and /docs/)

This endpoint always adds the homepage manually, but markdownFiles will also include pages/index.md. filePathToUrlPath() converts that file to urlPath === "/", so the loop will add a second URL with a trailing slash (${SITE_URL}/). That can create duplicate canonical entries in the sitemap.

Consider skipping entries where urlPath === "/" (or filtering out the root index.md before iterating), and adding a test assertion to catch the trailing-slash variant.

@kevinvandijk kevinvandijk added the documentation Improvements or additions to documentation label Feb 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants