# 构建镜像 # REPOSITORY TAG IMAGE ID CREATED SIZE # zjykzj/hexo-env latest a1e9ee129a0f About a minute ago 1.14GB $ docker build -t zjykzj/hexo-env . # # 启动容器,后台运行 # CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES # fe35a9fe54c4 zjykzj/hexo-env "docker-entrypoint.s…" About a minute ago Up About a minute 0.0.0.0:4000->4000/tcp, [::]:4000->4000/tcp hexo-dev $ docker run -it -d \ --name hexo-dev \ -v "$(pwd)/blog":/blog \ -v /etc/localtime:/etc/localtime:ro \ -w /blog \ -p 4000:4000 \ --user "$(id -u):$(id -g)" \ zjykzj/hexo-env \ sleep infinity # # 进入容器 $ docker exec -it hexo-dev bash node@1156c9756f25:/blog$ hexo -v INFO Validating config hexo: 8.1.1 hexo-cli: 4.3.2 os: linux 6.6.87.2-microsoft-standard-WSL2 Debian GNU/Linux 12 (bookworm) 12 (bookworm) node: 20.19.6 acorn: 8.15.0 ada: 2.9.2 ares: 1.34.5 brotli: 1.1.0 cjs_module_lexer: 2.1.0 cldr: 47.0 icu: 77.1 llhttp: 9.3.0 modules: 115 napi: 9 nghttp2: 1.61.0 openssl: 3.0.17 simdutf: 6.4.2 tz: 2025b undici: 6.22.0 unicode: 16.0 uv: 1.46.0 uvwasi: 0.0.23 v8: 11.3.244.8-node.33 zlib: 1.3.1-470d3a2
创建Hexo工程
初始化Hexo工程
1 2 3 4 5 6 7 8
node@1156c9756f25:/blog$ hexo init . INFO Cloning hexo-starter https://github.com/hexojs/hexo-starter.git INFO Install dependencies warning hexo-renderer-stylus > stylus > glob@7.2.3: Glob versions prior to v9 are no longer supported warning hexo-renderer-stylus > stylus > glob > inflight@1.0.6: This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested wayINFO Start blogging with Hexo! node@1156c9756f25:/blog$ node@1156c9756f25:/blog$ ls _config.landscape.yml _config.yml node_modules package.json scaffolds source themes yarn.lock
# 启动本地预览服务器(注意:需额外暴露端口!) # node@1156c9756f25:/blog$ hexo server # INFO Validating config # INFO Start processing # INFO Hexo is running at http://localhost:4000/ . Press Ctrl+C to stop. hexo server --host 0.0.0.0
# 清除缓存和生成的静态文件 hexo clean
# 自动生成一篇新文章的Markdown文件,放在source/_posts/目录下 # 文件名称为xxx.md hexo new "xxx"
> hexo-site@0.0.0 dev > hexo clean && hexo generate && hexo server
INFO Validating config INFO Deleted database. INFO Deleted public folder. INFO Validating config INFO Start processing INFO Files loaded in 219 ms INFO Generated: archives/index.html INFO Generated: index.html INFO Generated: archives/2025/11/index.html INFO Generated: css/style.css INFO Generated: js/script.js INFO Generated: archives/2025/index.html INFO Generated: fancybox/jquery.fancybox.min.js INFO Generated: js/jquery-3.6.4.min.js INFO Generated: fancybox/jquery.fancybox.min.css INFO Generated: css/images/banner.jpg INFO Generated: 2025/11/30/hello-world/index.html INFO 11 files generated in 162 ms INFO Validating config INFO Start processing INFO Hexo is running at http://localhost:4000/ . Press Ctrl+C to stop.
# URL ## Set your site url here. For example, if you use GitHub Page, set url as 'https://username.github.io/project' url: http://example.com # 比如 /2025/11/30/我的博客/ permalink: :year/:month/:day/:title/ permalink_defaults: pretty_urls: trailing_index: true # Set to false to remove trailing 'index.html' from permalinks trailing_html: true # Set to false to remove trailing '.html' from permalinks
# abbrlink config # 基于文章文件名和创建时间,通过 CRC32 算法计算出的唯一十六进制 ID abbrlink: alg: crc32 # Algorithm used to calc abbrlink. Support crc16(default) and crc32 rep: hex # Representation of abbrlink in URLs. Support dec(default) and hex drafts: false # Whether to generate abbrlink for drafts. (false in default) force: false # Enable force mode. In this mode, the plugin will ignore the cache, and calc the abbrlink for every post even it already had an abbrlink. (false in default) writeback: true # Whether to write changes to front-matters back to the actual markdown files. (true in default)
categories: - Sports - Baseball tags: - Injury - Fight - Shocking # categories: - [Sports, Baseball] - [MLB, American League, Boston Red Sox] - [MLB, American League, New York Yankees] - Rivalries