-
Hi! I'm trying to add Algolia search to my Docusaurus app. Since my website is behind authentication, I’ve written a scraping script to send my content to Algolia. It works, and the structure of my index items is:
For the cs locale, it will be the same, but the objectID and url will be Problems 🐛 :
Turning on 2 Ok, let's turn off However, on the local setup, although the links are absolutely correct, clicking on a search result from a different locale than the current one leads to strange behavior: When going from EN --> CS, you are redirected to the correct page (the URL is actually correct), but the page is treated as a 404. However, after refreshing the page, it loads as expected. If I manually paste the link (from the Algolia search structure) into the browser, the page loads without any issues. So I don't understand where this strange behavior is coming from. When going from CS --> EN, clicking on an English search result redirects you to the correct page, but still under the Czech locale. This is even more confusing to me. I can clearly see that the URL stored in Algolia is I'm using the standard built-in Algolia integration. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
We don't use the same setup as you do, so it's hard for us to help you, but there are interfaces you can use on the Algolia dashboard to check if you can filter on certain fields like language, version or docusaurus_tag.
Not particularly recommended since you see results from all locales and all docs versions (leading to possible duplicates). If you disable this, then you are responsible for providing your own search queries to improve that UX. By default, the Docusaurus search integration tries to navigate to your search hits using the SPA / soft navigation (based on I18n sites are distinct SPA apps, and you can't navigate from one localized site to another using that kind of soft navigation, because one localized site is not aware (in terms of client-side routing) of routes of another i18n site. When navigating from one site to another, you should use a real browser navigation instead (using a regular You can probably fix this by using the But really, it would be smpler to make contextual search work in the first place |
Beta Was this translation helpful? Give feedback.
contextualSearch: true
: Thank you for your answer and suggestion, I have found out that it isn't enough to have correctly setdocusaurus_tag
,version
andlanguage
. It is also required to set them as attributes for facetingI did this using API in this way (JS, algoliasearch v5 (5.35.0))
or you can set it using UI
Hope this will be useful as a troubleshooting for others i…