Skip to content
BoKSA

Preview your site locally

Preview your site locally

You can run the website on your own laptop and see every change the moment you save a file. That is much faster than pushing and waiting for the pipeline, and it keeps mistakes away from the website you share with your team.

There are two ways to do it. Pick one.

Option 1: with Docker

You need Docker Desktop installed and running. Open a terminal in the root of your repository.

Build the image once:

1
docker compose build mkdocs

Start the preview:

1
docker compose up mkdocs

Open http://localhost:8000. The page reloads by itself when you save a file in docs/ or change mkdocs.yml. Stop the preview with Ctrl+C.

Option 2: with Python and uv

If you already use uv (see Setup Python Virtual Environment), you do not need Docker. In the root of your repository:

1
2
uv venv
uv pip install -r requirements.txt

Activate the environment (.venv\Scripts\activate on Windows, source .venv/bin/activate on macOS) and start the preview:

1
mkdocs serve

Open http://localhost:8000.

Do not commit .venv

The .venv folder is large and only works on your own laptop. Add a line with .venv/ to the .gitignore file in your repository so it is never committed.

Preview the slides

The slides are built by a separate tool. With Docker:

1
docker compose run --rm marp

This writes the slide deck to public/slides/index.html. Open that file in your browser. Run the command again after every change. The public/ folder is ignored by Git, so it is never committed.

See The slide deck for a way to get a live preview while you write.

Read the terminal

While the preview runs, MkDocs prints a line for everything it notices. Lines that start with WARNING are worth reading: they point to links to pages that do not exist, missing images and mistakes in mkdocs.yml. Fix them before you push.

The preview is not the published website

Locally your website lives at the root of localhost:8000. The published website may live in a subfolder of a longer address. Links that start with a / can therefore work locally and break online. Always write relative links, as described in Writing documentation.