If you are using one of Algolia's frontend libraries, how you handle redirects depends which library you are using, and which rule editor you have utilized. All that is required is some simple front end development work to be put in place for the keyword redirect to be triggered.
Visual Editor
If you implement a redirect rule using the Visual Editor, the API response contains the renderingContent.redirect
property which, in turn, contains the redirect URL, which needs to be retrieved to redirect the user to this URL.
- If using Autocomplete, this is handled by the Autocomplete redirect plugin. We have another guide article on this here.
- If you don’t use Autocomplete but are using InstantSearch, you can access by creating a custom InstantSearch widget.
Manual Editor
If you created a custom redirect using the custom data consequence in the Manual Editor, you must handle it with InstantSearch’s queryRuleCustomData
widget using this guide.
API
If you have added a rule with the API, using the saveRule
method and have added renderingContent
to search parameters as a consequence, the API response will include the renderingContent.redirect
property and therefore you can use the same options as the Visual Editor above.
If using the userData
property to add a custom redirect as a consequence (as shown below), you can use the queryRuleCustomData
InstantSearch widget to update the page location.
consequence: { userData: { redirect: 'https://www.algolia.com/support' } }
Not using one of our frontend libraries?
You can still leverage the redirect data that's returned in the API response, you will just need to handle this yourself.
- If have used the Visual Editor, this will be the
renderingContent.redirect
property. - If you have used the Manual Editor, this will be the
userData
property. More on this here.
Useful Guides:
- Redirects in Autocomplete: https://www.algolia.com/doc/ui-libraries/autocomplete/guides/redirect/
- Redirects in InstantSearch: https://www.algolia.com/doc/guides/building-search-ui/ui-and-ux-patterns/redirects/js/
- Extending the out-the-box approach: https://www.algolia.com/doc/guides/managing-results/rules/merchandising-and-promoting/how-to/redirects/#extend-the-out-of-the-box-approach-or-create-custom-redirection