1
1
---
2
2
template : overrides/main.html
3
+ tags :
4
+ - HTML5
5
+ - JavaScript
6
+ - CSS
7
+ - Other
3
8
---
4
9
5
10
# Setting up tags
6
11
7
12
Material for MkDocs adds first-class support for categorizing pages with tags,
8
13
which adds the possibility to group related pages and make them discoverable
9
- via search and a dedicated tags index. If your documentation is large, tags
14
+ via search and a dedicated [ tags index] . If your documentation is large, tags
10
15
can help to discover relevant information faster.
11
16
17
+ [ tags index ] : #adding-a-tags-index
18
+
12
19
## Configuration
13
20
14
21
### Built-in tags plugin
@@ -32,8 +39,9 @@ The following configuration options are available:
32
39
33
40
: :octicons-milestone-24 : Default: _none_ – This option specifies which file
34
41
should be used to render the tags index. See the section on [adding a tags
35
- index] for more information. If this option is specified, tags will
36
- become clickable, pointing to the corresponding section in the tags index :
42
+ index][tags index] for more information. If this option is specified, tags
43
+ will become clickable, pointing to the corresponding section in the tags
44
+ index :
37
45
38
46
` ` ` yaml
39
47
plugins:
@@ -42,12 +50,92 @@ The following configuration options are available:
42
50
` ` `
43
51
44
52
The page holding the tags index can be linked anywhere in the `nav` section
45
- of `mkdocs.yml`. Note, however, that this options is not required. If this
46
- option is not specified, tags are still rendered and searchable,
47
- but without a tags index.
53
+ of `mkdocs.yml`. Note, however, that this options is not required – only use
54
+ it if you want a tags index page.
48
55
49
56
[tags support] : https://github.com/squidfunk/mkdocs-material/releases/tag/8.2.0
50
- [adding a tags index] : # adding-a-tags-index
57
+
58
+ # ## Tag icons
59
+
60
+ [:octicons-heart-fill-24:{ .mdx-heart } Insiders][Insiders]{ .mdx-insiders } ·
61
+ [:octicons-tag-24 : insiders-4.13.0][Insiders] ·
62
+ :octicons-beaker-24 : Experimental
63
+
64
+ Each tag can be associated with an icon, which is then rendered inside the tag.
65
+ Before assigning icons to tags, associate each tag with a unique identifier,
66
+ by adding the following to `mkdocs.yml` :
67
+
68
+ ` ` ` yaml
69
+ extra:
70
+ tags:
71
+ <tag>: <identifier> # (1)!
72
+ ` ` `
73
+
74
+ 1. The identifier can only include alphanumeric characters, as well as dashes
75
+ and underscores. For example, if you have a tag `Compatibility`, you can
76
+ set `compat` as an identifier :
77
+
78
+ ` ` ` yaml
79
+ extra:
80
+ tags:
81
+ Compatibility: compat
82
+ ` ` `
83
+
84
+ Identifiers can be reused between tags. Tags which are not explicitly
85
+ associated will use the default tag icon which is :material-pound :
86
+
87
+ Next, each identifier can be associated with an icon, or even a [custom icon],
88
+ by adding the following lines to `mkdocs.yml` under the `theme.icon`
89
+ configuration setting :
90
+
91
+ === "Tag icon"
92
+
93
+ ` ` ` yaml
94
+ theme:
95
+ icon:
96
+ tag:
97
+ <identifier>: <icon> # (1)!
98
+ ` ` `
99
+
100
+ 1. Enter a few keywords to find the perfect icon using our [icon search] and
101
+ click on the shortcode to copy it to your clipboard :
102
+
103
+ <div class="mdx-iconsearch" data-mdx-component="iconsearch">
104
+ <input class="md-input md-input--stretch mdx-iconsearch__input" placeholder="Search icon" data-mdx-component="iconsearch-query" value="tag" />
105
+ <div class="mdx-iconsearch-result" data-mdx-component="iconsearch-result" data-mdx-mode="file">
106
+ <div class="mdx-iconsearch-result__meta"></div>
107
+ <ol class="mdx-iconsearch-result__list"></ol>
108
+ </div>
109
+ </div>
110
+
111
+ === "Tag default icon"
112
+
113
+ ` ` ` yaml
114
+ theme:
115
+ icon:
116
+ tag:
117
+ default: <icon>
118
+ ` ` `
119
+
120
+ ??? example "Expand to inspect example"
121
+
122
+ ` ` ` yaml
123
+ theme:
124
+ icon:
125
+ tag:
126
+ html: fontawesome/brands/html5
127
+ js: fontawesome/brands/js
128
+ css: fontawesome/brands/css3
129
+ extra:
130
+ tags:
131
+ HTML5: html
132
+ JavaScript: js
133
+ CSS: css
134
+ ` ` `
135
+
136
+ [Insiders] : ../insiders/index.md
137
+ [custom icon] : changing-the-logo-and-icons.md#additional-icons
138
+ [icon search] : ../reference/icons-emojis.md#search
51
139
52
140
# # Usage
53
141
@@ -60,8 +148,10 @@ lines at the top of a Markdown file:
60
148
` ` ` sh
61
149
---
62
150
tags:
63
- - insiders
64
- - brand new
151
+ - html
152
+ - js
153
+ - css
154
+ - other
65
155
---
66
156
67
157
...
0 commit comments