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

smart section titles when no navigation is configured #3356

Open
realtimeprojects opened this issue Aug 27, 2023 · 6 comments
Open

smart section titles when no navigation is configured #3356

realtimeprojects opened this issue Aug 27, 2023 · 6 comments

Comments

@realtimeprojects
Copy link

Given no navigation tree is defined in the configuration, the section titles for sub-directories should be determined by the following logic:

  • if an index page is defined, use the title of the index page, hereby the title from the meta data of the index page should be prefered to the title from the markdown in order to allow using a different title than the actual page title for the navigation menu.
  • If no index page is defined, keep the logic "as-is".

The user should be able to turn on/off this behaviour by a configuration option, e.g.

theme:
  features:
    - navigation.smart-section-titles
realtimeprojects added a commit to realtimeprojects/mkdocs that referenced this issue Aug 27, 2023
@zinizhu
Copy link

zinizhu commented Sep 6, 2023

+1 to this feature, the default section titles are not ideal, it's also hard to sort the directory order.

@tomchristie
Copy link
Member

Perhaps you could provide a short example?

@realtimeprojects
Copy link
Author

This repository contains a simple example:

https://github.com/realtimeprojects/mkdocs-sample/tree/master

This is how the page looks like at the moment:

Screen Shot 2024-04-20 at 15 18 23

Given the feature smart_section_titles is enabled, the page should look like this:

Screen Shot 2024-04-20 at 15 17 31

@realtimeprojects
Copy link
Author

Here is the PR with a basic implementation:
#3656

@oprypin
Copy link
Contributor

oprypin commented Apr 20, 2024

Thanks for the example site, that does make it clear.

The functionality that this request is about is specific to mkdocs-material. It doesn't make sense to apply a workaround in MkDocs to make section titles calculated based on a page, because in MkDocs there's never any direct relation between a section and a page inside it. If you try this with any other theme, it doesn't make any sense anymore.

I tried this out with the plugin "mkdocs-section-index", which does create these explicit associations in a generic way, but sadly it suffers from the same deficiency. Though implementing this functionality there would make a lot of sense.

@oprypin
Copy link
Contributor

oprypin commented Apr 20, 2024

And let me leave you with a fun tidbit.

This example site contains all kinds of plugins and extensions that one would need to install.
But I don't need to do any of that to try it out.

I just create the following file hatch.toml inside the directory:

[env]
requires = ["hatch-mkdocs"]

[env.collectors.mkdocs.docs]

And then running hatch run docs:serve does all the steps to view the site.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants