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
Including page title in search results #2076
Comments
The search index is created by breaking up a page into its individual sections (divided by headers). Each section is then indexed as if it was its own separate document. However, the entire page is also indexed as a single document. Therefore, the same result should appear twice: once as its own section (without the page title) and once as part of the entire page (with the page title). I suppose we could store the page title as another attribute in the index for the page sections. A PR is welcome. |
Does this sort of patch look like a reasonable way to do it? One additional feature is to add the url to the search text so that searching by file name will bring up a link to the specific file.
|
I would also find this very helpful to identify the correct page in search results |
Seconded |
Me as well. |
Me, too 👍 |
To show titles in a meaningful and non-confusing way, sections would need to be sorted under pages, or navigation breadcrumbs should be shown. Nowadays (2024) lunr.js is unmaintained (last commit 2020). While we welcome enhancements to existing themes, we're also discussing creating a new, better default theme, which would probably use something else than lunr.js. @squidfunk also stated that he and his team are working on a standalone search plugin that is theme-agnostic and will bring such functionality, see the discussion starting here #3560 (comment). For these reasons, we'll close this as not planned! If someone wants to work on this anyway, we can re-open the issue. |
The search results include the section header where a keyword is found, but not the page that it was found on, which sometimes makes it difficult to tell which one is the most relevant. Is it possible to include the page title in the search results like
Page title - Section
?Test case is using mkdocs 1.1 and has three files:
The text was updated successfully, but these errors were encountered: