Material for MkDocs
Material for MkDocs is a theme for the vanilla MkDocs ‘static site generator’.
The material part of that name appears to refer to “Material Design“, which according to Wikipedia is “a design language developed by Google in 2014”.
An example of the use of Material for MkDocs is the documentation of PiKVM,
Sites like this have various attractive characteristics.
Top bar
A relatively modest top bar runs horizontally against the top of the browser view. It is always shown, even when the page is getting scrolled down.
The bar contains an icon (in the standard Material for MkDocs layout this resembles a book with a reader’s head above it) which can be clicked to return to ‘the root of the site’.
Next to the ‘home’ icon, the name of the site is shown. This text changes to the name of the page when the header of any page is scrolled out of view. (The name of the site continues to be shown above the page overview enumeration in the browser viewport.)
The background color of the top bar is configurable.
Search
The top bar may contain a search section. This starts out as a narrow text input field. Clicking in it causes the box to expand over a wider section of the top bar.
Typing text into the search bar causes the expanded search box to further expand vertically, instantly showing content that matches the search string.
Sections within the match results can be clicked on, but the cursor up and down keys can also be used to traverse the list of matches.
For a match, both the page title and the matching content can be clicked or keyboard-selected. These actions cause the browser to be redirected to the beginning of the page or the section that actually matches.
Repository
A further section can be put onto the top bar, one that links back to a GitHub-like software repository where the source material for the site, i.e. the underlying Markdown and media files, might be located.
In addition to linking out to this repository, feedback about the repository hosting can be displayed, as in the number of ‘likes’ and all.
Social bar
Above the top bar, a ‘social’ bar may be placed that allows site visitors to reference the site on Twitter or whatnot. This element appears to have a close icon that allows visitors to temporarily get rid of it, reclaiming the vertical real estate.
Footer
At the bottom of each page, which on long pages may be initially out of view and require scrolling to be revealed, a footer bar can be displayed.
This advertises the tooling that was used to render the site, as in “Made with Material for MkDocs”.
A supplemental copyright notice can be made to appear via configuration.
It is also possible to have Previous and Next ‘buttons’ to be placed in the footer section, facilitating sequential traversal of the pages of the site.
Page overview
A MkDocs for Material site is comprised of pages. Key pages are enumerated in the left margin of the browser view. The label shown in the enumeration need not be the same as the page title that gets displayed when the page is selected.
The page enumeration can be made hierarchical, with ‘sub menus’ either expanding on demand or appearing expanding as standard.
The currently selected page, of which the content gets shown in the middle of the browser view, is highlighted with a different color.
Responsive design
Material for MkDocs aligns with responsive web design. When in the browser there is insufficient horizontal space, the page overview section collapses into a hamburger menu.
Wide browser view:
Narrow browser view, showing hamburger menu button:
Hamburger menu level 1:
Hamburger menu level 2:
Section overview
Each individual page may be divided into Markdown-standard sections, with section headers of various depths.
An index into the section collection of a page (which may become rather large) is shown in the right margin of the browser view, beneath a – by default – “Table of contents” label.
Here, the section labels are indented according to their depth.
When the page is scrolled, the ‘current’ section is highlighted similar to the page selection. In addition though, the names of sections that precede the current one are grayed out.
Plugins
The site presentation is customizable through plugins. One plugin used here, on the site describing the Uptick project, is glightbox. This causes images, such as the PiKVM screenshots above, to be clickable
The ‘zoomed-into’ view of such images can be closed with a click on the close icon in the top right of the expanded view, or by pressing the Escape key.
Another characteristic of glightbox is that expanded image may be dragged – to the left and right within the expanded view to move forward or back within the wider collection of images on the page, or up or down to close the expanded view.
Extensions
Also in play are ‘Markdown extensions’, which allow lower-level HTML-style control over display elements. For the top screenshot image above, the attr_list extension was enabled to allow the standard width of the image to be set to “70%”.




