Skip to content

1. Local MkDocs Setup in Python Virtual Environment

1.1. Environment

  • OS: Linux Mint 22.2 Cinnamon
  • Python Version: Python 3.12.3
  • Virtual Environment: .venv
  • MkDocs Version: 1.6.1
  • MkDocs Material Version: 9.7.1

1.2. Purpose

Opsætte MkDocs lokalt i et Python virtual environment til brug med GitLab Pages.


1.3. Prerequisites

  • Python installeret
  • Projekt med pages/ mappe
  • Virtual environment oprettet (.venv)

1.4. Procedure

1.4.1. Activate virtual environment

source .venv/bin/activate

1.4.2. Install MkDocs

pip install mkdocs

1.4.3. Install MkDocs Material

pip install mkdocs-material

1.4.4. Run MkDocs locally

cd pages
mkdocs serve
mkdocs build

1.4.5. Generate requirements.txt

pip freeze > requirements.txt

1.4.6. Update .gitignore

Tilføj:

env/
.venv/
site/

1.4.7. Run with live reload

mkdocs serve --livereload

1.4.8. Create GitLab pipeline file

Opret:

.gitlab-ci.yml

1.6. References

  • https://www.mkdocs.org/

1.7. Notes / Learnings

  • pip freeze gemmer dependencies fra .venv
  • requirements.txt bruges til at reproducere miljøet