# Maintenance & Operation Guide Your website is now live and working. Here's how to maintain and update it. ## Quick Start ### To Edit Content Edit the markdown files in `content/` directory: ```bash # Edit a page nano content/home/index.md nano content/projects/index.md # Add a blog post nano content/blog/my-new-post.md ``` ### To Regenerate (Update Site) After editing markdown, regenerate the JSON files: ```bash # Option 1: Run the shell script (easiest) ./rebuild.sh # Option 2: Run PHP directly php generate_json.php ``` That's it! Your site will update immediately. --- ## Three Operation Modes ### Mode 1: Manual Regeneration (Simplest) **When to use:** If you edit infrequently or prefer to control updates **Steps:** 1. Edit markdown file 2. Run `./rebuild.sh` 3. Refresh browser to see changes **Pros:** - Simple - Full control - No background processes **Cons:** - Must remember to run script - Requires manual step --- ### Mode 2: Automatic Watcher (Recommended) **When to use:** If you want automatic updates when files change **Start the watcher:** ```bash # Start watching (foreground) php watch.php # Start watching (background) nohup php watch.php > watch.log 2>&1 & # Start with screen (so it persists) screen -d -m php watch.php ``` **Stop the watcher:** ```bash # Find and stop pkill -f "php watch.php" ``` **How it works:** - Polls every 2 seconds for markdown changes - Automatically regenerates JSON when files change - Logs output to console/file - Displays timestamps for debugging **Pros:** - Automatic updates - No manual steps - Tracks all changes - Shows timestamps **Cons:** - Requires running background process - Uses minimal CPU/memory - Need to manage process --- ### Mode 3: Git Hook (For Version Control) **When to use:** If you're using git (recommended for production) **Setup:** ```bash # Initialize git if you haven't git init # Create post-commit hook cat > .git/hooks/post-commit << 'EOF' #!/bin/bash echo "Regenerating JSON files after commit..." php generate_json.php EOF chmod +x .git/hooks/post-commit ``` **How it works:** - Automatically runs after each `git commit` - Ensures JSON stays in sync with markdown - Only regenerates when you commit **Pros:** - Automatic for commits - Version controlled - Safe - only runs on commits - Can track changes in git **Cons:** - Requires git setup - Only runs on commits --- ## Workflow Examples ### Example 1: Quick Edit (Manual) ```bash # Edit a blog post nano content/blog/my-update.md # Regenerate ./rebuild.sh # Refresh browser # (Ctrl+F5 to hard refresh cache) ``` ### Example 2: Multiple Changes with Watcher ```bash # Start watcher in background nohup php watch.php > watch.log 2>&1 & # Edit multiple files nano content/home/index.md nano content/blog/post1.md nano content/blog/post2.md # Changes auto-regenerate as you save # Stop watcher when done pkill -f "php watch.php" ``` ### Example 3: Production with Git ```bash # Make changes nano content/blog/new-post.md # Commit changes (auto-regenerates via hook) git add content/blog/new-post.md git commit -m "Add new blog post" # JSON files automatically updated # Push to production git push ``` --- ## File Structure ``` /home/jisifu/public_html/ ├── index.php ← Main page (don't edit) ├── content/ ← EDIT THESE FILES │ ├── home/index.md │ ├── projects/index.md │ ├── blog/ │ │ ├── post1.md │ │ ├── post2.md │ │ └── fibonacci_tree.md │ ├── about/index.md │ ├── files/index.md │ ├── german/index.md │ └── pics/index.md ├── home/, blog/, etc. ← AUTO-GENERATED (don't edit) │ └── *.json files ├── generate_json.php ← Use for manual regeneration ├── watch.php ← Use for auto-watching └── rebuild.sh ← Use for quick rebuild ``` --- ## Adding New Content ### Add a New Blog Post ```bash # Create new markdown file nano content/blog/my-awesome-post.md # Add content (markdown format) # Example: # # My Awesome Post # # This is a paragraph. # # - List item 1 # - List item 2 # Regenerate ./rebuild.sh # It will appear automatically in /blog ``` ### Add a New Page Section ```bash # Create new directory mkdir content/mynewsection # Create index.md nano content/mynewsection/index.md # Add content # Example: # # My New Section # Content here... # Regenerate ./rebuild.sh # Will appear in sidebar and be accessible at /mynewsection ``` --- ## Markdown Format Tips ### Basic Markdown ```markdown # Heading 1 ## Heading 2 ### Heading 3 **Bold text** *Italic text* ***Bold and italic*** - Bullet point - Another point - Nested point 1. Numbered item 2. Another item [Link text](https://example.com) ![Alt text](/path/to/image.jpg) > Blockquote `code snippet` \`\`\` code block \`\`\` ``` ### HTML Support You can also use raw HTML (it won't be escaped): ```html

HTML content

``` --- ## Troubleshooting ### Changes Not Showing 1. **Regenerate manually:** ```bash ./rebuild.sh ``` 2. **Clear browser cache:** - Ctrl+F5 (Windows/Linux) - Cmd+Shift+R (Mac) 3. **Check file permissions:** ```bash ls -la content/ chmod 755 content/ ``` ### Watcher Not Working 1. **Check if it's running:** ```bash ps aux | grep "php watch" ``` 2. **Check for errors:** ```bash tail watch.log ``` 3. **Restart it:** ```bash pkill -f "php watch.php" nohup php watch.php > watch.log 2>&1 & ``` ### JSON Generation Error 1. **Check markdown syntax:** ```bash php -l content/file.md ``` 2. **Run manually with output:** ```bash php generate_json.php ``` 3. **Check permissions:** ```bash ls -la */index.json chmod 644 */index.json ``` --- ## Performance Notes - **Watcher uses:** ~2-5MB memory, negligible CPU - **Regeneration takes:** ~100-500ms depending on content size - **Browser caching:** JSON files are cached, hard refresh needed to see changes --- ## Recommended Setup For a personal site like yours, I recommend: **Option 1: Simple (No watcher)** - Edit files manually - Run `./rebuild.sh` when done - Simple, no background processes **Option 2: Developer-friendly (Watcher)** - Start `php watch.php` in a tmux/screen session - Edits auto-update as you save - Perfect for active development **Option 3: Production (Git + Hook)** - Use git to manage content - Post-commit hook regenerates automatically - Safe, version controlled, trackable --- ## Summary **To maintain your site:** 1. Edit markdown files in `content/` 2. Run `./rebuild.sh` (or let watcher auto-regenerate) 3. Refresh browser to see changes **That's it!** No database, no complex setup, just simple markdown files. --- ## Useful Commands ```bash # View current watchers ps aux | grep php # Stop all watchers pkill -f "php watch" # Regenerate everything ./rebuild.sh # View logs (if using watcher) tail -f watch.log # List all markdown files find content -name "*.md" # Check markdown validity php -l content/home/index.md # Monitor file changes watch ls -la content/*/ ``` --- **Your site is ready!** Choose your operation mode above and start editing.