7.6 KiB
Leon的技术阁 (Leon's Tech Pavilion)
Description
Source repository for Leon的技术阁 (Leon's Tech Pavilion), a personal Chinese-language
tech blog by Leon Xu. The site is generated with Hexo using the
Butterfly theme, and every push to
master triggers a Gitea Actions pipeline that builds the static site and deploys it
over SSH to a self-hosted server.
Live site: https://www.leonxu260.dev (canonical www host, behind Cloudflare;
the apex leonxu260.dev 301-redirects to www; HTTPS everywhere via Let's Encrypt).
Features
- Chinese-language blog (
zh-CN) built on Hexo 8.1.2 and Butterfly 5.7.2 (installed as thehexo-theme-butterflynpm package — no vendored theme copy). - Fully automated deploys: push to
masterand the site is rebuilt and live in seconds. - Key-based rsync deploys — the server rejects password authentication by policy.
- Rich plugin set:
abbrlinkpermalinks, sitemap + Baidu sitemap, Algolia search, encrypted posts, word counts, lazy-loaded images, and Butterfly tag-plugin widgets. - Site configuration in
_config.ymland_config.butterfly.yml; dependencies inpackage.json.
Installation
Requirements:
- Node.js 22 (matches the CI environment)
- yarn (the repo ships a
yarn.lock; there is nopackage-lock.json) - git
Steps:
-
Clone the repository:
git clone https://git.leonxu260.dev/Discharge7443/hexo-butterfly.git cd hexo-butterfly -
Install dependencies:
yarn install -
(Optional) Install the Hexo CLI globally for local preview commands:
npm install -g hexo-cli
Docker (local or NAS — no Node or node_modules on the host)
The repo ships a dev image for any Docker-compatible machine where you don't
want to install Node — your laptop, a NAS, a build box. Dependencies are
baked into the image; the source is mounted in, and a named volume shields
node_modules so the host filesystem stays clean.
With Docker:
docker compose up # preview at http://localhost:4000
docker compose run --rm hexo generate # build the site into ./public
With Finch (Apple's open-source container CLI for macOS — a free, Docker-desktop-free alternative):
finch compose up
finch compose run --rm hexo generate
On a NAS or other LAN machine, the preview is reachable at
http://<host>:4000 (the container binds 0.0.0.0 on purpose).
After changing package.json or yarn.lock, rebuild the image and reset the
named dependency volume (a plain up -V won't do it — -V only renews
anonymous volumes):
docker compose build && docker compose down -v && docker compose up
# with Finch: same commands, substituting `finch compose`
Forking the deploy setup
The CI/CD pipeline lives in .gitea/workflows/deploy.yml. To reuse it you need:
- A Gitea instance with Actions runners (
act_runner) - A repository secret named
DEPLOY_KEYcontaining the private half of an SSH key whose public half is in the target server'sauthorized_keys - A webroot on the server to rsync into (the workflow syncs to
root@<server>:/www/wwwroot/<domain>/)
Note that the workflow pins the server's IP address on purpose: the site's domain is Cloudflare-proxied, and Cloudflare does not proxy SSH, so the rsync step must talk to the origin directly.
Usage
Local development:
hexo server # live preview at http://localhost:4000
hexo generate # build the static site into public/
hexo clean # remove generated files and the Hexo cache
Deployment requires nothing beyond a push:
git add .
git commit -m "new post"
git push origin master
The CI is written for Gitea Actions and lives in two workflow files under
.gitea/workflows/. Each workflow contains jobs, and the jobs are chained with
needs: — a job's gates — so downstream jobs physically cannot start until
everything they depend on has passed.
deploy.yml — triggers on every push to master
(plus manual dispatch from the Actions tab). Three jobs:
build— checks out the repo, sets up Node 22, and runs a singleyarn install --frozen-lockfilefor the whole job; thenhexo generate, a Markdown lint oversource/andscaffolds/withmarkdownlint-cli2(house style codified in.markdownlint-cli2.jsonc; lint failures fail the job), image optimization with pngquant/jpegoptim (~56% smaller images, originals insource/untouched), and finally uploadspublic/as thesiteworkflow artifacttest(needs: build) — downloads the artifact, no rebuild, and never touches production: structural checks (index, theme assets, file count) plus a serving smoke test that requests the homepage, a real post page, and the stylesheet over a local HTTP serverdeploy(needs: test) — downloads the tested artifact, writes an SSH deploy key from theDEPLOY_KEYsecret, andrsync -avzover SSH (key-based only; the server rejects password auth) toroot@69.164.253.99:/www/wwwroot/leonxu260.dev/
Transfers are incremental — the first deploy took ~100 s; subsequent runs finish in
seconds. The server runs BT Panel (BTPanel) + nginx, which serves the synced
public/ output directly as the webroot.
lint.yml — runs the same Markdown lint on pushes to
non-master branches and on pull requests, so style feedback arrives without
duplicating the master chain's dependency install.
Support
This is a personal site, but questions and corrections are welcome — open an issue at https://git.leonxu260.dev/Discharge7443/hexo-butterfly/issues.
Contributing
Content is personal, but fixes (broken links, config or CI improvements) are appreciated. To work on it locally:
yarn install
hexo server # verify your changes at http://localhost:4000
hexo generate # confirm a clean build
Please keep changes compatible with Node 22 / yarn, and remember that any push to
master deploys to production.
Authors and acknowledgment
- Leon Xu — site content, configuration, and deploy pipeline.
- Hexo and its plugin authors, and Butterfly (theme) — the framework and design this blog is built on.
License
Not specified — the repository contains no LICENSE file, and the site content is the author's personal work.
Project status
Active. Every push to master triggers an automated build and deploy. Recent
milestones:
- Migrated git hosts: abandoned gitlab.com → self-hosted Gitea (with Actions runners)
- Migrated deploy mechanism: SFTP (
hexo-deployer-sftp) → key-based rsync over SSH - Upgraded the stack: Hexo 6 → 8, Butterfly 4 → 5