Fix search index not trimming numerical ordering prefixes#2408
Merged
emmadesilva merged 1 commit intomasterfrom Apr 3, 2026
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #2408 +/- ##
===========================================
Coverage 100.00% 100.00%
- Complexity 2000 2003 +3
===========================================
Files 197 197
Lines 5127 5135 +8
===========================================
+ Hits 5127 5135 +8 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
a195b86 to
721c534
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🐛 Fix search index not trimming numeric ordering prefixes
Summary
This PR fixes an issue where documentation search results generated incorrect URLs when source files used numeric ordering prefixes (e.g.
01-,02-).Hyde correctly strips these prefixes when generating the final documentation pages, but the search index was still using the original filename, causing broken links (404s) when users clicked search results.
✅ What’s fixed
Search index now uses the page
routeKeyinstead of the raw file identifierNumeric prefixes like
01-and02-are properly removed from:slugdestination(URL)Nested documentation structures are handled correctly
Fallback title generation no longer includes numeric prefixes
🔍 Example
Before
Source file:
Generated page:
Search result (incorrect):
After
Search result:
💡 Implementation details
basename($page->routeKey)instead of$page->identifiergetCleanBasename()inHydePageDataFactoryto strip numeric prefixes when generating fallback titlesNumericalPageOrderingHelperto ensure consistent prefix handling across the frameworkindexpages🧪 Tests
Added tests to ensure:
🎯 Why this approach
Instead of duplicating filename-cleaning logic in the search index, this PR aligns search behavior with Hyde’s routing system by using
routeKeyas the source of truth.This ensures:
🔗 Fixes
Fixes hydephp/hyde#324