Algolia search redirects with duplicated base url
See original GitHub issue- I confirm that this is an issue rather than a question.
Bug report
Steps to reproduce
- Have Algolia search setup
- The document website has site config
base
configured, for example,/docs
. - Search any keyword and click on a search result
- The page will try to navigate to a Url with duplicated base url, In the above, example, will be '/docs/docs/path/to/result.html`.
What is expected?
- The page should navigate to a correct url.
- Or allow user to configure
handleSelected
asalgolia
config to overwrite default build-in behavior.
What is actually happening?
On lines around https://github.com/vuejs/vuepress/blob/master/packages/%40vuepress/theme-default/components/AlgoliaSearchBox.vue#L41
handleSelected: (input, event, suggestion) => {
const { pathname, hash } = new URL(suggestion.url)
this.$router.push(`${pathname}${hash}`)
}
If the suggestion url is https://my-domain.com/docs/path/to/result.html`, pathname
will be /docs/path/to/result.html
. When we use $router.push
, the $router will also prepend /docs
base url to the path which results in double base url.
Also the handleSelected
handling overwrites any configurations on site level algolia
config of handleSelected
.
Other relevant information
- Output of
npx vuepress info
in my VuePress project:
Environment Info:
System:
OS: macOS 10.14.6
CPU: (8) x64 Intel(R) Core(TM) i7-6820HQ CPU @ 2.70GHz
Binaries:
Node: 8.11.2 - ~/.nvm/versions/node/v8.11.2/bin/node
Yarn: 1.10.1 - ~/.nvm/versions/node/v8.11.2/bin/yarn
npm: 6.4.0 - ~/.nvm/versions/node/v8.11.2/bin/npm
Browsers:
Chrome: 76.0.3809.100
Firefox: 60.8.0
Safari: 12.1.2
npmPackages:
@vuepress/core: 1.0.3
@vuepress/theme-default: 1.0.3
vuepress: ^1.0.3 => 1.0.3
npmGlobalPackages:
vuepress: Not Found
Issue Analytics
- State:
- Created 4 years ago
- Reactions:4
- Comments:9 (3 by maintainers)
Top Results From Across the Web
Redirects in InstantSearch.js - Algolia
The best way to set up redirects is through Rules. You can add redirect information as custom data to any Rule. The Rule...
Read more >Grouping results - Algolia
Learn about combining, consolidating, aggregating, deduplicating records using Algolia's Distinct feature.
Read more >Copy indices | Algolia
Select Manage index > Duplicate. Select Create a new index and enter a new index name, if you want to copy an index...
Read more >DocSearch Scraper with Anchors - Algolia Community
The duplicates you have noticed are due to the way the DocSearch scraper builds records from a page. It creates one record for...
Read more >Optimize InstantSearch.js search requests - Algolia
Clear your browser's cache and reload the page. Were any queries sent to Algolia? If yes, check to see if any Algolia results...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
First of all, thank you for Vuepress. This is a great project. Really helpful!
I am part of the DocSearch team which feature Algolia for vuepress.
Just to add on top of that, prepending
/docs
base url to the path is required for edge cases where the crawl is not made against the final website. A common use case would be to edit the result’s URL to make sure your staging website redirect to your production one while the crawl is not against the production website (this require an update of your DocSearch configuration available from algolia/docsearch-configs). This is not the main use case and a temporary situation.The default behaviour of vuepress should not mute the URL since the DocSearch crawler is making sure this URL is available by crawling it (
200
). Editing the URL should not be the default behaviour.Happy to provide more details if needed. Thanks for handling that.
I have the same issue.
I asked Algolia’s DocSearch team, and they answered that the pages are correctly indexed with the right URLs.