#!/bin/bash # Update image references in HTML files echo "Updating image references in HTML files..." # First, find all HTML files find . -name "*.html" | while read file; do # Skip files in node_modules if they exist if [[ "$file" == *"node_modules"* ]]; then continue fi # For each jpg/jpeg/png reference, update to webp sed -i '' 's/\.jpg"/\.webp"/g' "$file" sed -i '' "s/\.jpg'/\.webp'/g" "$file" sed -i '' 's/\.jpeg"/\.webp"/g' "$file" sed -i '' "s/\.jpeg'/\.webp'/g" "$file" sed -i '' 's/\.png"/\.webp"/g' "$file" sed -i '' "s/\.png'/\.webp'/g" "$file" echo "Updated: $file" done # Update image references in content files (Markdown, etc.) echo "Updating image references in content files..." find content -type f | while read file; do # For each jpg/jpeg/png reference, update to webp sed -i '' 's/\.jpg"/\.webp"/g' "$file" sed -i '' "s/\.jpg'/\.webp'/g" "$file" sed -i '' 's/\.jpeg"/\.webp"/g' "$file" sed -i '' "s/\.jpeg'/\.webp'/g" "$file" sed -i '' 's/\.png"/\.webp"/g' "$file" sed -i '' "s/\.png'/\.webp'/g" "$file" echo "Updated: $file" done # Update hero_image in front matter echo "Updating image references in front matter..." find content -name "*.md" | while read file; do sed -i '' 's/hero_image="\/images\/.*\.jpg"/hero_image="\/images\/material-bg.webp"/g' "$file" sed -i '' 's/hero_image="\/images\/.*\.jpeg"/hero_image="\/images\/material-bg.webp"/g' "$file" sed -i '' 's/hero_image="\/images\/.*\.png"/hero_image="\/images\/material-bg.webp"/g' "$file" echo "Updated front matter in: $file" done # Update CSS files echo "Updating image references in CSS files..." find . -name "*.css" | while read file; do # Skip files in node_modules if they exist if [[ "$file" == *"node_modules"* ]]; then continue fi # For each jpg/jpeg/png reference, update to webp sed -i '' 's/\.jpg)/\.webp)/g' "$file" sed -i '' 's/\.jpeg)/\.webp)/g' "$file" sed -i '' 's/\.png)/\.webp)/g' "$file" echo "Updated: $file" done echo "All image references have been updated to WebP format!" echo "" echo "Next steps:" echo "1. Restart your Hugo server to see the changes" echo "2. Check for any missing or broken images and fix them manually"