Skip to content

MkDocs Deployment Guide

This guide covers deploying the AzharStore documentation using MkDocs.

Local Development

Installation

  1. Install Python 3.8 or later

  2. Install dependencies:

    cd docs
    pip install -r requirements.txt
    

Serve Locally

cd docs
mkdocs serve

Access at: http://localhost:8000

Build Static Site

cd docs
mkdocs build

Output will be in docs/site/

Deployment Options

Option 1: GitHub Pages

  1. Install mkdocs-gh-deploy:

    pip install mkdocs-gh-deploy
    

  2. Deploy to GitHub Pages:

    cd docs
    mkdocs gh-deploy
    

Option 2: Docker Deployment

Add a docs service to docker-compose.yml:

  docs:
    image: squidfunk/mkdocs-material:latest
    container_name: azharstore-docs
    volumes:
      - ./docs:/docs
    ports:
      - "8000:8000"
    command: mkdocs serve -a 0.0.0.0:8000
    restart: unless-stopped
    networks:
      - azharstore-network

Start the docs service:

docker compose up -d docs

Access at: http://localhost:8000

Option 3: Static Hosting (Netlify, Vercel, etc.)

  1. Build the site:

    cd docs
    mkdocs build
    

  2. Deploy the site/ directory to your hosting provider

Option 4: Cloudflare Pages

Cloudflare Pages can automatically build and deploy MkDocs sites from Git.

Via Git Integration

  1. Push your code to GitHub/GitLab

  2. In Cloudflare Dashboard:

  3. Go to Pages > Create a project
  4. Connect to your Git provider
  5. Select your repository
  6. Configure build settings:

    • Build command: cd docs && pip install -r requirements.txt && mkdocs build
    • Build output directory: docs/site
    • Root directory: / (repository root)
  7. Click Save and Deploy

Via Direct Upload

  1. Build the site locally:

    cd docs
    pip install -r requirements.txt
    mkdocs build
    

  2. In Cloudflare Dashboard:

  3. Go to Pages > Create a project
  4. Select "Upload assets"
  5. Upload the contents of docs/site/
  6. Click Deploy site

Environment Variables

If your documentation needs environment variables, add them in Cloudflare Pages settings: - Go to your Pages project > Settings > Environment variables - Add any required variables

Custom Domain

  1. In Cloudflare Pages project:
  2. Go to Custom domains
  3. Add your domain (e.g., docs.azhar.store)
  4. Follow DNS instructions

Option 5: Nginx Deployment

  1. Build the site:

    cd docs
    mkdocs build
    

  2. Serve with Nginx:

    server {
        listen 80;
        server_name docs.azhar.store;
    
        root /path/to/docs/site;
        index index.html;
    
        location / {
            try_files $uri $uri/ /index.html;
        }
    }
    

Configuration

The MkDocs configuration is in mkdocs.yml:

  • Theme: Material
  • Plugins: Search, Git revision dates
  • Extensions: Code highlighting, Mermaid diagrams, Admonitions

Customization

Theme

Edit the theme section in mkdocs.yml to customize colors, fonts, and features.

Edit the nav section in mkdocs.yml to add or remove pages.

Plugins

Add plugins to the plugins section in mkdocs.yml.

CI/CD

GitHub Actions

Create .github/workflows/docs.yml:

name: Deploy Documentation

on:
  push:
    branches: [main]
    paths: [docs/**, mkdocs.yml]

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - uses: actions/setup-python@v4
        with:
          python-version: '3.x'
      - run: pip install mkdocs-material mkdocs-git-revision-date-localized-plugin
      - run: mkdocs gh-deploy --force

Troubleshooting

Build Errors

If you encounter build errors:

  1. Check Python version (>= 3.8)
  2. Reinstall dependencies: pip install -r requirements.txt --upgrade
  3. Check for syntax errors in markdown files

Missing Pages

If pages don't appear in navigation:

  1. Check the nav section in mkdocs.yml
  2. Verify file paths are correct
  3. Ensure files are in the docs/ directory

Plugin Errors

If plugins fail to load:

  1. Install missing plugins: pip install <plugin-name>
  2. Check plugin configuration in mkdocs.yml
  3. Verify plugin compatibility with MkDocs version

Resources