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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tags support 馃啎 #2593

Closed
squidfunk opened this issue Apr 24, 2021 · 12 comments
Closed

Tags support 馃啎 #2593

squidfunk opened this issue Apr 24, 2021 · 12 comments
Labels
announcement Issue announces news or new features change request Issue requests a new feature or improvement

Comments

@squidfunk
Copy link
Owner

squidfunk commented Apr 24, 2021

EDIT: Tags support is available as of Insiders 2.7.0! Check out the demo or the docs


Sometimes, it might be beneficial to group documents by specific tags, especially in very large codebases. There are some prior discussions on tag support on the MkDocs issue tracker (see below) and there is mkdocs-plugin-tags, which looks abandoned. In general I would consider the following features to provide a good first implementation for tag support:

  • The author can specify tags as part of the front matter of a document, exactly like in other static site generators like Jekyll.
  • Tags are rendered below above the actual content of the document
  • Tags are rendered inside the search and can be searched like the title and text of a document
  • There's an overview page that lists all tags and related articles (as provided by mkdocs-plugin-tags)

This is a sneak peek of how I would imagine tags to work inside search:

Ohne.Titel.mp4

This is how the tags overview page will look:

screenshot-localhost-8000-tags-1619362962713

This will not be an integration of the said plugin, but a standalone integration into Material for MkDocs itself, because I believe for this to be useful, it will need to be integrated deeply (search etc.).

Any feedback is appreciated!


Prior discussions:

@squidfunk squidfunk pinned this issue Apr 24, 2021
@squidfunk squidfunk added announcement Issue announces news or new features and removed proposal labels May 1, 2021
@squidfunk squidfunk changed the title Idea: tag support (+ search) Tags support 馃啎 May 1, 2021
@squidfunk squidfunk added the change request Issue requests a new feature or improvement label May 1, 2021
@Stanzilla
Copy link
Contributor

Love it, things to consider:

  • Mention that you have to "install" mkdocs now via ./mkdocs-material in requirements.txt when using a sub module / fork.
  • It would be nice if you could adjust the place the tag gets inserted in the template without having to touch the plugin itself

@Stanzilla
Copy link
Contributor

Suggestion: add tags to the list of things that hide: can hide.

@rjahern5
Copy link

rjahern5 commented May 5, 2021

I am getting some warnings in the tag implementation when build. Looks like everything 'works' fine though:

WARNING -  Documentation file 'tags.md' contains a link to 'api/some/page.html' which is not found in the documentation files. 

Looks like tags is explicitly referencing the page with the html extension instead of using md?

@squidfunk
Copy link
Owner Author

squidfunk commented May 5, 2021

@rjahern5 thanks for reporting. Could you give me some more details? If you could boil it down to a reproducible case, it's probably a quick fix. Are you using use_directory_urls: false?

@rjahern5
Copy link

rjahern5 commented May 6, 2021

@squidfunk yes sir, I just created a small sample project and changed it to true but it is still giving the same issue. I will open a different ticket for it. Incredible feature and thank you!

@squidfunk
Copy link
Owner Author

@rjahern5 see #2638.

@squidfunk
Copy link
Owner Author

@rjahern5 the issue should be fixed in Insiders 2.7.2.

@Kanaduchi
Copy link

Is it possible to add Tags to some headers and not whole page?

Example, I have some page, which contains ###Header1. And I want to set tag "Deprecated" only for this header.

@squidfunk
Copy link
Owner Author

@Kanaduchi tags are defined on a page level, so they cannot be set for specific headers.

@Kanaduchi
Copy link

@squidfunk can it be considered as a separate enhancement? Such feature can be very useful

@squidfunk
Copy link
Owner Author

squidfunk commented May 19, 2021

@Kanaduchi how would you imagine this to work, I mean from an authoring perspective? How could the Markdown look? Tags are defined in front matter, which we can only define once per document.

@squidfunk
Copy link
Owner Author

The latest commit on Insiders addresses the following two ideas by @Stanzilla:

  1. Tags can now be hidden on any page using front matter
  2. Tags are now rendered through a partial, making customization simpler. This made it necessary to render tags above the headline. If one wishes to move them below the content, this can now be done via regular theme extension.

I also adjusted the installation instructions to account for the built-in plugins which need to be installed when cloning from git.

Closing this issue. For all subsequent bug reports or feature requests, please open separate discussions or issues.

@squidfunk squidfunk unpinned this issue May 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
announcement Issue announces news or new features change request Issue requests a new feature or improvement
Projects
None yet
Development

No branches or pull requests

4 participants