Cinder + Superhero for MkDocs

About

Cinder is a clean, responsive theme for static documentation sites that are generated with MkDocs. It's built on the Bootstrap 3 framework and includes pre-packaged:

highlight.js v9.13.1 syntax highlighting with support for over 25 programming languages
FontAwesome v5.13 icon support
smashingly legible type scheme to get your message out to your users

You are viewing the theme in action and can see a selection of the theme elements on the Specimen page.

Install

Required: Python 2.7 or 3.4+

Install MkDocs & Create a New Project

If you haven't installed MkDocs yet, use the following command to install it:

$ pip install mkdocs

Next, navigate to a clean directory and create a new MkDocs project with the following command:

$ mkdocs new [projectname]

Replace [projectname] with the name of your project (without the brackets).

Then navigate to the root of your project directory:

$ cd [projectname]

Install the Cinder Theme

Choose one of the following install approaches:

If you are using MkDocs v0.15.0 or higher, you can install the Cinder theme with the Python package manager pip using the command:

$ pip install mkdocs-cinder

MkDocs projects use a YAML settings file called mkdocs.yml. This is located in the root of your project directory after you use the mkdocs new command. Open the file in a text editor and modify it to define Cinder in the theme setting as follows (note that this is case-sensitive):

site_name: [YOURPROJECT]

theme:
    name: null
    custom_dir: 'cinder-superhero'

nav:
- Home: index.md

Updates with pip

Update your pip-installed Cinder theme to new releases with the command:

$ pip install --upgrade mkdocs-cinder

Then rebuild the static files (see documentation below)

2. Manual Install

Download the Cinder theme archive by clicking the button below.

Unpack the contents of the archive into a directory named cinder at the top level of your MkDocs project directory.

Your project directory should now look like this:

.
├── mkdocs.yml
├── cinder
│     ├── css
│     ├── img
│     ├── js
│     ├── base.html
│     ├── content.html
│     ├── 404.html
│     ├── nav-sub.html
│     ├── nav.html
│     └── toc.html
└── docs
      └── index.md

MkDocs projects use a YAML settings file called mkdocs.yml. This is located in the root of your project directory after you use the mkdocs new command. Open the file in a text editor and modify it to include the theme settings as follows:

site_name: [YOURPROJECT]

theme:
    name: null
    custom_dir: 'cinder-superhero'

nav:
  - Home: index.md

See the MkDocs documentation for additional details.

Updates, the Manual Approach

If you choose the manual install approach, you can update your Cinder theme by downloading the new cinder.zip release archive and including it in your project. Then re-build your static site files (see instructions below).

Test with a Local Site Server

Use the following command to establish a local server for your site:

$ mkdocs serve

Then open your site in any browser at the URL http://localhost:8000.

Create Your Site

Add Content with Markdown Syntax

Get to work on your site home page by opening the docs/index.md file and editing it in Markdown syntax. The HTML automatically updates in the browser when you save the Markdown file if you use the MkDocs server (see command above).

Add New Pages

Add new pages to your site by creating a new Markdown file in your docs directory, then linking to the new page in the mkdocs.yml file. This uses a Page Name : Markdown file syntax.

For example, to add an About page using a Markdown file that is located on the path docs/about.md, you would format the mkdocs.yml file as follows:

site_name: [YOURPROJECT]

theme:
  name: null
  custom_dir: 'cinder'

nav:
  - Home: index.md
  - About: about.md

Add additional pages to your site by repeating the above series of steps.

Build Your Site

Build your site files with the command:

$ mkdocs build

Your site files are built in the site directory and are ready to use. Deploy the contents of the site directory to your web server.

Site Customization

The following are a few common customizations that you might be interested in. For much more detail about the configuration of your site, check out the MkDocs Configuration documentation.

Site Favicon

Place your site favicon image file in the top level of your docs directory and then include a new site_favicon: field in the mkdocs.yml file:

site_name: [YOURPROJECT]

theme:
  name: null
  custom_dir: 'cinder'

site_favicon: favicon.ico
nav:
  - Home: index.md
  - About: about.md

Add Your Own CSS Stylesheets

Create a css directory inside your docs directory and add your CSS files. You can overwrite any of the Cinder styles in your CSS files. Then include your CSS files in the mkdocs.yml file with the extra_css field:

site_name: [YOURPROJECT]

theme:
  name: null
  custom_dir: 'cinder'

extra_css:
  - "css/mystyle.css"
  - "css/myotherstyle.css"
nav:
  - Home: index.md
  - About: about.md

Your CSS styles fall at the end of the cascade and will override all styles included in the theme (including Bootstrap and default Cinder styles). You can find the Cinder and Bootstrap CSS files on the paths cinder/css/cinder.css and cinder/css/bootstrap.min.css, respectively.

Add Your Own JavaScript

Create a js directory inside your docs directory and add your JS files. Then include your JS files in the mkdocs.yml file with the extra_js field:

site_name: [YOURPROJECT]

theme:
  name: null
  custom_dir: 'cinder'

extra_js:
  - "js/myscript.js"
  - "js/myotherscript.js"
nav:
  - Home: index.md
  - About: about.md

Keyboard shortcuts

In your mkdocs.yml file, place the following to enable keyboard shortcuts.

shortcuts:
    help: 191    # ?
    next: 39     # right arrow
    previous: 37 # left arrow
    search: 83   # s

The numbers correspond to the key that you would like to use for that shortcut. You can use https://keycode.info/ to find the keycode you want.

Extending Cinder

Create a new directory within your project (e.g., cinder-theme-ext/) and create main.html. Add the following line at the top of the HTML file.

{% extends "base.html" %}

Instead of using theme: cinder or theme_dir: cinder in mkdocs.yml, use:



theme:
    name: cinder
    custom_dir: [custom dir]

Refer to MkDocs Documentation - Using the theme custom_dir for more information.

Use the following examples as reference. You can put your own Jinja2 within the blocks. More information can be found in MkDocs Documentation - Overriding Template Blocks.

Adding extra HTML to the head tag

Append to main.html:

{% block extrahead %}
      <meta name="author" content="{{ page.meta.author }}">
{% endblock %}

Append to main.html:

{% block footer %}
<hr>
<p>{% if config.copyright %}
      <small>{{ config.copyright }}<br></small>
{% endif %}
<small>Documentation built with <a href="http://www.mkdocs.org/">MkDocs</a>.</small>
{% if page.meta.revision_date %}
      <small><br><i>Updated {{ page.meta.revision_date }}</i></small>
{% endif %}
</p>
{% endblock %}

page.meta.revision_date can be set by using meta-data (front-matter) at the beginning of your Markdown document or using mkdocs-git-revision-date-plugin.

Include the repo_url field and define it with your repository URL:

site_name: [YOURPROJECT]

theme:
  name: null
  custom_dir: 'cinder'

repo_url: "https://github.com/chrissimpkins/cinder"
nav:
  - Home: index.md
  - About: about.md

The link appears at the upper right hand corner of your site.

The Cinder theme displays your license declaration in the footer if you include a copyright field and define it with the text (and optionally the HTML link) that you would like to display:

site_name: [YOURPROJECT]

theme:
  name: null
  custom_dir: 'cinder'

copyright: "Cinder is licensed under the <a href='https://github.com/chrissimpkins/cinder/blob/master/LICENSE.md'>MIT license"
nav:
  - Home: index.md
  - About: about.md

Issues

If you have any issues with the theme, please report them on the Cinder repository:

License

Cinder is licensed under the MIT license.