A personal blog built with Hexo and the Cactus theme, featuring a dynamic theme switcher and deployed on Cloudflare Pages.
- π¨ Dynamic Theme Switcher - Switch between 4 color schemes (Dark, Light, White, Classic) without page reload
- π Local Search - Fast client-side search functionality
- π± Responsive Design - Mobile-friendly layout
- β‘ Fast Deployment - Automated deployment to Cloudflare Pages via GitHub Actions
- π― Git Submodule Theme - Easy theme updates and version control
- Bun (or Node.js)
- Git
# Clone the repository
git clone https://github.com/silryn/blog.git
cd blog
# Initialize git submodules (for the theme)
git submodule update --init --recursive
# Install dependencies
bun install# Start local development server
bun run server
# Visit http://localhost:4000# Clean previous build
bun run clean
# Generate static files
bun run build
# Output will be in the dist/ directoryThis blog features a custom theme switcher that allows users to toggle between 4 color schemes in real-time.
- Button: A floating button in the bottom-right corner displays the current theme icon
- Themes: π Dark, βοΈ Light, βͺ White, π¨ Classic
- Persistence: User preference is saved in localStorage
- Smooth Transition: Fade effect during theme switching
If you update the Cactus theme or modify theme configurations, you need to regenerate all theme CSS files:
bash build-all-themes.shThis script:
- Builds the site 4 times with different
colorschemesettings - Generates
style-dark.css,style-light.css,style-white.css,style-classic.css - Saves them to
source/css/for the theme switcher to use
When to run this script:
- After updating the theme submodule (
git submodule update --remote themes/cactus) - After modifying theme configuration in
_config.cactus.yml - When setting up the project for the first time (if CSS files are missing)
Note: The generated CSS files are committed to the repository, so you don't need to run this script for normal development or deployment.
.
βββ .github/
β βββ workflows/
β βββ deploy-cloudflare.yml # CI/CD configuration
βββ source/ # Source files
β βββ _posts/ # Blog posts
β βββ about/ # About page
β βββ search/ # Search page
β βββ images/ # Images (favicon, logo)
β βββ css/ # Custom CSS
β β βββ custom.css # Custom styles
β β βββ style-dark.css # Dark theme
β β βββ style-light.css # Light theme
β β βββ style-white.css # White theme
β β βββ style-classic.css # Classic theme
β βββ js/
β βββ theme-switcher.js # Theme switching logic
βββ scripts/ # Hexo scripts
β βββ theme-switcher-injector.js # Injects theme switcher into pages
βββ themes/
β βββ cactus/ # Theme (git submodule)
βββ _config.yml # Hexo configuration
βββ _config.cactus.yml # Theme configuration
βββ build-all-themes.sh # Theme CSS generator script
βββ package.json # Dependencies
Create a new post:
hexo new "My New Post"This creates a new file in source/_posts/. Edit it with your content using Markdown.
---
title: My Post Title
date: 2026-01-15 10:00:00
tags:
- tag1
- tag2
categories:
- category1
---
Your content here...Main Hexo configuration including site title, URL, and plugins.
Theme-specific settings:
- Navigation menu
- Social links
- Logo and favicon
- Color scheme (default)
- Analytics
- Comments
Push to the main branch triggers automatic deployment to Cloudflare Pages via GitHub Actions.
The workflow:
- Checks out code with submodules
- Sets up Bun
- Installs dependencies
- Adds build information to About page
- Builds the site
- Deploys to Cloudflare Pages
# Build the site
bun run build
# Deploy the dist/ directory to your hosting providerTo update the Cactus theme:
# Update the submodule to the latest version
git submodule update --remote themes/cactus
# Regenerate theme CSS files
bash build-all-themes.sh
# Commit the changes
git add themes/cactus source/css/style-*.css
git commit -m "Update Cactus theme"
git pushAdd custom CSS to source/css/custom.css. This file is automatically loaded and won't be overwritten by theme updates.
Add Hexo scripts to the scripts/ directory. They will be automatically loaded during build.
# Ensure submodules are initialized
git submodule update --init --recursive# Regenerate theme CSS files
bash build-all-themes.sh# Clean and rebuild
bun run clean
bun run build- Blog content: Β© Silryn
- Hexo: MIT License
- Cactus Theme: MIT License
- Blog: https://blog.silryn.com
- Hexo: https://hexo.io/
- Cactus Theme: https://github.com/probberechts/hexo-theme-cactus