fix(seo): enforce trailing slashes on internal links to fix 134 non-indexable canonicals - #19004
fix(seo): enforce trailing slashes on internal links to fix 134 non-indexable canonicals#19004sfanahata wants to merge 1 commit into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit f42310b. Configure here.
| const hasScheme = realTo.includes(':'); | ||
| const hasFileExtension = /\.\w{2,10}(?=[?#]|$)/.test(realTo); | ||
| const normalizedHref = | ||
| hasScheme || hasFileExtension ? realTo : ensureTrailingSlash(realTo); |
There was a problem hiding this comment.
Extension check scans query and hash
Medium Severity
hasFileExtension runs against the full href, including query strings and hashes. A page link whose query or fragment ends in a file-like suffix (for example .js or .json) is treated as a static file and skips ensureTrailingSlash, so those internal links still miss the trailing slash and can hit the same redirect/canonical issue this PR aims to fix.
Reviewed by Cursor Bugbot for commit f42310b. Configure here.
f42310b to
32e842c
Compare
…ndexable canonicals Three changes to eliminate broken canonical chains caused by missing trailing slashes: 1. SmartLink normalization: Add ensureTrailingSlash() to src/utils.ts and apply it in SmartLink for all internal links. This prevents future regressions by normalizing URLs at render time, avoiding 308 redirects that break canonical signal chains. 2. Content link cleanup: Fix 732 internal links across 366 content files (docs/, includes/, platform-includes/) that were missing trailing slashes on markdown links and PlatformLink to= props. 3. MD export canonical URLs: Fix generate-md-exports.mjs to include trailing slashes in canonical URLs embedded in export HTML, matching the behavior of generateMetadata() and middleware. Also consolidates the duplicated appendSlash() helper in sitemap.ts to use the shared ensureTrailingSlash() utility.
32e842c to
94c626b
Compare


DESCRIBE YOUR PR
Fixes 134 non-indexable canonical issues where pages point their canonical tag to a URL that triggers a redirect (missing trailing slash → trailing slash), creating broken canonical chains that confuse Google's indexation.
Root cause
The site is configured with
trailingSlash: true(in bothnext.config.tsandvercel.json), meaning all canonical URLs include a trailing slash. However, hundreds of internal links in content files were authored without trailing slashes. When followed, these trigger a 308 redirect to the trailing-slash version, creating a chain between the link and the canonical URL that degrades SEO signals.Changes
1. SmartLink trailing slash normalization (
src/components/smartLink.tsx,src/utils.ts)ensureTrailingSlash()utility tosrc/utils.ts(alongside the existingstripTrailingSlash())SmartLinkfor all internal page links at render timemailto:and other scheme-based URLs, and static file paths with extensions (e.g..pdf)#section) and query strings (?param=value)src/utils.test.ts2. Content link cleanup (366 files across
docs/,includes/,platform-includes/)[text](/path)) and<PlatformLink to="/path">usages were missing trailing slashes3. MD export canonical URLs (
scripts/generate-md-exports.mjs)generateMetadata()inpage.tsxandmdToCanonicalPath()inmiddleware.ts4. Deduplication (
app/sitemap.ts)appendSlash()helper with the sharedensureTrailingSlash()fromsrc/utils.tsVerification
ensureTrailingSlashtests)IS YOUR CHANGE URGENT?
PRE-MERGE CHECKLIST