Skip to content
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

Ignore anchor with h1/lvl1 #1745

Open
oliviertassinari opened this issue Dec 31, 2022 · 0 comments
Open

Ignore anchor with h1/lvl1 #1745

oliviertassinari opened this issue Dec 31, 2022 · 0 comments
Labels
crawler issue related to the indexing

Comments

@oliviertassinari
Copy link
Contributor

oliviertassinari commented Dec 31, 2022

Description

https://docsearch.algolia.com/docs/tips/#add-anchors-to-headings and https://docsearch.algolia.com/docs/required-configuration/#use-the-right-classes-as-recordprops makes a lot of sense for h2,h3,h4, etc.

However, I believe that it's harmful to h1. e.g. https://docusaurus.io/ doesn't have an anchor. The value is so that people get a cleaner URL when they copy and paste it to share after a search, which happens quite often in my use cases.

I had to add this code so that the crawler won't pick up an anchor for the lvl1.

      recordExtractor: ({ $, helpers, url }) => {
        // Removing DOM elements we don't want to crawl
        const toRemove = ".skip-algolia-crawler";
        $(toRemove).remove();
+       $("#main-content, #__next").removeAttr("id");

Steps to reproduce

I could reproduce on: https://mui.com/material-ui/react-alert/ with https://crawler.algolia.com/admin/crawlers/739c29c8-99ea-4945-bd27-17a1df391902/configuration/edit.

I get this URL: https://mui.com/material-ui/react-alert/#main-content.

Expected behavior

helpers.docsearch doesn't try to find an anchor for h1.
I would get this URL: https://mui.com/material-ui/react-alert/.

Environment

  • DocSearch version: v3
@oliviertassinari oliviertassinari changed the title Strange behavior with anchors for headings Ignore anchor with h1 Dec 31, 2022
@oliviertassinari oliviertassinari changed the title Ignore anchor with h1 Ignore anchor with h1/lvl1 Dec 31, 2022
@shortcuts shortcuts added the crawler issue related to the indexing label Jan 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
crawler issue related to the indexing
Projects
None yet
Development

No branches or pull requests

2 participants