Welcome to My Docs

A modern static site built with MkDocs and custom React theme

Key Features

Modern technology stack for optimal performance

Lightning Fast

Built with modern static site generation for optimal performance and SEO.

Responsive Design

Fully responsive design that works perfectly on all devices and screen sizes.

Modern Stack

Built with React, Tailwind CSS, and MkDocs for a modern development experience.

Development

Development Guide

This guide covers the development process, build system, and deployment pipeline for the MkDocs React theme.

๐Ÿ› ๏ธ Development Setup

Prerequisites

Before starting development, ensure you have the following installed:

  • Python 3.11+: Required for MkDocs
  • Node.js 18+: Required for frontend build tools
  • Git: Version control
  • Code Editor: VS Code, WebStorm, or similar

Environment Setup

  1. Clone the repository:

    git clone https://github.com/asap-programmer/static-site-python.git
    cd static-site-python
    

  2. Create a virtual environment:

    python -m venv venv
    source venv/bin/activate  # On Windows: venv\Scripts\activate
    

  3. Install Python dependencies:

    pip install -r requirements.txt
    

  4. Install Node.js dependencies:

    npm install
    

๐Ÿ—๏ธ Build System

MkDocs Configuration

The site is configured through mkdocs.yml:

site_name: My Docs
site_url: https://asap-programmer.github.io/static-site-pages
site_description: A modern static site built with MkDocs and custom React theme
site_author: Ilvir Nizaev

theme:
  name: null
  custom_dir: custom_theme
  static_templates:
    - 404.html

plugins:
  - search
  - minify:
      minify_html: true
      minify_js: true
      minify_css: true

markdown_extensions:
  - toc:
      permalink: true
  - codehilite:
      guess_lang: true
  - pymdownx.superfences
  - pymdownx.tabbed:
      alternate_style: true

PostCSS Configuration

CSS processing is handled by PostCSS with the following configuration:

module.exports = {
  plugins: [
    require('autoprefixer'),
    require('cssnano')({
      preset: 'default',
    }),
  ],
};

Build Commands

Command Description
mkdocs serve Start development server
mkdocs build Build static site
npm run build:css Process CSS with PostCSS
npm run watch:css Watch CSS files for changes

๐ŸŽจ Theme Development

Theme Structure

custom_theme/
โ”œโ”€โ”€ base.html              # Base template
โ”œโ”€โ”€ main.html              # Main page template
โ”œโ”€โ”€ 404.html               # Error page template
โ””โ”€โ”€ assets/
    โ”œโ”€โ”€ css/
    โ”‚   โ”œโ”€โ”€ custom.css     # Custom styles
    โ”‚   โ””โ”€โ”€ custom.min.css # Minified styles
    โ””โ”€โ”€ js/
        โ””โ”€โ”€ custom.js      # Custom JavaScript

Template Development

Base Template (base.html)

The base template provides the overall page structure:

<!DOCTYPE html>
<html lang="{{ lang or 'en' }}">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>{% if page.title %}{{ page.title }} - {% endif %}{{ config.site_name }}</title>
    <!-- Additional head content -->
</head>
<body>
    <!-- Header -->
    <header>...</header>

    <!-- Main content -->
    <main>
        {% block content %}{% endblock %}
    </main>

    <!-- Footer -->
    <footer>...</footer>

    <!-- Scripts -->
    <script src="{{ 'assets/js/custom.js'|url }}"></script>
</body>
</html>

Main Page Template (main.html)

The main page template extends the base template with additional features:

{% extends "base.html" %}

{% block extrahead %}
<style>
    .hero-gradient {
        background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    }
</style>
{% endblock %}

{% block content %}
<!-- Hero Section -->
<section class="hero-gradient text-white py-20 mb-16">
    <!-- Hero content -->
</section>

<!-- Features Section -->
<section id="dev-features" class="py-16">
    <!-- Features content -->
</section>

<!-- Content Section -->
<section class="py-16 bg-gray-50">
    <div class="bg-white rounded-lg shadow-sm p-8">
        {{ super() }}
    </div>
</section>
{% endblock %}

CSS Development

Custom CSS (custom.css)

The custom CSS file includes:

  • Typography improvements: Enhanced readability
  • Component styles: Custom component styling
  • Animations: Smooth transitions and effects
  • Responsive design: Mobile-first approach
  • Print styles: Optimized printing

PostCSS Processing

CSS is processed through PostCSS with:

  • Autoprefixer: Automatic vendor prefixes
  • CSSnano: CSS minification
  • Custom plugins: Additional processing

JavaScript Development

React Components

The theme includes several React components:

// Theme Toggle Component
function ThemeToggle() {
    const [isDark, setIsDark] = useState(false);

    const toggleTheme = () => {
        setIsDark(!isDark);
        if (!isDark) {
            document.documentElement.classList.add('dark');
            localStorage.setItem('theme', 'dark');
        } else {
            document.documentElement.classList.remove('dark');
            localStorage.setItem('theme', 'light');
        }
    };

    return React.createElement('button', {
        onClick: toggleTheme,
        className: 'p-2 rounded-lg bg-gray-200 hover:bg-gray-300 transition-colors',
        'aria-label': 'Toggle theme'
    }, isDark ? 'โ˜€๏ธ' : '๐ŸŒ™');
}

Interactive Features

  • Mobile menu: Responsive navigation
  • Search functionality: Real-time search
  • Smooth scrolling: Enhanced navigation
  • Code copying: One-click code copying
  • Back to top: Smooth scroll to top

๐Ÿ”„ Development Workflow

Local Development

  1. Start the development server:

    mkdocs serve
    

  2. Open your browser to http://localhost:8000

  3. Make changes to templates, CSS, or JavaScript

  4. Refresh the browser to see changes

CSS Development

  1. Edit CSS files in custom_theme/assets/css/

  2. Process with PostCSS:

    npm run build:css
    

  3. Watch for changes:

    npm run watch:css
    

Testing

  1. Build the site:

    mkdocs build
    

  2. Validate HTML:

    html5validator --root site
    

  3. Test responsiveness using browser dev tools

๐Ÿš€ Deployment Pipeline

GitHub Actions Workflow

The deployment pipeline includes:

  1. Testing Phase:
  2. HTML validation
  3. Dependency installation
  4. Build verification

  5. Build Phase:

  6. CSS processing with PostCSS
  7. Static site generation
  8. Asset minification

  9. Deployment Phase:

  10. GitHub Pages deployment
  11. CDN integration
  12. Cache configuration

Workflow Configuration

name: Build and Deploy MkDocs Site

on:
  push:
    branches:
      - main
  pull_request:
    branches:
      - main

jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout source repo
        uses: actions/checkout@v3

      - name: Set up Python
        uses: actions/setup-python@v4
        with:
          python-version: '3.11'

      - name: Install dependencies
        run: |
          python -m pip install --upgrade pip
          pip install -r requirements.txt

      - name: Validate HTML
        run: |
          mkdocs build
          pip install html5validator
          html5validator --root site --format text

  build-deploy:
    needs: test
    runs-on: ubuntu-latest
    if: github.ref == 'refs/heads/main'

    steps:
      # ... build and deployment steps

๐Ÿงช Testing

Automated Testing

  • HTML Validation: W3C HTML validation
  • CSS Validation: CSS linting and validation
  • JavaScript Testing: ESLint and functionality tests
  • Performance Testing: Lighthouse CI integration

Manual Testing

  • Cross-browser Testing: Chrome, Firefox, Safari, Edge
  • Device Testing: Mobile, tablet, desktop
  • Accessibility Testing: Screen reader and keyboard navigation

Testing Commands

# HTML validation
html5validator --root site

# CSS validation
npm run lint:css

# JavaScript testing
npm run test:js

# Performance testing
npm run lighthouse

๐Ÿ“ฆ Dependencies

Python Dependencies

mkdocs>=1.5.0
mkdocs-material>=9.0.0
mkdocs-minify-plugin>=0.7.0
pymdown-extensions>=10.0.0

Node.js Dependencies

{
  "devDependencies": {
    "autoprefixer": "^10.4.16",
    "cssnano": "^6.0.1",
    "html-minifier-terser": "^7.2.0",
    "postcss": "^8.4.32",
    "postcss-cli": "^11.0.0"
  }
}

๐Ÿ”ง Configuration

Environment Variables

  • PERSONAL_TOKEN: GitHub personal access token for deployment
  • NODE_ENV: Node.js environment (development/production)

Build Configuration

  • Python Version: 3.11+
  • Node.js Version: 18+
  • MkDocs Version: 1.5.0+
  • React Version: 18.0+

๐Ÿ› Debugging

Common Issues

  1. Build Failures:
  2. Check Python and Node.js versions
  3. Verify all dependencies are installed
  4. Check for syntax errors in templates

  5. CSS Issues:

  6. Verify PostCSS configuration
  7. Check for CSS syntax errors
  8. Ensure Tailwind CSS is loaded

  9. JavaScript Issues:

  10. Check browser console for errors
  11. Verify React is loaded correctly
  12. Check for JavaScript syntax errors

Debug Commands

# Debug MkDocs build
mkdocs build --verbose

# Debug CSS processing
npx postcss custom_theme/assets/css/custom.css --verbose

# Debug JavaScript
node -c custom_theme/assets/js/custom.js

๐Ÿ“š Resources

Documentation

Tools

๐Ÿค Contributing

Development Guidelines

  1. Code Style: Follow existing code patterns
  2. Testing: Add tests for new features
  3. Documentation: Update documentation for changes
  4. Performance: Ensure changes don't impact performance

Pull Request Process

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests if applicable
  5. Update documentation
  6. Submit a pull request

๐Ÿ“ž Support

If you encounter issues during development:

  1. Check the Issues page
  2. Create a new issue with detailed information
  3. Contact the maintainer via GitHub

Happy coding! ๐Ÿš€