-
-
Notifications
You must be signed in to change notification settings - Fork 8.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Search Issue with Hash Router #10399
Comments
Please be precise: tell us what's the exact url after clicking with a mouse, and what's the exact URL after pressing tab. For both our website, and your Docusaurus project. I suspect what is going on for our own website is that we only deploy the "current" version so that CI runs faster. This means that the indexed |
Hmmm it looks like you are right, I also get a weird URL only when using search with keyboard controls. Repro:
Result:
This is a valid bug to fix. Looks like it only happens with the hash router. |
Unrelated but worth mentioning: I'm not sure how Algolia is able to index Docusaurus when it's using the experimental hash router. @shortcuts any idea? With the hash router, Docusaurus becomes a full client-side CSR/SPA app, not SSG/SSR anymore. An example hash router deployment: https://facebook.github.io/docusaurus/#/ More info here:
Worth mentioning: in hash router mode, we do not emit a Note: if search works on the example hash router deployment, it's only because it's using the same Algolia as our main website (https://docusaurus.io), which is the one being indexed. It's not proof that the Algolia crawler can index a hash-based Docusaurus website. |
If somehow behavior of pressing Enter can mimick what mouse click does in
backend. It will solve the use case for me.
Yes, I have crawled on algolia index without hash router and then using
that index inside search with hash router. Everything is working perfectly
for me except this strange behavior on pressing Enter.
…On Tue, 13 Aug, 2024, 20:43 Sébastien Lorber, ***@***.***> wrote:
Unrelated but worth mentioning: I'm not sure how Algolia is able to index
Docusaurus when it's using the experimental hash router.
@shortcuts <https://github.com/shortcuts> any idea? With the hash router,
Docusaurus becomes a full client-side CSR/SPA app, not SSG/SSR anymore.
An example hash router deployment:
https://facebook.github.io/docusaurus/#/
More info here:
- https://docusaurus.io/blog/releases/3.4#hash-router---experimental
- #9859 <#9859>
Worth mentioning: in hash router mode, we do not emit a sitemap.xml (but
we could eventually add that if it's useful). This probably means that
Algolia crawler would have to run the JS and crawl links on its own. I'm
not sure the default Algolia Docusaurus config is suited for that.
Note: if search works on the example hash router deployment, it's only
because it's using the same Algolia as our main website (
https://docusaurus.io), which is the one being indexed. It's not proof
that the Algolia crawler can index a hash-based Docusaurus website.
—
Reply to this email directly, view it on GitHub
<#10399 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AZTKI3EN2JTDWXEJ3R5HVDDZRIPALAVCNFSM6AAAAABMOEUC4KVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEOBWGQ4TSOJQGA>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
@slorber, are you planning to fix this bug in the next few days? |
I'm very curious how search can ever work with hash router, since I assumed that the site would then not be crawlable by Algolia. Plus hash routers were implemented so the site could work offline without a server, and that idea seems incompatible with an online search service. But I'll defer the investigation and explanation to @slorber |
The search is working smoothly except for this issue on pressing enter on the search bar. I understand your concern of offline access. |
The default DocSearch's docusaurus config does not enable javascript rendering, one would need to enable it: https://www.algolia.com/doc/tools/crawler/apis/configuration/render-java-script/ I believe it would be worth setting it by default? It would also mean a migration on our side if we want this to be retroactively applied
A sitemap is always better for consistency but the Crawler will still discover links on its own |
I don't think it's necessary, most sites will keep using the browser router and rendering JS is probably more expensive. We can just document users should enable it if needed if they want to use the hash router (a minority of users).
Yes, I understand that, at the same time the sitemap is supposed to help with SEO and I don't think it is expected to contain anchors. Although it probably doesn't harm, if we implement this it's probably only for Algolia crawlers. It's hard to find relevant info online on how to index a hash-based site. |
@ankur-vunet @Josh-Cena even if the site is distributed as an offline-first archive, it doesn't necessarily mean that the user won't have access to internet, so the Algolia search engine may still work in that scenario. If the search should work offline, someone will have to build a local search plugin that supports the hash router. |
Have you read the Contributing Guidelines on issues?
Prerequisites
npm run clear
oryarn clear
command.rm -rf node_modules yarn.lock package-lock.json
and re-installing packages.Description
I have created a docusaurus project with algolia search and hash router. But observed a strange behavior of search not working properly with Enter button on keyboard. Whereas it works smoothly with mouse click. Later I observed same on official sample page also.
https://facebook.github.io/docusaurus/#/
GO to any page on this website, and then do a search and select with mouse click. It returns the result correctly.
Next, make the search again from this page, and use Enter on keyboard, and you will be navigated to Page not found since, URL redirected is improper. Please make a fix for this. I want algolia to work smoothly with hash router for my project.
Reproducible demo
No response
Steps to reproduce
https://facebook.github.io/docusaurus/#/
GO to any page on this website, and then do a search and select with mouse click. It returns the result correctly.
Next, make the search again from this page, and use Enter on keyboard, and you will be navigated to Page not found since, URL redirected is improper. Please make a fix for this. I want algolia to work smoothly with hash router for my project.
Expected behavior
On both, search with either mouse click or Enter on keyboard, functionality should be similar.
Actual behavior
On actuals, on mouse click it is working fine. But on Keyboard Enter, Page not found. This issue isexplicitly with hash router only. If I remove hash router, it is working perfectly fine.
Your environment
Self-service
The text was updated successfully, but these errors were encountered: