You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/creating-content/documentation-pages.md
+111-9Lines changed: 111 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -100,7 +100,39 @@ navigation:
100
100
priority: 5
101
101
```
102
102
103
-
You can also change the order in the `config/docs.php` configuration file, which may be easier to manage for larger sites. See [the chapter in the customization page](customization#navigation-menu--sidebar) for more details.
103
+
You can also change the order in the `config/docs.php` configuration file, which may be easier to manage for larger sites.
104
+
105
+
#### Basic Priority Syntax
106
+
107
+
A nice and simple way to define the order of pages is to add their route keys as a simple list array. Hyde will then match that array order.
108
+
109
+
It may be useful to know that Hyde internally will assign a priority calculated according to its position in the list, plus an offset of `500`. The offset is added to make it easier to place pages earlier in the list using front matter or with explicit priority settings.
110
+
111
+
```php
112
+
// filepath: config/docs.php
113
+
'sidebar' => [
114
+
'order' => [
115
+
'readme', // Priority: 500
116
+
'installation', // Priority: 501
117
+
'getting-started', // Priority: 502
118
+
]
119
+
]
120
+
```
121
+
122
+
#### Explicit Priority Syntax
123
+
124
+
You can also specify explicit priorities by adding a value to the array keys. Hyde will then use these exact values as the priorities.
125
+
126
+
```php
127
+
// filepath: config/docs.php
128
+
'sidebar' => [
129
+
'order' => [
130
+
'readme' => 10,
131
+
'installation' => 15,
132
+
'getting-started' => 20,
133
+
]
134
+
]
135
+
```
104
136
105
137
### Sidebar Labels
106
138
@@ -130,13 +162,11 @@ navigation:
130
162
131
163
#### Automatic Subdirectory-Based Grouping
132
164
133
-
You can also automatically group your documentation pages by placing source files in sub-directories.
165
+
You can also automatically group your documentation pages by placing source files in subdirectories.
134
166
135
167
For example, putting a Markdown file in `_docs/getting-started/` is equivalent to adding the same front matter seen above.
136
168
137
-
>info Note that when the [flattened output paths](#using-flattened-output-paths) setting is enabled (which it is by default), the file will still be compiled to the `_site/docs/` directory like it would be if you didn't use the subdirectories. Note that this means that you can't have two documentation pages with the same filename as they would overwrite each other.
138
-
139
-
>info Tip: When using subdirectory-based grouping, you can set the priority of the groups using the directory name as the array key in the config file.
169
+
>warning Note that when the [flattened output paths](#using-flattened-output-paths) setting is enabled (which it is by default), the file will still be compiled to the `_site/docs/` directory like it would be if you didn't use the subdirectories. Note that this means that you can't have two documentation pages with the same filename as they would overwrite each other.
140
170
141
171
### Hiding Items
142
172
@@ -213,11 +243,9 @@ To quickly arrange the order of items in the sidebar, you can reorder the page i
213
243
214
244
See [the chapter in the customization page](customization#navigation-menu--sidebar) for more details. <br>
215
245
216
-
### Automatic Sidebar Group Labels
217
-
218
-
When using the automatic sidebar grouping feature (based on subdirectories), the titles of the groups are generated from the directory names. If these are not to your liking, for example if you need to use special characters, you can override them in the Docs configuration file. The array key is the directory name, and the value is the label.
246
+
### Setting Sidebar Group Labels
219
247
220
-
Please note that this option is not added to the config file by default, as it's not a super common use case. No worries though, just add the following yourself!
248
+
When using the automatic sidebar grouping feature the titles of the groups are generated from the subdirectory names. If these are not to your liking, for example if you need to use special characters, you can override them in the configuration file. The array key is the directory name, and the value is the label.
221
249
222
250
```php
223
251
// Filepath: config/docs.php
@@ -227,6 +255,80 @@ Please note that this option is not added to the config file by default, as it's
227
255
],
228
256
```
229
257
258
+
Please note that this option is not added to the config file by default, as it's not a super common use case. No worries though, just add the following yourself!
259
+
260
+
#### Setting Sidebar Group Priorities
261
+
262
+
By default, each group will be assigned the lowest priority found inside the group. However, you can specify the order and priorities for sidebar group keys the same way you can for the sidebar items.
263
+
264
+
Just use the sidebar group key as instead of the page identifier/route key:
265
+
266
+
```php
267
+
// Filepath: config/docs.php
268
+
'sidebar' => [
269
+
'order' => [
270
+
'readme',
271
+
'installation',
272
+
'getting-started',
273
+
],
274
+
],
275
+
```
276
+
277
+
### Numerical Prefix Sidebar Ordering
278
+
279
+
HydePHP v2 introduces sidebar item ordering based on numerical prefixes in filenames. This feature works for the documentation sidebar.
280
+
281
+
This has the great benefit of matching the sidebar layout with the file structure view. It also works especially well with subdirectory-based sidebar grouping.
282
+
283
+
```shell
284
+
_docs/
285
+
01-installation.md # Priority: 1
286
+
02-configuration.md # Priority: 2
287
+
03-usage.md # Priority: 3
288
+
```
289
+
290
+
As you can see, Hyde parses the number from the filename and uses it as the priority for the page in the sidebar, while stripping the prefix from the route key.
291
+
292
+
#### Important Notes
293
+
294
+
1. The numerical prefix remains part of the page identifier but is stripped from the route key.
295
+
For example: `_docs/01-installation.md`has route key `installation` and page identifier `01-installation`.
296
+
2. You can delimit the numerical prefix with either a dash or an underscore.
297
+
For example: Both `_docs/01-installation.md` and `_docs/01_installation.md` are valid.
298
+
3. Leading zeros are optional. `_docs/1-installation.md` is equally valid.
299
+
300
+
#### Using Numerical Prefix Ordering in Subdirectories
301
+
302
+
This feature integrates well with automatic subdirectory-based sidebar grouping. Here's an example of how you could organize a documentation site:
303
+
304
+
```shell
305
+
_docs/
306
+
01-getting-started/
307
+
01-installation.md
308
+
02-requirements.md
309
+
03-configuration.md
310
+
02-usage/
311
+
01-quick-start.md
312
+
02-advanced-usage.md
313
+
03-features/
314
+
01-feature-1.md
315
+
02-feature-2.md
316
+
```
317
+
318
+
Here are two useful tips:
319
+
320
+
1. You can use numerical prefixes in subdirectories to control the sidebar group order.
321
+
2. The numbering within a subdirectory works independently of its siblings, so you can start from one in each subdirectory.
322
+
323
+
#### Customization
324
+
325
+
If you're not interested in using numerical prefix ordering, you can disable it in the Hyde config file. Hyde will then no longer extract the priority and will no longer strip the prefix from the route key.
326
+
327
+
```php
328
+
// filepath: config/hyde.php
329
+
'numerical_page_ordering' => false,
330
+
```
331
+
230
332
### Table of Contents Settings
231
333
232
334
Hyde automatically generates a table of contents for the page and adds it to the sidebar.
Copy file name to clipboardExpand all lines: docs/digging-deeper/navigation.md
+8-69Lines changed: 8 additions & 69 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,15 +8,15 @@ navigation:
8
8
9
9
## Introduction
10
10
11
-
HydePHP offers automatic navigation menu and documentation sidebar generation features, designed to take the pain out of creating navigation menus.
11
+
HydePHP offers automatic navigation menu generation features, designed to take the pain out of creating navigation menus.
12
12
While Hyde does its best to configure these menus automatically based on understanding your project files, you may want to customize them further.
13
13
14
14
There are two types of navigation menus in Hyde:
15
15
16
16
1.**Primary Navigation Menu**: The main navigation menu appearing on most pages of your site. Unique features include dropdowns for subdirectories, depending on configuration.
17
17
2.**Documentation Sidebar**: The sidebar on documentation pages with links to other documentation pages. Unique features include automatic grouping based on subdirectories.
18
18
19
-
This documentation will guide you through the customization process. To learn even more about sidebars, visit the [Documentation Pages](documentation-pages) documentation.
19
+
This documentation will guide you through the customization process of the primary navigation menu. To learn about the documentation sidebar, visit the [Documentation Pages](documentation-pages) documentation.
20
20
21
21
### Internal Structure Overview
22
22
@@ -43,11 +43,10 @@ Hyde provides multiple ways to customize navigation menus to suit your needs:
43
43
44
44
1. Front matter data in Markdown and Blade page files, applicable to all menu types
45
45
2. Configuration in the `hyde` config file for main navigation items
46
-
3. Configuration in the `docs` config file for documentation sidebar items
47
46
48
47
Keep in mind that front matter data overrides dynamically inferred or config-defined priorities. While useful for quick one-off changes on small sites, it can make reordering items later on more challenging as you can't see the entire structure at once.
49
48
50
-
Additionally, general options for the entire navigation menus are also available in the `hyde`and `docs`config files.
49
+
Additionally, general options for the entire navigation menus are also available in the `hyde` config file.
51
50
52
51
## Front Matter Configuration
53
52
@@ -105,16 +104,15 @@ navigation:
105
104
106
105
## Config File Configuration
107
106
108
-
Let's explore how to customize navigation menus using configuration files:
107
+
Let's explore how to customize the main navigation menu using configuration files:
109
108
110
109
- For the main navigation menu, use the `navigation` setting in the `hyde.php` config file.
111
-
- For the sidebar, use the `sidebar` setting in the `docs.php` config file.
112
110
113
-
When customizing the main navigation menu, use the [route key](core-concepts#route-keys) of the page. For the sidebar, you can use either the route key or the [page identifier](core-concepts#page-identifiers).
111
+
When customizing the main navigation menu, use the [route key](core-concepts#route-keys) of the page.
114
112
115
113
### Changing Priorities
116
114
117
-
The `navigation.order` and `sidebar.order` settings allow you to customize the order of pages in the navigation menus.
115
+
The `navigation.order` setting allows you to customize the order of pages in the main navigation menu.
118
116
119
117
#### Basic Priority Syntax
120
118
@@ -133,17 +131,6 @@ It may be useful to know that we internally will assign a priority calculated ac
133
131
]
134
132
```
135
133
136
-
```php
137
-
// filepath: config/docs.php
138
-
'sidebar' => [
139
-
'order' => [
140
-
'readme', // Priority: 500
141
-
'installation', // Priority: 501
142
-
'getting-started', // Priority: 502
143
-
]
144
-
]
145
-
```
146
-
147
134
#### Explicit Priority Syntax
148
135
149
136
You can also specify explicit priorities by adding a value to the array keys. We'll then use these exact values as the priorities.
@@ -159,28 +146,6 @@ You can also specify explicit priorities by adding a value to the array keys. We
159
146
]
160
147
```
161
148
162
-
```php
163
-
// filepath: config/docs.php
164
-
'sidebar' => [
165
-
'order' => [
166
-
'readme' => 10,
167
-
'installation' => 15,
168
-
'getting-started' => 20,
169
-
]
170
-
]
171
-
```
172
-
173
-
You could also combine these methods if desired:
174
-
175
-
```php
176
-
// filepath: Applicable to both
177
-
[
178
-
'readme' => 10, // Priority: 10
179
-
'installation', // Priority: 500
180
-
'getting-started', // Priority: 501
181
-
]
182
-
```
183
-
184
149
### Changing Menu Item Labels
185
150
186
151
Hyde makes a few attempts to find suitable labels for the navigation menu items to automatically create helpful titles.
@@ -197,8 +162,6 @@ If you're not happy with these, it's easy to override navigation link labels by
197
162
]
198
163
```
199
164
200
-
**Note:** This feature is not yet supported for the sidebar.
201
-
202
165
### Excluding Items (Blacklist)
203
166
204
167
When you have many pages, it may be useful to prevent links from being added to the main navigation menu.
@@ -268,22 +231,14 @@ Enable this feature in the `hyde.php` config file by setting the `subdirectory_d
268
231
269
232
Now if you create a page called `_pages/about/contact.md`, it will automatically be placed in a dropdown called "About".
270
233
271
-
#### Automatic Documentation Sidebar Grouping
272
-
273
-
This feature is always enabled for documentation pages. Simply place your pages in subdirectories to have them grouped in the sidebar.
274
-
275
-
For example: `_docs/getting-started/installation.md`will be placed in a group called "Getting Started".
276
-
277
-
>info Tip: When using subdirectory-based dropdowns, you can set their priority using the directory name as the array key.
278
-
279
234
#### Dropdown Menu Notes
280
235
281
236
- Dropdowns take priority over standard items. If you have a dropdown with the key `about` and a page with the key `about`, the dropdown will be created, and the page won't be in the menu.
282
237
- Example: With this file structure: `_pages/foo.md`, `_pages/foo/bar.md`, `_pages/foo/baz.md`, the link to `foo` will be lost, so please keep this in mind when using this feature.
283
238
284
239
## Numerical Prefix Navigation Ordering
285
240
286
-
HydePHP v2 introduces navigation item ordering based on numerical prefixes in filenames. This feature works for both the primary navigation menu and the documentation sidebar.
241
+
HydePHP v2 introduces navigation item ordering based on numerical prefixes in filenames. This feature works for the primary navigation menu.
287
242
288
243
This has the great benefit of matching the navigation menu layout with the file structure view. It also works especially well with subdirectory-based navigation grouping.
289
244
@@ -308,25 +263,9 @@ As you can see, Hyde parses the number from the filename and uses it as the prio
308
263
309
264
This feature integrates well with automatic subdirectory-based navigation grouping. Here are two useful tips:
310
265
311
-
1. You can use numerical prefixes in subdirectories to control the dropdown/sidebar order.
266
+
1. You can use numerical prefixes in subdirectories to control the dropdown order.
312
267
2. The numbering within a subdirectory works independently of its siblings, so you can start from one in each subdirectory.
313
268
314
-
Here is an example structure of how you could organize a documentation site:
315
-
316
-
```shell
317
-
_docs/
318
-
01-getting-started/
319
-
01-installation.md
320
-
02-requirements.md
321
-
03-configuration.md
322
-
02-usage/
323
-
01-quick-start.md
324
-
02-advanced-usage.md
325
-
03-features/
326
-
01-feature-1.md
327
-
02-feature-2.md
328
-
```
329
-
330
269
### Customization
331
270
332
271
If you're not interested in using numerical prefix ordering, you can disable it in the Hyde config file. Hyde will then no longer extract the priority and will no longer strip the prefix from the route key.
0 commit comments