algolia / jekyll-algolia

Add fast and relevant search to your Jekyll site
https://community.algolia.com/jekyll-algolia/
MIT License
214 stars 35 forks source link

Jekyll algolia url does not include basehostname #183

Open shikon opened 2 years ago

shikon commented 2 years ago

Original issue: https://github.com/mmistakes/minimal-mistakes/discussions/3199

I want to report a bug:

After building my website the search works however clicking on the result only redirect to subpath and excludes the basepath.

What is the current behavior?

Redirect to subpath only

What is your expected behavior?

redirect to hostname/subpath

Git repository to reproduce the issue:

https://github.com/shikon/shikon.github.io/tree/source

Ruby version used:

2.7.2p137

Jekyll version used:

4.2.1

Haroenv commented 2 years ago

I think relevant code is here: https://github.com/algolia/jekyll-algolia/blob/12437512c1974675f5aa8399d3ea44c759d980a4/lib/jekyll/algolia/file_browser.rb#L157

shikon commented 2 years ago

So do you suggest me to hardcode my hostname there?

I am confused why it is not correctly adding my basehostname to the url, while jekyll works fine and hence has the required information to link to the correct paths. It probably has to do something with me locally building all the files.

[edit] Whenever I add any string url: "mystring" + url(file) it becomes.

hostname/mystring/subpath so: https://mywebsite.com/mystring/subpath

if the string is empty i still get the same issue that it only redirects to https://subpath

Haroenv commented 2 years ago

I meant that you could take a look inside the code of the plugin and see if base hostname needs to be added somewhere where we're manipulating the URL @shikon. You could then make a pull request to add the base. Thanks!

shikon commented 2 years ago

Well I tried looking into it a bit, but me for its not clear where any manipulations of the url part happens. At least not inside this code. all i can find in this file def self.url(file) file.url end And neglible content in other files.