#!/bin/bash # Reset MkDocs site to baseline while preserving custom code # Usage: ./reset-site.sh set -e # Exit on error SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" MKDOCS_DIR="$SCRIPT_DIR/mkdocs" DOCS_DIR="$MKDOCS_DIR/docs" TEMP_DIR="/tmp/mkdocs-reset-$$" echo "๐ Resetting MkDocs site to baseline..." # Create temp directory for backups mkdir -p "$TEMP_DIR" # Backup custom directories if they exist echo "๐ฆ Backing up custom directories..." for dir in hooks assets javascripts overrides stylesheets blog; do if [ -d "$DOCS_DIR/$dir" ]; then echo " - Backing up $dir/" cp -r "$DOCS_DIR/$dir" "$TEMP_DIR/" fi done # Backup mkdocs.yml cp "$MKDOCS_DIR/mkdocs.yml" "$TEMP_DIR/mkdocs.yml.bak" # Clear docs directory echo "๐งน Clearing docs directory..." rm -rf "$DOCS_DIR"/* rm -rf "$DOCS_DIR"/.* 2>/dev/null || true # Create baseline MkDocs Material structure echo "๐ Creating baseline content structure..." mkdir -p "$DOCS_DIR" # Create index.md cat > "$DOCS_DIR/index.md" << 'EOF' # Welcome to Your MkDocs Site This site has been reset to baseline configuration. ## Getting Started - Edit `docs/index.md` to change this page - Add new pages in the `docs/` directory - Configure navigation in `mkdocs.yml` - Customize the theme in `docs/overrides/` ## Features Preserved Your custom code has been preserved in: - `hooks/` - Custom build hooks - `assets/` - Images and static files - `javascripts/` - Custom JavaScript - `overrides/` - Theme overrides - `stylesheets/` - Custom CSS - `blog/` - Blog content ## Next Steps 1. Start adding your content 2. Configure the navigation 3. Customize the appearance 4. Deploy your site --- *Built with MkDocs Material* EOF # Create a simple getting-started.md cat > "$DOCS_DIR/getting-started.md" << 'EOF' # Getting Started Welcome to your fresh MkDocs Material site! ## Adding Content Create new markdown files in the `docs/` directory: ```bash docs/ โโโ index.md # Homepage โโโ getting-started.md # This page โโโ page1.md # Your content โโโ page2.md # More content ``` ## Configuring Navigation Edit `mkdocs.yml` to add navigation: ```yaml nav: - Home: index.md - Getting Started: getting-started.md - Your Section: - Page 1: page1.md - Page 2: page2.md ``` ## Using the Blog The blog plugin is already configured. Add posts in `docs/blog/posts/`: ```markdown --- date: 2024-01-01 categories: - News --- # Your Blog Post Title Post content here... ``` ## Customization - Theme overrides: `docs/overrides/` - Custom CSS: `docs/stylesheets/` - Custom JS: `docs/javascripts/` EOF # Restore custom directories echo "โป๏ธ Restoring custom directories..." for dir in hooks assets javascripts overrides stylesheets blog; do if [ -d "$TEMP_DIR/$dir" ]; then echo " - Restoring $dir/" cp -r "$TEMP_DIR/$dir" "$DOCS_DIR/" else # Create empty directories if they didn't exist mkdir -p "$DOCS_DIR/$dir" fi done # Create simplified home.html echo "๐ Creating simplified home template..." cat > "$DOCS_DIR/overrides/home.html" << 'EOF' {% extends "main.html" %} {% block extrahead %} {{ super() }} {% endblock %} {% block content %}
Your MkDocs Material site is ready for customization.
Create pages with Markdown
Make it your own
Share with the world