You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: sitemap exclude API and parameterized routes (#1132)
## Motivation
The sitemap currently includes non-indexable routes such as
`/api/listingsourcecode/*`, `/api/chat/*`, and parameterized templates
like `/api/listingsourcecode/chapter/{chapter}/listing/{listing}`. These
are API endpoints that return JSON or template routes with unfillable
placeholders -- not real user-facing pages.
Including them wastes crawl budget, creates soft-404 signals, and can
weaken site quality signals for search engines.
## Approach
Adds `GetIndexableRoutes()` to `IRouteConfigurationService` alongside
the existing `GetStaticRoutes()`. The implementation derives indexable
routes from the already-computed static route set using three
string-level filters:
1. **`/api/` prefix** -- drops all API-prefixed routes
2. **Route parameter regex** -- drops routes containing `{param}` or
`{param:constraint}` syntax (cached as `static readonly` to avoid
repeated construction)
3. **Identity area** -- drops routes containing `identity` (Razor Pages
under `/Identity/Account/*`)
`GetStaticRoutes()` is unchanged for backward compatibility (used by
navigation UI). `SitemapXmlHelpers.GenerateSitemapXml()` now calls
`GetIndexableRoutes()`, and redundant inline filters are removed.
## Tests added
- `GetIndexableRoutes_ShouldExcludeApiControllerRoutes`
- `GetIndexableRoutes_ShouldExcludeParameterizedRoutes`
- `GetIndexableRoutes_ShouldIncludeValidContentRoutes` (including
`mcp-setup`)
- `GetStaticRoutes_StillReturnsAllRoutes_ForBackwardCompatibility`
- `GenerateSitemapXml_DoesNotIncludeApiRoutes` (asserts on `/api/`
prefix pattern)
- `GenerateSitemapXml_DoesNotIncludeParameterizedRoutes`
0 commit comments