MKDocs

Tips and tricks for MKDocs, a static site generator.

MKDocs is a static-site generator that converts Markdown source files into fully formed websites.

Check version

Use --version to display the current MkDocs version:

$ mkdocs --version

Early versions of MkDocs include a small “ad” in the footer of your webpages (“Documentation built wwith MKDocs”).

You can hide this by adding a CSS rule to hide the message or by removing it from your site’s template.

Hide with CSS

To hide the ad using CSS:

  1. In your project’s /docs/ folder, add the following rule to a custom style sheet:

    footer :last-child { display: none; }
    
  2. Verify that your custom style sheet is declared in your site’s project configuration (mydocs.yml)

    site_name: My example site
    exta_css:
       - hidefooter.css
    

    Here, we assume your custom CSS file is named hidefooter.css.

If you’re working with an earlier version of MKDocs, you may need to tweak the CSS rule. In version v0.15.x, for example, MKDocs placed its ad in a <center> element (now deprecated).

To hide the footer in this version:

center { display: none; }

Update template

You can also update the template to remove the ad entirely:

  1. Install a copy of the basic theme into a your project.

  2. Update mkdocs.yml to refer to your new theme:

    theme_dir: <custom-template>
    
  3. Update base.html to remove the “Built with” line (line 189 as of this writing).

  4. Save, build, and deploy as usual.

Customize templates

MKDocs uses Jinja2 as its templating engine. To learn more, see:

Vital statistics

  • 8 May 2024: Rewritten and updated for site revamp
  • 15 March 2017: First post