Linking to relevant content on result page (internal anchor)

Hi there,

I’ve recently started using Algolia search and am finding it really intuitive. There’s only one thing I’m struggling with, and thought someone may know the answer. I think it might be an advanced feature ask.

In the hits I’m getting back from the index.search query, I can’t see any indication for where the content is in the destination page, like a link to the parent heading or div with an ID. Is there a way to configure this?

I saw in the Algolia Doc Search that if your headings have id’s, then they can be used for linking to internal anchors, but I couldn’t find the same for a basic search.

Hope you can help, thanks.

Hi @mledwards,

Thanks for writing into the community forum - it’s a great idea so that everyone can benefit from this Q&A.

I want to understand a bit more about your question:

 I can’t see any indication for where the content is in the destination page, like a link to the parent heading or div with an ID. Is there a way to configure this?

From my initial understanding of your question, it sounds like you are trying to figure out how you actually link to your final page. If that’s the case then imagine you have a record where you include the URL in an attribute:

{
    "name": "my product",
    "url": "http://www.myproductpage.com"
}

You can then use that url value in your template so that on-click it hyperlinks to the product/record page.

Does that get you going on the right path? Please feel free to clarify if you need more help.

Hi David,

Thanks for your prompt response.

I’ve got the results linking through to the final pages, my question is related to linking to where the actual content is on the final page. The internal anchor points.

For example, one search will say “…Brand logo…” which appears about 3/4 of the way down the page. But I can only see the page URL, not any internal anchors.

@ajay.david Are you able to follow up on this? Basically, it would be great to know how to link to specific parts of pages.

Hi @mledwards,

Thanks for following-up.

I can comment on the part related to Algolia, but as for the specifics on the syntax for this URL value to put in the href attribute I’ll share some resources that could point you in the right direction - honesty is the best policy and I am not certain of the right format, but that part is getting into HTML syntax outside the scope of Algolia.

As we already mentioned you’ll have an attribute for the desired URL value, now whether that should now look like:

{
    "name": "my product",
    "url": "http://www.myproductpage.com/#id_of_target_element_on_page"
}

or something else, I hope the below help as they seem to be similar questions: