Comments (7)
I was also astonished by this behaviour but I understood when explained in another issue : in fact, Algolia is indexing your content by pieces (see https://github.com/algolia/algoliasearch-jekyll#settings for the settings), including each paragraph separately.
When searched, the index is able to point at the specific paragraph containing the searched term 👀
from algoliasearch-jekyll.
As @borisschapira perfectly explained, the anchor in the url is here so the search result is linked to the exact HTML node in the page it references.
If you want to remove it, you can use the custom hooks and override the url
attribute. For example, you can create a file in _plugins/search.rb
with the following content (every page in _plugins
will be loaded by Jekyll).
class AlgoliaSearchRecordExtractor
def custom_hook_each(item, node)
# Here you have access to the item object, right before it is pushed
# Modify it as much as you want (in your case, changing the item[:url] key) then return it
# item[:url] = '...'
item
end
end
Also note that you can run jekyll algolia push -n
to do a dry-run (parse data but does not send anything to the Algolia API).
Tell me if this works for you
from algoliasearch-jekyll.
@borisschapira @pixelastic Thank you very much for your answers! It would be great if index could point at the specific paragraph, but instead it points at the top of the page, even though the paragraph is at the bottom.
I guess I can simply remove #algolia:{{ css_selector }}
from:
<a class="algolia__result-link" href="{{ full_url }}#algolia:{{ css_selector }}">
{{{ _highlightResult.title.value }}}
</a>
Would that be enough?
P.S. I have a few more questions about integrating Algolia, but I'm not sure if GitHub issues is the right place to post them. Is it ok if I ask them here?
from algoliasearch-jekyll.
My mistake, I thought the url
was saved, including the css_selector
, in the record. As they are actually two different fields, you're right that you just have to update the link to target the page without the anchor. That will work.
To scroll the page to the correct part, you need a bit of custom JavaScript. You can have a look at how it was done on our Jekyll/Hyde demo. Basically we wait for page load, read the url, parse the anchor and scroll to the element matching the selector.
Regarding your other questions, feel free to post issues here (one thread per issue, to make tracking easier). If something is not clear enough, I'll update the documentation accordingly.
from algoliasearch-jekyll.
@pixelastic ok, thank you very much.
Actually, I already have this piece of code in my search.js
file. (I copied the whole algolia.js
file from Jekyll/Hyde demo.) But it's still not working for me.
from algoliasearch-jekyll.
Sorry to hear that it did not work for you. If you have a public url I can have a look and see what is not working.
But as I understand this issue you prefer having the results pointing to the top of the page anyway. I'll close this issue for now then, but feel free to comment back if you want to push it further.
from algoliasearch-jekyll.
Ok, thank you very much. I'll send you a link when I push it to GitHub.
from algoliasearch-jekyll.
Related Issues (20)
- Enhancement: Using the new facetingAfterDistinct=true for correct facet count HOT 3
- Timeout at indexing time HOT 6
- Content not rendered with Liquid before indexing? HOT 6
- Error: API key cannot write to {index_name}_tmp index HOT 2
- Ruby 2.4 compatibility HOT 2
- Status of V1 HOT 7
- Typo in README
- algolia selector returning undefined HOT 6
- Plugin not pushing all pages to index HOT 3
- Catch errors when zero element indexed HOT 1
- Unable to exclude files from indexing based on directories HOT 2
- Update json dependency to v2.0
- Update nokogiri dependency to version 1.7.2 or higher HOT 3
- Nokogiri Error HOT 8
- Better explain the difference between record_css_selector and attributesToIndex settings HOT 2
- Algolia push error: "no implicit conversion of nil into Hash" HOT 5
- Cannot install algoliasearch-jekyll HOT 6
- Asciidoc files don't get indexed HOT 1
- Synonyms deleted on index HOT 6
- Using "removeWordsIfNOResults" setting parameter does not seem to work HOT 10
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from algoliasearch-jekyll.