Loading...

Loading...

Deployment

This page explains the blog’s release & deployment: how static output is hosted, the Vercel production deployment and test-domain flow, the four Docker build modes, and the “code change vs content change” release choice. The deployment chain relies on git submodules (themes/matery/ etc.), so commits need both repos committed together (see section 6).

How to read: every deployment target is given as a pair — Effect (which domain/repo gets updated) → Corresponding command/config → Output. Config sections still follow “How to enable → Common options → All tunable keys → Boundaries & conflicts”.

1. Deploying Static Output (any static host)

Purpose: Hexo generates pure static files; the public/ directory can be dropped on any static host (Nginx, GitHub Pages, Cloudflare Pages, OSS etc.) and go live directly.

Learning path: How to enable → Common options → All tunable keys → Boundaries & conflicts

1.1 How to enable

Effect: public/ contains the complete site (index.html + page directories + static assets); sync it to any web server root and visiting that domain shows your blog.

Corresponding command:

npm run build      # hexo generate + pagefind index; output in public/
npm run clean      # hexo clean; clears public/ and cache

Output: public/index.html, public/posts/, public/pagefind/ etc. are generated; npm run build exiting with code 0 means the build succeeded.

1.2 Common options

① Deploying means syncing public/

Effect: copy it to the web server root and it’s live; where the domain points is decided by the hosting platform (this project uses Vercel in production, see §2).

Corresponding command (example; replace the placeholders for your host):

rsync -a --delete public/ {{USER}}@{{HOST}}:{{WEB_ROOT}}/

Output: the server directory matches the local public/, and refreshing the domain shows the new pages.

② The root URL must match

Effect: with a correct url, absolute links in canonical, sitemap and RSS all point at your domain; a wrong one leaves those links pointing at the old domain (SEO and share cards go wrong with it).

Corresponding config (root _config.yml):

url: https://blog.17lai.site

Output: <loc>/<link> in public/sitemap.xml and public/atom.xml use that domain.

1.3 All tunable keys

OptionTypeDefaultValues / rangePurpose
urlstring—full site URLbase for absolute canonical/sitemap/RSS links
public/directory—any static host rootdeployment output
npm run buildcommand——hexo generate + pagefind index
npm run cleancommand——clears public/ and the Hexo cache

1.4 Boundaries & conflicts

  • Deploying means syncing public/: copy it to the web server root and you’re done; where the domain points is decided by the hosting platform.
  • The root URL must match: url in _config.yml decides absolute links in canonical/sitemap/RSS — change it when the hosting domain changes (see the Global Configuration chapter).
  • This project uses Vercel in production (next section); the old GitHub Pages deployment is retired.

1.5 Summary

  • Minimum viable: npm run build, then sync public/
  • Changing domain: update url in _config.yml first, then build
  • Local viewing only: npx hexo server -p 4100

2. Vercel Production Deployment (blog.17lai.site)

Purpose: production at https://blog.17lai.site. Vercel is linked to the GitHub repo github.com:appotry/hexo.git (main branch) — pushes trigger automatic builds, no manual trigger needed.

Learning path: How to enable → Common options → All tunable keys → Boundaries & conflicts

2.1 How to enable

Effect: the main branch of hexo.git gains one commit + one git tag; minutes later https://blog.17lai.site becomes the new version and the ?v= version in the HTML increments (so browsers/PWA fetch the new assets).

Corresponding command:

# push to hexo.git (production repo)
tools/cicd.sh -r "feature description"    # build + version bump + git tag + push

Output:

  • tools/.VERSION increments and the matching git tag is created
  • Only hexo.git (production) is pushed; hexoback.git is untouched
  • Vercel runs npm run build in the cloud and the output goes straight onto the CDN

2.2 Common options

① Verify production after release

Effect: layer-by-layer checks against the production domain — complete build output, 20 layout pages returning HTTP 200, comment sections present, version consistent in three places, SW smoke, etc.; any failing layer errors out.

Corresponding command:

tools/tests/release-test.sh

Output: a PASS/FAIL report per layer L1–L14 with a final total; the release only counts as done when everything is green.

② Don’t create an extra deployment repo

Effect: production only trusts hexo.git, and Vercel only watches it; a second repo means two sets of output and a confused domain mapping.

Corresponding config: the Vercel project’s Git integration (in the Vercel console, not repo config).

2.3 All tunable keys

Deployment targetTriggerRepoResulting domain
Productiontools/cicd.sh -r "feature"hexo.git (main)https://blog.17lai.site
Test domaintools/cicd.sh -t "desc"hexoback.githttps://blog2.17lai.site
Content onlytools/cicd.sh -c "desc"hexo.git + hexoback.gitboth domains update
Local debuggingtools/cicd.sh -dno pushlocal preview only

2.4 Boundaries & conflicts

  • The build runs on Vercel’s cloud (npm run build), with output going straight onto the CDN; a successful local build doesn’t mean the cloud build succeeds — the Vercel build log is authoritative.
  • Don’t create a deployment repo besides the production one; testing uses the independent hexoback.git (next section).
  • After release, run tools/tests/release-test.sh per the release rule to verify production (20 pages + comment sections + version consistency).

2.5 Summary

  • Minimum viable: tools/cicd.sh -r "desc"
  • Must verify after release: tools/tests/release-test.sh
  • Broke production: revert to the previous git tag, then -r again
  • Content only: use -c, no version bump

3. Test Domain Flow (hexoback → blog2.17lai.site)

Purpose: verify on the test domain before a real release, keeping broken changes off production. Vercel has a second project listening on hexoback.git (test repo), deploying to https://blog2.17lai.site.

Learning path: How to enable → Common options → All tunable keys → Boundaries & conflicts

3.1 How to enable

Effect: hexoback.git updates → https://blog2.17lai.site becomes the new version; production blog.17lai.site is completely unchanged.

Corresponding command:

# push the test repo (Vercel auto-deploys to the test domain)
tools/cicd.sh -t "desc"        # push test repo (Vercel deploys test domain)

# run PWA smoke + interaction verification on the test domain
make test-pwa                  # 7-page SW smoke + interaction verification

Output: -t switches the deploy target to hexoback only and pushes; make test-pwa prints SW smoke results for 7 pages plus interaction findings.

3.2 Common options

① Push production only after tests pass

Effect: the production domain updates with the same output as the test domain, carrying the bumped version number.

Corresponding command:

tools/cicd.sh -r "feature"        # official release (version bump + CDN + git tag)
tools/tests/release-test.sh    # 【release rule】full layout automated tests

Output: hexo.git gains a commit and tag; release-test.sh prints L1–L14 results.

② Skip the test domain for small changes

Effect: when only content changes, push to both (production + test) directly, saving one wait.

Corresponding command:

tools/cicd.sh -c "desc"

Output: both hexo.git and hexoback.git update, with the version number unchanged.

3.3 All tunable keys

RepoWatched byCommandResult
hexo.gitVercel production project-r / -cblog.17lai.site
hexoback.gitVercel test project-t / -cblog2.17lai.site

3.4 Boundaries & conflicts

  • The two repos are fully separate, so testing never pollutes production; but -t reuses the old version, so it does not create a new tag.
  • make test-pwa targets the test domain (blog2.17lai.site), not local port 4000.
  • Small changes (content only) can skip the test domain and push directly with -c.

3.5 Summary

  • Minimum viable: -t → make test-pwa
  • After it passes: -r → release-test.sh
  • Posts only: -c
  • Test-domain error: fix it and re-run -t — never go straight to production

4. Docker Build (four modes of tools/cicd.sh)

Purpose: tools/cicd.sh is the full CI/CD entry (proxy → version management → sub-repo sync → config injection → build → PWA version → deploy push), supporting four modes.

Learning path: How to enable → Common options → All tunable keys → Boundaries & conflicts

4.1 How to enable

Effect: after running -d inside the container, localhost:4000 shows the real posts + unminified + no CDN debug build; config injection and PWA generation still run, but nothing is pushed to any repo.

Corresponding command:

docker compose -f docker-compose.test.yml up -d
docker compose -f docker-compose.test.yml exec hexo bash
# inside the container: tools/cicd.sh -d   (local debug build)
exit
docker compose -f docker-compose.test.yml down

Output: public/index.html is regenerated and larger than 1000 bytes; after the PM2 restart, port 4000 returns 200.

4.2 Common options

① The four modes (original comparison table)

FlagPurposeVersionMinifyCDN
-d / --debuglocal debuggingno bumpoffcleared
-c "desc" / --continuecontinuous integration (posts only)reuse oldonempty
-r "feature" / --releaseofficial releasebump + git tagonjsdelivr
-t / --testlocal compile testreuse oldonempty

② Observable result of each mode

Effect: at a glance, which domain/repo changed after the command and what the output looks like.

Corresponding modes: the table below is the output difference between the four modes.

ModePush targetDomain changeOutput traits
-d / --debugno pushnone (local 4000)unminified, CDN placeholders cleared, debug-readable
-c "desc"hexo.git + hexoback.gitboth production and test updateminified, no CDN, version unchanged
-r "feature"hexo.gitproduction onlyminified + jsDelivr CDN + new tag
-t / --testhexoback.gittest domain onlyminified, no CDN, version unchanged

③ Building directly on this machine

Effect: the same output (config injection + pagefind) without Docker, for quick verification.

Corresponding command:

tools/test.sh build        # proxies to tools/hexo-build.sh
npx hexo server -p 4100    # local preview, avoiding Docker's 4000

Output: public/ is generated; port 4100 is reachable and port 4000 is unaffected.

4.3 All tunable keys

OptionValuePurpose
-d / --debugnonelocal debugging, no push
-c / --continuedescription stringpush to both, version unchanged
-r / --releasefeature stringproduction only, version bump + tag
-t / --testdescription stringtest domain only
tools/debugBlog.sh true\|falsebooleanswitch the debug post set (independent of cicd.sh)

4.4 Boundaries & conflicts

  • The hexo server inside the Docker container maps port host 4000 → container 4000; for local preview use tools/test.sh server or npx hexo server -p 4100 — the two don’t conflict.
  • Post-set replacement has been moved out of cicd.sh (2026-09-23): to speed things up with a small debug post set, run tools/debugBlog.sh true first, then tools/cicd.sh -d; restore with tools/debugBlog.sh false when done. Build scripts shouldn’t modify source files.
  • -d doesn’t push, but it does rewrite themes/matery/_config.yml (the config injection output); that’s expected — don’t commit it as a dirty change.

4.5 Summary

  • Minimum viable: tools/cicd.sh -d + open port 4000
  • Needs pushing: -c (both) / -t (test) / -r (production)
  • Port conflict: use 4100 for local preview
  • Faster builds: debugBlog.sh true is a separate step

5. Release Flow Selection (code vs content)

Purpose: picking the wrong mode means “changed it but production didn’t move” (cache hit on the old version) or an unnecessary version bump.

Learning path: How to enable → Common options → All tunable keys → Boundaries & conflicts

5.1 How to enable

Effect: git status --short prints themes/matery/ → code change → must use -r; only source/ prints → content change → -c/-d is enough.

Corresponding command:

git status --short themes/matery/   # dirty → code change → -r
git status --short source/          # content only → -d / -c

Output: lists the changed files; empty output means nothing changed in that directory.

5.2 Common options

Core principle: code changes use -r, content changes use -c/-d.

Change typeCommandReason
JS/CSS/theme code (under themes/matery/)tools/cicd.sh -r "feature"needs a version bump + git tag so browsers/PWA fetch the new version (unchanged version = cache hit)
Posts/content only (source/_posts/ etc.)-d (local preview) or -c "desc" (push)content updates need no version, incremental release
Changing the JS version numbermust -r (bump in 3 places, then release)otherwise production serves the cached old version

5.3 All tunable keys

ModeVersion behaviourHow to observe
-rreads tools/.VERSION, bumps it and creates a git taggit tag gains one; the page’s ?v= grows
-creuses the old versiontools/.VERSION unchanged

5.4 Boundaries & conflicts

  • The version number is synced in 3 places (tools/.VERSION, {urlVersion} in userConfig/_config.tmp.yml, userConfig/sw.tmp.js); miss one and part of the assets stays cached.
  • Using -r for a content-only change needlessly bumps the version and makes every visitor re-download static assets.

5.5 Summary

  • Theme code changes: -r
  • Post changes: -c (push) or -d (preview)
  • Unsure: run git status --short first to see which directory changed

6. Dual-Repo Commits (submodules)

Purpose: the theme lives in the submodule themes/matery/; after theme changes both repos must be committed, otherwise the parent repo still points at the old commit.

Learning path: How to enable → Common options → All tunable keys → Boundaries & conflicts

6.1 How to enable

Effect: the submodule repo gains one commit and the parent repo gains an “update submodule pointer” commit; the parent’s git status no longer shows themes/matery as modified.

Corresponding command:

# 1. commit the submodule
git -C themes/matery add <files>
git -C themes/matery commit -m "[✨] feat(scope): description"

# 2. commit the parent repo (updates the submodule pointer)
git add themes/matery
git commit -m "[🔧] chore: update matery submodule pointer"

Output: two commit calls produce one commit each; git status is clean.

6.2 Common options

Local commit convention: [emoji] type(scope): description, one commit does one thing.

typeemojiPurpose
feat✨new feature
fix🐛bug fix
docs📖documentation
refactor♻️refactoring
perf⚡performance
test🧪tests
chore🔧build/tooling/config
style🎨formatting

6.3 All tunable keys

RepoPathWhat’s committed
Submodulethemes/matery/theme code changes
Parent reporepo rootsubmodule pointer + site content/scripts

6.4 Boundaries & conflicts

  • Committing only the parent without the submodule → the parent pointer still points at the old commit, and the theme change never reaches production.
  • The two repos have different remotes (gitea is the main one); check each remote when pushing.

6.5 Summary

  • Minimum viable: submodule commit → parent repo pointer commit
  • Forgot step two: the parent’s git status keeps showing the submodule as modified
  • Commit message: [emoji] type(scope): description

7. Open Graph Metadata (open_graph)

Purpose: generate Open Graph social-sharing metadata for pages (title, description, thumbnail shown when sharing to WeChat/Twitter/Facebook).

Learning path: How to enable → Common options → All tunable keys → Boundaries & conflicts

7.1 How to enable

Effect: the page <head> gains og:title / og:description / og:image / twitter:card etc.; paste the link on a social platform and the card shows the title, description and thumbnail.

Corresponding config (theme config):

open_graph:
  enable: true
  twitter_card: summary_large_image   # Twitter card type
  twitter_id:                         # Twitter user ID
  twitter_site:                       # Twitter site @username
  google_plus:                        # Google+ profile
  fb_admins:                          # Facebook admin ID
  fb_app_id:                          # Facebook App ID

Output: after building, the head section of public/posts/<abbrlink>/index.html contains those meta tags.

7.2 Common options

① Default share image

Effect: when a post has no img, home/list share cards use this image; post pages still prefer the post cover.

Corresponding config:

open_graph:
  default_og_image: /medias_webp/featureimages/15.webp

② Change the Twitter card style

Effect: summary_large_image shows a large-image card; summary shows a small square card.

Corresponding config:

open_graph:
  twitter_card: summary

7.3 All tunable keys

KeyTypeDefaultValues / rangePurpose
open_graph.enablebooltruetrue / falsegenerate OG tags
open_graph.twitter_cardstringsummary_large_imagesummary / summary_large_imageTwitter card type
open_graph.twitter_idstringemptyTwitter user IDauthor attribution
open_graph.twitter_sitestringempty@usernamesite account
open_graph.fb_adminsstringemptyFacebook admin IDFB admin
open_graph.fb_app_idstringemptyFacebook App IDFB app
open_graph.default_og_imagestring—image pathfallback image when the post has none

7.4 Boundaries & conflicts

  • Based on Hexo’s built-in open_graph helper; with enable: true the OG tags are generated automatically from post front-matter (title/description/cover) and read by social platforms on share.
  • Image priority: page.img (post image) → theme.default_og_image (default) → theme.featureImages[0].
  • Theme config changes must also go into userConfig/_config.tmp.yml, or the next CI build overwrites them.

7.5 Summary

  • Minimum viable: enable: true
  • Card has no image: set default_og_image
  • Large-image card: twitter_card: summary_large_image

8. Safe Redirect Page (safego)

Purpose: external-link redirect safety page — outbound links pass through a notice page on this site first, avoiding a direct jump (anti-phishing/anti-tracking).

Learning path: How to enable → Common options → All tunable keys → Boundaries & conflicts

8.1 How to enable

Effect: clicking an external link first opens this site’s safety notice page; the visitor only leaves after confirming. When off, the link goes straight to the target site.

Corresponding config (theme config):

safego:
  enable: false

Output: with enable: true, scripts.ejs pulls in libs.js.safego (defer) and css.ejs additionally preloads that script; with false, neither tag appears on the page.

8.2 Common options

① Turn on / off

Effect: true intercepts outbound jumps and shows the notice page; false (default) keeps the native jump with no extra request.

Corresponding config:

safego:
  enable: true

8.3 All tunable keys

KeyTypeDefaultValues / rangePurpose
safego.enableboolfalsetrue / falseexternal-link safety notice switch

8.4 Boundaries & conflicts

  • Depends on the libs.js.safego asset and the safego styles; when missing, the notice page is unstyled or the script doesn’t work.
  • Reference implementation: Fluid safe jump.

8.5 Summary

  • Minimum viable: enable: true
  • Off by default: keep false if you don’t want the extra click

Appendix: Deployment Quick Reference

ScenarioCommand
Local previewtools/cicd.sh -d or npx hexo server -p 4100
Content-only pushtools/cicd.sh -c "desc"
Test domain verificationtools/cicd.sh -t "desc" + make test-pwa
Official releasetools/cicd.sh -r "feature" + tools/tests/release-test.sh
Fast local buildtools/test.sh build
Docker testdocker compose -f docker-compose.test.yml up -d && ... exec hexo bash
Comments
Data Loading...