-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
Algolia search redirects with duplicated base url #1802
Comments
I also encountered the same problem. |
I also have this problem. Has anyone found a way to fix this? |
Algolia Search doesn't know that you're redeploying your site under a sub directory, which causes this issue. the unique solution is the search plugin providing a new option to let you intuitively pass it in. Contribution welcome! |
@ulivz Thank you for a quick answer! Now that you're "here" I'd just like to say how amazing vuepress is! It's by far the best tool for what it does. Thank you so much for your hard work 🙇♂️ Your answer might be exactly right, but what confuses me is that it used to work like that. I use vuepress with algolia search here and it has worked for months just fine. It just recently stopped working for whatever reason. Probably because I updated vuepress. I didn't change the configs, or the sub directory. I can dig around to find out what the last working version was if you want? (now it works because I implemented the fix other people in this thread have implemented) |
Also even without the fix, the algolia links point to the correct URL (if I look at the anchor tags using dev tools). It goes wrong in the custom handler that calls the router. And that's the thing the workaround "fixes". You can see the "fix" here |
If the implemented fix makes sense, I'm happy to create a PR for it. If there's a better way to fix it, I'm happy to implement that also, but I'll need some pointers, since I'm new to vuepress's code, |
I have the same issue. I asked Algolia's DocSearch team, and they answered that the pages are correctly indexed with the right URLs. |
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 The default behaviour of vuepress should not mute the URL since the DocSearch crawler is making sure this URL is available by crawling it ( Happy to provide more details if needed. Thanks for handling that. |
I think @koskimas's fix is correct. It's not changing the URL so much as working around the in-this-instance-undesirable Vue router behaviour. The URL people end up on remains the same as what DocSearch suggested. |
Bug report
Steps to reproduce
base
configured, for example,/docs
.What is expected?
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
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 levelalgolia
config ofhandleSelected
.Other relevant information
npx vuepress info
in my VuePress project:The text was updated successfully, but these errors were encountered: