# Customization ## A great starting point Project documentation is as diverse as the projects themselves and the Material theme is a good starting point for making it look great. However, as you write your documentation, you may reach some point where some small adjustments are necessary to preserve the style. ## Adding assets [MkDocs][1] provides several ways to interfere with themes. In order to make a few tweaks to an existing theme, you can just add your stylesheets and JavaScript files to the `docs` directory. [1]: http://www.mkdocs.org ### Additional stylesheets If you want to tweak some colors or change the spacing of certain elements, you can do this in a separate stylesheet. The easiest way is by creating a new stylesheet file in your `docs` directory: ``` sh mkdir docs/stylesheets touch docs/stylesheets/extra.css ``` Then, add the following line to your `mkdocs.yml`: ``` yaml extra_css: - 'stylesheets/extra.css' ``` Spin up the development server with `mkdocs serve` and start typing your changes in your additional stylesheet file – you can see them instantly after saving, as the MkDocs development server implements live reloading. Cool, huh? ### Additional JavaScript The same is true for additional JavaScript. If you want to integrate another syntax highlighter or add some custom logic to your theme, create a new JavaScript file in your `docs` directory: ``` sh mkdir docs/javascripts touch docs/javascripts/extra.js ``` Then, add the following line to your `mkdocs.yml`: ``` yaml extra_javascript: - 'javascripts/extra.js' ``` Further assistance can be found in the [MkDocs documentation][2]. [2]: http://www.mkdocs.org/user-guide/styling-your-docs/#customizing-a-theme ## Extending the theme If you want to alter the HTML source (e.g. add or remove some part), you can extend the theme. From version 0.16 on MkDocs implements [theme extension][3], an easy way to override parts of a theme without forking and changing the main theme. [3]: http://www.mkdocs.org/user-guide/styling-your-docs/#using-the-theme_dir ### Setup and theme structure Reference the Material theme as usual in your `mkdocs.yml`, and create a new folder for overrides, e.g. `theme`, which you reference using `theme_dir`: ``` yaml theme: 'material' theme_dir: 'theme' ``` !!! warning "Theme extension prerequisites" As the `theme_dir` variable is used for the theme extension process, the Material theme needs to be installed via `pip` and referenced with the `theme` parameter in your `mkdocs.yml`. The structure in the theme directory must mirror the directory structure of the original theme, as any file in the theme directory will replace the file with the same name which is part of the original theme. Besides, further assets may also be put in the theme directory. The directory layout of the Material theme is as follows: ``` sh . ├─ assets/ │ ├─ images/ # Images and icons │ ├─ javascripts/ # JavaScript │ └─ stylesheets/ # Stylesheets ├─ partials/ │ ├─ fonts.html # Webfont definitions │ ├─ footer.html # Footer bar │ ├─ header.html # Header bar │ ├─ i18n.html # Localized labels │ ├─ nav-item.html # Main navigation item │ ├─ nav.html # Main navigation │ ├─ search.html # Search box │ ├─ social.html # Social links │ ├─ source.html # Repository information │ ├─ svgs.html # Inline SVG definitions │ ├─ toc-item.html # Table of contents item │ └─ toc.html # Table of contents ├─ 404.html # 404 error page ├─ base.html # Base template └─ main.html # Default page ``` ### Overriding partials In order to override the footer, we can replace the `footer.html` partial with our own partial. To do this, create the file `partials/footer.html` in the theme directory. MkDocs will now use the new partial when rendering the theme. This can be done with any file. ### Overriding template blocks Besides overriding partials, one can also override so called template blocks, which are defined inside the Material theme and wrap specific features. To override a template block, create a `main.html` inside the theme directory and define the block, e.g.: ``` jinja {% extends "base.html" %} {% block htmltitle %}