Files
the_information_nexus/projects/MkDocs-website.md
2024-05-25 16:48:12 +00:00

3.1 KiB

Setting Up and Managing a Conda Environment for MkDocs

1. Creating a New Conda Environment

environment.yml

Create an environment.yml file with the following content:

name: mkdocs-env
channels:
  - conda-forge
dependencies:
  - python=3.11
  - pip
  - jupyter
  - matplotlib
  - nbconvert
  - pip:
    - mkdocs
    - mkdocs-material
    - mkdocs-mermaid2-plugin
    - mkdocs-jupyter
    - mkdocs-bibtex
    - mkdocs-exclude

requirements.txt

Create a requirements.txt file with the following content:

mkdocs
mkdocs-material
mkdocs-mermaid2-plugin
mkdocs-jupyter
mkdocs-bibtex
mkdocs-exclude

Steps to Create the Environment

  1. Create the Conda Environment:

    conda env create -f environment.yml
    
  2. Activate the Environment:

    conda activate mkdocs-env
    
  3. Install Additional pip Packages:

    pip install -r requirements.txt
    

2. Updating an Existing Conda Environment

If you already have an environment named mkdocs-env and want to update it with new dependencies:

Steps to Update the Environment

  1. Update the Conda Environment:

    conda env update -f environment.yml --prune
    
  2. Activate the Environment:

    conda activate mkdocs-env
    
  3. Install Additional pip Packages:

    pip install -r requirements.txt
    

The --prune flag ensures that any dependencies that are no longer needed are removed.

3. Removing an Existing Conda Environment

If you need to remove an existing environment before creating a new one:

Steps to Remove and Recreate the Environment

  1. Remove the Existing Environment:

    conda env remove -n mkdocs-env
    
  2. Create the Conda Environment:

    conda env create -f environment.yml
    
  3. Activate the Environment:

    conda activate mkdocs-env
    
  4. Install Additional pip Packages:

    pip install -r requirements.txt
    

4. Including MathJax in MkDocs

Since mkdocs-mathjax is not available on PyPI, include MathJax via CDN in your mkdocs.yml configuration file:

Example mkdocs.yml

site_name: My MkDocs Site
theme:
  name: material

extra_javascript:
  - https://cdnjs.cloudflare.com/ajax/libs/mathjax/3.2.0/es5/tex-mml-chtml.js

markdown_extensions:
  - extra
  - toc:
      permalink: true
  - pymdownx.superfences
  - pymdownx.inlinehilite
  - pymdownx.highlight
  - pymdownx.arithmatex

plugins:
  - search
  - mermaid2
  - mkdocs-jupyter
  - bibtex
  - exclude:
      glob:
        - "*.tmp"
        - "*.log"

Summary

  1. Create or Update Conda Environment:

    • conda env create -f environment.yml
    • conda env update -f environment.yml --prune
  2. Activate the Environment:

    • conda activate mkdocs-env
  3. Install pip Packages:

    • pip install -r requirements.txt
  4. Configure MathJax:

    • Add MathJax via CDN in mkdocs.yml.

Following these steps will ensure your MkDocs environment is properly set up and maintained. If you have any further questions or run into issues, feel free to ask!