In large MkDocs sites there could be multiple pages with similar title residing under different navigation paths or sections. It is difficult to see from the search results in which section the particular article is located in.
Search results should display the full navigation path to the pages just like in the header of the website, for example:
This could be an optional configurable feature, toggled on or off.
Only title is displayed in the search results:
2.7.50.16.31.6.4site_name: My Test Docs
site_description: Test documentation
copyright: 'Copyright © 2017 My Company'
theme: material
repo_url: https://git.mytestcompany.com/tech/docs
edit_uri: edit/master/docs/
site_favicon: 'img/favicon.ico'
theme_dir: 'theme'
markdown_extensions:
- admonition
- codehilite:
linenums: False
guess_lang: True
pygments_style: 'native'
noclasses: True
- toc:
permalink: True
separator: "_"
extra:
feature:
tabs: true
logo: 'img/logo.png'
palette:
primary: 'light blue'
accent: 'indigo'
font:
text: 'Roboto'
code: 'Roboto Mono'
pages:
- 'Start': 'index.md'
- 'FAQ': 'faq.md'
- My First Section:
- 'My Page': 'section1/mypage.md'
- 'Some Page': 'section1/somepage.md'
- My Second Section:
- 'My Page': 'section2/mypage.md'
- 'Other Page': 'section2/otherpage.md'
Not possible, because this information is missing from the search index MkDocs exposes. The only thing that could be used is the URL, because the path information is also encoded in the URL.
OK, I would be interested in at least displaying the URL in the results but not sure how to customize the results. Thank you.
The search results are generated dynamically inside the Search/Result.jsx class/file. You could include the URL below here:
https://github.com/squidfunk/mkdocs-material/blob/master/src/assets/javascripts/components/Material/Search/Result.jsx#L228
(doc.location)
and here:
https://github.com/squidfunk/mkdocs-material/blob/master/src/assets/javascripts/components/Material/Search/Result.jsx#L243
(section.location)
Then you need to set the styles for your changes which can be done through extra_css
Hi @squidfunk, I am interested in implementing showing the URL in the search result and formatting it to show the full article path.
Can you provide more information on what needs to be added to the lines you mention for doc.location/section.location. I am not proficient in javascript and JS class files.