This guide explains the complete process for adding new blog posts to brianbondy.com, including image optimization for better PageSpeed performance.
Before adding blog posts, ensure you have the required tools installed:
# Install WebP conversion tool
brew install webp # macOS
# or
sudo apt-get install webp # Ubuntu/Debian
# or
sudo yum install libwebp-tools # CentOS/RHEL-
Create markdown file: Add a new file in
data/markdown/blog/with the next available ID# Example: for blog post 191 touch data/markdown/blog/191.markdown -
Add metadata: Update
data/blogPostManifest.jsonwith the new post's information{ "id": 191, "title": "Your Blog Post Title", "created": "2025-01-15", "tags": ["tag1", "tag2"], "fbImagePath": "static/img/blogpost_191/featured-image.jpg", "fbDescription": "Brief description for social media" }
-
Create image directory: Create a directory for your blog post images
mkdir -p static/img/blogpost_191
-
Add your images: Place your
.jpg,.jpeg, or.pngimages in the directory# Example: adding images cp your-image1.jpg static/img/blogpost_191/ cp your-image2.png static/img/blogpost_191/
Option A: Process all blog post images (recommended)
make blog-imagesOption B: Process only your specific blog post
python3 scripts/process_new_blog_images.py 191Option C: Process all images in the entire site
make webp-
Test locally:
go run .Visit
http://localhost:8080to verify your blog post appears correctly -
Run tests:
make test -
Deploy:
make deploy
The image processing scripts automatically:
- Convert to WebP: Convert
.jpg,.jpeg, and.pngfiles to.webpformat - Optimize quality: Use quality setting of 80 (good balance of size vs quality)
- Smart conversion: Only convert images that don't already have WebP versions or are newer than existing WebP files
- Size reporting: Show file size savings for each converted image
| Command | Description |
|---|---|
make webp |
Convert all images in static/img to WebP |
make webp-force |
Force convert all images (even if WebP exists) |
make blog-images |
Process all blog post images |
python3 scripts/process_new_blog_images.py [ID] |
Process specific blog post images |
Main WebP conversion script (scripts/convert_images_to_webp.py):
python3 scripts/convert_images_to_webp.py --help
# Options:
# --force Convert all images even if .webp already exists
# --directory Specify directory to process (default: static/img)
# --quality WebP quality 0-100 (default: 80)Blog post specific script (scripts/process_new_blog_images.py):
python3 scripts/process_new_blog_images.py --help
# Options:
# blog_post_id Specific blog post ID to process (e.g., 191)
# --force Force convert all images even if .webp already existsThe website automatically optimizes images through the optimizeImages template function:
- WebP format: Uses
.webpversions when available - Lazy loading: Adds
loading="lazy"to images - Async decoding: Adds
decoding="async"for better performance - Responsive images: Adds
srcsetfor different screen densities - Fallback support: Falls back to original format if WebP not supported
When you run the image processing, you'll see output like:
✓ Converted: static/img/blogpost_191/image1.jpg → static/img/blogpost_191/image1.webp
Size: 245,760 bytes → 98,304 bytes (60.0% smaller)
⏭ Skipped: static/img/blogpost_191/image2.jpg (WebP already exists and up-to-date)
-
WebP tool not found:
Error: cwebp tool not found. Please install it first: macOS: brew install webp Ubuntu/Debian: sudo apt-get install webp CentOS/RHEL: sudo yum install libwebp-tools
-
Permission errors: Make sure you have write permissions to the image directories
-
Images not showing: Check that the image paths in your markdown match the actual file locations
- Smaller file sizes: WebP typically reduces image size by 25-35%
- Faster loading: Smaller files load faster
- Better PageSpeed scores: Optimized images improve overall site performance
- Modern format support: WebP is supported by all modern browsers
- Use descriptive filenames:
race-finish-line.jpginstead ofimg1.jpg - Optimize source images: Start with reasonably sized images (don't upload 10MB photos)
- Run image processing after adding images: Always run
make blog-imagesafter adding new images - Test locally first: Always test your blog post locally before deploying
- Keep original images: The scripts preserve your original images alongside the WebP versions
After processing, your blog post directory will look like:
static/img/blogpost_191/
├── featured-image.jpg # Original image
├── featured-image.webp # Optimized WebP version
├── race-photo.jpg # Original image
├── race-photo.webp # Optimized WebP version
└── finish-line.png # Original image
└── finish-line.webp # Optimized WebP version
The website will automatically serve the WebP versions to supported browsers while falling back to the original formats for older browsers.