Skip to main content

Deploying MkDocs Documentation to Netlify

Steps

  1. Test the MkDocs documentation locally
  2. Push the code to GitHub
  3. Add a Netlify configuration file to the repository
  4. Create a project on Netlify
  5. Select GitHub as the source

Test the MkDocs Documentation Locally

Test the MkDocs documentation locally.

$ mkdocs serve
...
INFO - [17:43:43] Serving on http://127.0.0.1:8000/

Verify that everything displays correctly.

Push the Code to GitHub

The minimum file structure is as follows. In the next step, we will add the Netlify configuration file.

$ tree -L 1
.
├── docs
└── mkdocs.yml

Add a Netlify Configuration File to the Repository

Add netlify.toml to the root of the repository.

[build]
publish = "site"
command = "mkdocs build -d site"

Create a Project on Netlify

Create a project on Netlify.

  • Click Add new site
  • Select Import an existing repository
  • Select GitHub
  • Select your repository

netlify

This completes the deployment.