1
0
mirror of https://github.com/thangisme/notes.git synced 2024-12-22 17:26:25 -05:00
notes/docs/navigation-structure.md

234 lines
5.4 KiB
Markdown
Raw Normal View History

2017-03-24 09:47:37 -04:00
---
layout: default
title: Navigation Structure
2018-11-16 11:47:14 -05:00
nav_order: 5
2017-03-24 09:47:37 -04:00
---
# Navigation Structure
2017-04-08 18:51:14 -04:00
{: .no_toc }
2017-03-24 09:47:37 -04:00
## Table of contents
{: .no_toc .text-delta }
1. TOC
{:toc}
---
## Main navigation
2018-11-19 16:26:22 -05:00
The main navigation for your Just the Docs site is on the left side of the page at large screens and on the top (behind a tap) on small screens. The main navigation can be structured to accommodate a multi-level menu system (pages with children and grandchildren).
2017-04-08 18:51:14 -04:00
2018-11-19 16:26:22 -05:00
By default, all pages will appear as top level pages in the main nav unless a parent page is defined (see [Pages with Children](#pages-with-children)).
2017-04-08 18:51:14 -04:00
2018-11-19 16:26:22 -05:00
---
2017-04-08 18:51:14 -04:00
2018-11-19 16:26:22 -05:00
## Ordering pages
2017-04-08 18:51:14 -04:00
2019-01-14 14:32:41 -05:00
To specify a page order, use the `nav_order` parameter in your pages' YAML front matter.
2017-04-08 18:51:14 -04:00
2018-11-16 14:55:20 -05:00
#### Example
{: .no_toc }
2019-01-14 14:18:09 -05:00
2017-04-08 18:51:14 -04:00
```yaml
---
layout: default
title: Customization
nav_order: 4
---
```
The specified `nav_order` parameters on a site should be all integers or all strings.
Pages without a `nav_order` parameter are ordered alphabetically by their `title`,
and appear after the explicitly-ordered pages at each level.
To sort all Capital letters before lowercase letters,
add `nav_sort: case_sensitive` in the configuration file.
2018-11-19 16:26:22 -05:00
---
## Excluding pages
2018-11-16 13:57:49 -05:00
2019-01-14 14:32:41 -05:00
For specific pages that you do not wish to include in the main navigation, e.g. a 404 page or a landing page, use the `nav_exclude: true` parameter in the YAML front matter for that page.
2018-11-16 13:57:49 -05:00
2018-11-16 14:55:20 -05:00
#### Example
{: .no_toc }
2019-01-14 14:18:09 -05:00
2018-11-16 13:57:49 -05:00
```yaml
---
layout: default
title: 404
nav_exclude: true
---
```
2018-11-19 16:26:22 -05:00
---
## Pages with children
2017-04-08 18:51:14 -04:00
2019-01-14 14:32:41 -05:00
Sometimes you will want to create a page with many children (a section). First, it is recommended that you keep pages that are related in a directory together... For example, in these docs, we keep all of the written documentation in the `./docs` directory and each of the sections in subdirectories like `./docs/ui-components` and `./docs/utilities`. This gives us an organization like:
2017-04-08 18:51:14 -04:00
```
+-- ..
|-- (Jekyll files)
|
|-- docs
| |-- ui-components
| | |-- index.md (parent page)
2017-04-08 18:51:14 -04:00
| | |-- buttons.md
| | |-- code.md
| | |-- labels.md
| | |-- tables.md
| | +-- typography.md
| |
| |-- utilities
| | |-- index.md (parent page)
2017-04-08 18:51:14 -04:00
| | |-- color.md
| | |-- layout.md
| | |-- responsive-modifiers.md
| | +-- typography.md
| |
| |-- (other md files, pages with no children)
| +-- ..
|
|-- (Jekyll files)
+-- ..
```
On the parent pages, add this YAML front matter parameter:
2019-01-14 14:32:41 -05:00
- `has_children: true` (tells us that this is a parent page)
2017-04-08 18:51:14 -04:00
#### Example
{: .no_toc }
2019-01-14 14:18:09 -05:00
2017-04-08 18:51:14 -04:00
```yaml
2018-11-16 14:55:20 -05:00
---
2017-04-08 18:51:14 -04:00
layout: default
title: UI Components
nav_order: 2
has_children: true
2018-11-16 14:55:20 -05:00
---
2017-04-08 18:51:14 -04:00
```
2019-01-14 14:32:41 -05:00
Here we're setting up the UI Components landing page that is available at `/docs/ui-components`, which has children and is ordered second in the main nav.
2017-04-08 18:51:14 -04:00
### Child pages
2018-11-19 16:26:22 -05:00
{: .text-gamma }
2017-04-08 18:51:14 -04:00
On child pages, simply set the `parent:` YAML front matter to whatever the parent's page title is and set a nav order (this number is now scoped within the section).
#### Example
{: .no_toc }
2019-01-14 14:18:09 -05:00
2017-04-08 18:51:14 -04:00
```yaml
2018-11-16 14:55:20 -05:00
---
2017-04-08 18:51:14 -04:00
layout: default
title: Buttons
parent: UI Components
nav_order: 2
2018-11-16 14:55:20 -05:00
---
2017-04-08 18:51:14 -04:00
```
2019-01-14 14:32:41 -05:00
The Buttons page appears as a child of UI Components and appears second in the UI Components section.
2018-12-16 14:27:44 -05:00
### Auto-generating Table of Contents
2019-01-14 14:32:41 -05:00
By default, all pages with children will automatically append a Table of Contents which lists the child pages after the parent page's content. To disable this auto Table of Contents, set `has_toc: false` in the parent page's YAML front matter.
2018-12-16 14:27:44 -05:00
#### Example
{: .no_toc }
2019-01-14 14:18:09 -05:00
2018-12-16 14:27:44 -05:00
```yaml
---
layout: default
title: UI Components
nav_order: 2
has_children: true
has_toc: false
---
```
2018-11-19 13:50:54 -05:00
### Children with children
2018-11-19 16:26:22 -05:00
{: .text-gamma }
2018-11-19 13:50:54 -05:00
2019-01-14 14:18:09 -05:00
Child pages can also have children (grandchildren). This is achieved by using a similar pattern on the child and grandchild pages.
2018-11-19 13:50:54 -05:00
1. Add the `has_children` attribute to the child
1. Add the `parent` and `grand_parent` attribute to the grandchild
#### Example
{: .no_toc }
```yaml
---
layout: default
title: Buttons
parent: UI Components
nav_order: 2
has_children: true
---
```
```yaml
---
layout: default
title: Buttons Child Page
parent: Buttons
grand_parent: UI Components
nav_order: 1
---
```
2019-01-14 14:32:41 -05:00
This would create the following navigation structure:
2018-11-19 13:50:54 -05:00
```
+-- ..
|
|-- UI Components
| |-- ..
| |
| |-- Buttons
| | |-- Button Child Page
| |
| |-- ..
|
+-- ..
```
2017-03-24 09:47:37 -04:00
---
2018-11-19 16:26:22 -05:00
## Auxiliary Navigation
2017-03-26 21:09:19 -04:00
2018-11-19 16:26:22 -05:00
To add a auxiliary navigation item to your site (in the upper right on all pages), add it to the `aux_nav` [configuration option]({{ site.baseurl }}{% link docs/configuration.md %}#aux-nav) in your site's `_config.yml` file.
#### Example
{: .no_toc }
2019-01-15 20:43:19 -05:00
```yaml
2018-11-19 16:26:22 -05:00
# Aux links for the upper right navigation
aux_links:
2019-01-14 14:18:09 -05:00
"Just the Docs on GitHub":
2018-11-19 16:26:22 -05:00
- "//github.com/pmarsceill/just-the-docs"
```
2017-04-08 18:51:14 -04:00
2017-03-26 21:09:19 -04:00
---
2017-03-24 09:47:37 -04:00
## In-page navigation with Table of Contents
2017-04-08 18:51:14 -04:00
2019-01-14 14:32:41 -05:00
To generate a Table of Contents on your docs pages, you can use the `{:toc}` method from Kramdown, immediately after an `<ol>` in Markdown. This will automatically generate an ordered list of anchor links to various sections of the page based on headings and heading levels. There may be occasions where you're using a heading and you don't want it to show up in the TOC, so to skip a particular heading use the `{: .no_toc }` CSS class.
2017-04-08 18:51:14 -04:00
#### Example
{: .no_toc }
```markdown
# Navigation Structure
{: .no_toc }
## Table of contents
{: .no_toc .text-delta }
1. TOC
{:toc}
```
This example skips the page name heading (`#`) from the TOC, as well as the heading for the Table of Contents itself (`##`) because it is redundant, followed by the table of contents itself.