fix(home): keep the URL clean until the user edits#13
Merged
Conversation
The editor rewrote `/` to `?data=<default state>` via history.replaceState right after load, with no user action. To a crawler that reads like the home page redirecting to a data URL on load, which can keep `/` from being indexed. Skip the first run of the URL-sync effect (the initially loaded or default state) and only write `?data=` once the project actually changes. An idle `/` now stays `/`, and opening `/?example=<slug>` no longer bloats into a `?data=` URL either. Sharing and reload-safety after an edit are unchanged. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
Problem
Opening
/(even by a crawler, with no interaction) rewrote the address to/?data=<default state>viahistory.replaceState~400ms after load. To Googlebot's renderer this reads like the home page redirecting to a data URL on load, which can keep/from being indexed. A separately-shared?data=link was indexed instead (it self-canonicalizes), while/was not.The server does not inject an example on a bare
/— the default diagram is the store's built-in default, not a redirect. The only culprit is the client-side URL-sync effect firing for the initial state.Fix
Skip the first run of the URL-sync effect (the initially loaded or default state) and only write
?data=once the project actually changes.Behavior (verified in-browser)
/after the debounce window → stays/✅?data=…appears; sharing and reload-safety unchanged ✅/?example=<slug>idle → stays?example=<slug>, no longer bloats into?data=✅ (also fixes the long-standing "URL grows on load" issue)Checks
npm run check(0 errors), ESLint + Prettier clean, 121 tests passing.Follow-up (not in this PR)
After deploy, request indexing of
/in Search Console and check the Page Indexing report for the prior exclusion reason. Optionally,?data=/?example=URLs could be setnoindexto keep them out of the index / save crawl budget — left as-is since indexing shared links is acceptable.🤖 Generated with Claude Code