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

Is it possible to hide a single file from nav? #102

Open
madjxatw opened this issue Mar 3, 2024 · 8 comments
Open

Is it possible to hide a single file from nav? #102

madjxatw opened this issue Mar 3, 2024 · 8 comments

Comments

@madjxatw
Copy link

madjxatw commented Mar 3, 2024

I see that hide: true could hide a directory from the navigation, but is there any simple way to hide a single file? The regex syntax might be used to filter out a file with a specific name, but I couldn't find an example. Please advice, thanks.

@lukasgeiter
Copy link
Owner

Not really. The regex might be able to do the trick, but it's not what it was designed for. Can you describe your use-case for hiding a single file?

@madjxatw
Copy link
Author

madjxatw commented Mar 4, 2024

I have some extra documents as supplementary readings, they do not and should not belong to the docs of my project. I only want to reference them from a Markdown file using the Markdown link syntax [](), so I need to make them part of the site but not directly navigable.

I might hide more files and expect a mechanism that works in the similar way as .gitignore where I could simply prefix a symbol (e.g. !) to ignore a file. I am not sure if this feature could be implemented by a plugin, maybe it is not possible due to the limitation of mkdocs itself.

@VladimirFokow
Copy link
Contributor

VladimirFokow commented Mar 4, 2024

@madjxatw
Here's an example that I used to put the 'Home' tab first, and then everything else (except for the top-level index.md file):

nav:
  - ... | home/**  # first in the nav order is the 'Home' tab
  - ... | regex=^(?!index\.md$).*  # then, all paths that are not exactly "index.md" of the root

But for your use-case, why can't you put all the files you want to hide into a directory and then just hide this directory?

@madjxatw
Copy link
Author

madjxatw commented Mar 4, 2024

@VladimirFokow, it sounds a good workaround to have a dedicated directory if there is no other better way, thanks!

@madjxatw
Copy link
Author

madjxatw commented Mar 4, 2024

@lukasgeiter , another use case is when blog pattern is enabled, a tags.md file is placed in the docs to make tags in each blog post clickable. See https://squidfunk.github.io/mkdocs-material/plugins/tags/?h=tags#config.tags_file. I want to include everything excluding the tags file.

@VladimirFokow
Copy link
Contributor

VladimirFokow commented Mar 4, 2024

@madjxatw , as far as I understand, you specify

plugins:
  - tags:
      tags_file: tags.md

only once - in mkdocs.yml file.
So there is only one tags_file path that exists - only one page where you see all your tags.

If you want to exclude this page from nav - also put it into that hidden folder?
(just remember to update its path in mkdocs.yml)

@madjxatw
Copy link
Author

madjxatw commented Mar 4, 2024

@VladimirFokow , I am currently using dedicated directories as you suggested for what to be hidden in nav. My site has a complex directory structure, so I create a "hidden" folder in each subdirectory (section) as needed for better organization and managment. Really appreciate your suggestion and awesome-pages plugin!

BTW, I still kind of expect that MkDocs itself offers a feature similar to gitignore in the future instead of .pages files being scattered around. 😛

@lukasgeiter
Copy link
Owner

Thanks for helping out @VladimirFokow!

Indeed, at the moment a hidden folder is the easiest solution. I've been playing with the thought of adding exclude patterns before, so it's good to know that there's a need for that 👍

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

No branches or pull requests

3 participants