Overview
This section describes how to create your site's main menu (the menu that appears in the header) and how to add docs to the sidebar navigation menu.
Both the main menu and the sidebar menu(s) are specified in the @kabartolo/gatsby-theme-chicago-docs
options in the gatsby-config.js
file for your site.
Main Menu
The main menu is the menu that appears in the header. In your gatsby-config.js
theme options, add an an array of objects called mainMenu
. Each object should have a name
and path
.
Omit this field if you don't want a main menu for your site.
module.exports = {plugins: [{resolve: '@kabartolo/gatsby-theme-chicago-docs',options: {menus: {mainMenu: [{name: 'Home',path: '/',},{name: 'Docs',path: '/docs/',},{name: 'Tutorials',path: '/tutorials/',},],},},},],}
Sidebar Menu
The sidebar menu lists the files that make up your project's documentation. This list is displayed in the sidebar, but it is also used on each doc page to create the breadcrumb links and the links to previous and next docs.
When displayed in the sidebar, the menu can organize doc files into groups (i.e., accordions) that can be expanded and collapsed. This helps make it easy to navigate your docs.
By default, single posts are also displayed as accordions that expand to show part of their table of contents. To disable this, set sidebarAllowTOC
to false
in the theme options. Also by default, multiple accordions can be open at the same time. You can disable this by setting sidebarAllowMultipleOpen
to false
(then only one accordion will be open at a time).
You can also change the nested accordion depth with sidebarDepth
(default: 3
) in the theme options. This is the total depth including groups and table of contents.
To create a sidebar menu, add an array called sidebarMenus
to the gatsby-config.js
options. This array is a list of objects with the following properties:
sidebarMenus properties
optionalstringname
default:''
(empty string)Used in the breadcrumb link (e.g.,
'Tutorials'
). This breadcrumb link will not appear ifname
is omitted.
optionalstringsidebarLabel
default: value ofname
Label appearing in the sidebar header (e.g.,
'Tutorials'
). Useful when there are multiple sidebar menus. If omitted, uses the value of thename
field. If set to''
(empty string), the sidebar header will not render.
optionalstringdropdownLabel
default: value ofname
Label appearing in the dropdown docs menu on mobile (e.g.,
'Menu'
). If omitted, uses the value of thename
field. If set to''
(empty string), no label will appear.
optionalstringslug
default:''
(empty string)The directory within
docsPath
containing the docs for this menu (e.g.,'tutorials'
forsrc/docs/tutorials
).
optionalstringitems
List of docs in custom order to be displayed in the menu. If omitted, the sidebar will be populated automatically from the
slug
directory. However, nested groups must contain anindex.mdx
file to be created automatically.
src└── docs└──tutorials├── jekyll│ ├── how-to-install-plugins.mdx│ ├── jekyll-quick-start.mdx│ ├── index.mdx├── gatsby| ├── gatsby-quick-start.mdx│ ├── how-to-install-plugins.mdx│ ├── index.mdx├── how-to-write-tutorials.mdx└── index.mdx
1234567891011121314151617181920
module.exports = {plugins: [{resolve: '@kabartolo/gatsby-theme-chicago-docs',options: {sidebarMenus: [{name: 'Tutorials',slug: 'tutorials',dropdownLabel: 'Menu',items: [// see example below],},],},},],}
Each item in the items
list can have the following properties:
Item properties
optionalstringname
default: value of frontmattershortTitle
ortitle
Label for the doc or group of docs in the sidebar (e.g.,
'Gatsby Tutorials'
). Also used in the breadcrumb link for this part of the path. For an automatically created group, this name defaults to theshortTitle
ortitle
of itsindex.mdx
.
requiredstringslug
Slug for a single doc (e.g.,
'how-to-write-tutorials'
) or the directory for a group of docs (e.g.,'jekyll'
).
optionalbooleanisGroup
default:false
Whether this item represents a directory of docs.
optionalobject[]items
default: all docs inslug
directoryList of docs in custom order to be displayed in the menu. If omitted, all docs in this directory are added automatically.
src└── docs└──tutorials├── jekyll│ ├── how-to-install-plugins.mdx│ ├── jekyll-quick-start.mdx│ ├── index.mdx├── gatsby| ├── gatsby-quick-start.mdx│ ├── how-to-install-plugins.mdx│ ├── index.mdx├── how-to-write-tutorials.mdx└── index.mdx
1234567891011121314151617181920212223242526272829303132333435363738394041
module.exports = {plugins: [{resolve: '@kabartolo/gatsby-theme-chicago-docs',options: {sidebarMenus: [{name: 'Tutorials',dropdownLabel: 'Menu',items: [{slug: 'how-to-write-tutorials',}{name: 'Jekyll Tutorials',slug: 'jekyll',isGroup: true,// items in custom orderitems: [{slug: 'jekyll-quick-start',},{slug: 'how-to-install-plugins',},],},{name: 'Gatsby Tutorials',slug: 'gatsby',isGroup: true,// items in folder added automatically},],},],},},],}
Multiple Sidebar Menus
You can define multiple sidebar menus for different parts of your site, grouped according to the base path of the docs (e.g., /tutorials
).
In this example, the first sidebar menu will appear for any docs with a base path of /documentation
(e.g., example.com/docs/documentation/gatsby/mdx-guide
, while the second will appear for any docs with a base path of /tutorials
(e.g., example.com/docs/tutorials/how-to-write-tutorials
):
src├───docs├── documentation│ ├── gatsby│ │ ├── index.mdx│ │ ├── mdx-guide.mdx│ │ ├── quick-start.mdx│ ├── index.mdx│ ├── overview.mdx└── tutorials├── jekyll│ ├── how-to-install-plugins.mdx│ ├── jekyll-quick-start.mdx│ ├── index.mdx├── gatsby| ├── gatsby-quick-start.mdx│ ├── how-to-install-plugins.mdx│ ├── index.mdx├── how-to-write-tutorials.mdx└── index.mdx
module.exports = {plugins: [{resolve: '@kabartolo/gatsby-theme-chicago-docs',options: {sidebarMenus: [{name: 'Documentation',slug: 'documentation',items: [{slug: 'overview',},{name: 'Usage with Gatsby',slug: 'gatsby',isGroup: true,// items in folder added automatically},],},{name: 'Tutorials',slug: 'tutorials',items: [{slug: 'how-to-write-tutorials',}{name: 'Jekyll Tutorials',slug: 'jekyll',isGroup: true,// items in custom orderitems: [{slug: 'jekyll-quick-start',},{slug: 'how-to-install-plugins',},],},{name: 'Gatsby Tutorials',slug: 'gatsby',isGroup: true,// items in folder added automatically},],},},},},],}