python-basic

⌘K
  1. Home
  2. Docs
  3. python-basic
  4. mkdocs
  5. Navigations

Navigations

Basic Navigation Structure

By default, MkDocs generates a basic navigation structure based on the files present in your docs directory. For example, if you have the following files:

docs/
  ├── index.md
  ├── getting-started.md
  └── installation.md
Bash

MkDocs will generate a simple navigation with links to these pages.

Custom Navigation

You can customize the navigation structure in the mkdocs.yml configuration file using the nav option. Here’s an example:

nav:
  - Home: index.md
  - Getting Started: getting-started.md
  - Installation Guide: installation.md
  - About:
    - Team: about/team.md
    - Contact: about/contact.md
Bash

In this example:

  • The nav key defines the navigation structure.
  • Each item in the navigation is a dictionary with the format Page Title: path/to/page.md.
  • You can also create dropdown menus in the navigation by providing a list of pages under a parent item.

External Links

You can also include external links in the navigation by providing the full URL instead of a file path. For example:

nav:
  - Home: index.md
  - GitHub: https://github.com/username/project
Bash

Order of Navigation

The order of items in the nav list determines their order in the navigation bar. You can reorder them as needed in the mkdocs.yml file.

Additional Options

MkDocs also provides additional options for customizing navigation, such as adding divider lines (-) and specifying icons for navigation items.

Example:

nav:
  - Home: index.md
  - Getting Started: getting-started.md
  - Installation Guide: installation.md
  - Divider
  - About:
    - Team: about/team.md
    - Contact: about/contact.md
  - GitHub: https://github.com/username/project
Bash

How can we help?