Files
OneMD/posts/blog/效率与工具/博客/hexo/hexo部署.md
T
2026-06-19 14:45:07 +08:00

41 lines
1.8 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
---
title: hexo部署
date: 2025-09-14
tags: [hexo]
---
**1️⃣ Hexo Admin 在服务器上直接公网编写文章**
- 可行,但要注意安全:
- Hexo Admin 本质是一个本地后台,默认是运行在 Node.js 服务器上的。
- 如果你把它部署在公网服务器:
- 你可以直接在浏览器访问 http://你的服务器IP:端口/admin,可视化编写文章。
- 写完文章后点击发布,它会生成静态文件(public/)。
- 你只需要在服务器上配置好 Nginx/Apache 指向 public/ 就能上线。
- 安全注意事项:
- 默认 Hexo Admin 用户名/密码可能简单,需要设置强密码。
- 最好用 反向代理 + HTTPS + IP 限制 或 VPN 保护后台。
- 如果直接暴露在公网,存在被攻击风险。
✅ 总结:Hexo Admin 可以在服务器上实现公网编辑和直接生成,但需要严格安全配置。
**2️⃣ 利用 GitHub 平台,个人仓库 + 自动部署**
- 完全可以:
- GitHub 上可以创建个人仓库存放 Hexo 博客源文件(source/_posts 等)。
- 编写文章后:
- 本地 hexo g 生成静态文件
- hexo d 可以配置自动推送到 GitHub Pages(仓库的 gh-pages 分支)
或者通过 CI/CD 自动把 public/ 部署到你自己的服务器。
- 好处:
- GitHub 保存一份 Markdown 原始内容(版本控制)
- 同时可以自动上线到你的网站(GitHub Pages 或 VPS
- 流程示例:
- 本地写文章 → 保存到仓库
- GitHub 自动触发 Actions
- 生成 Hexo 静态文件
- 推送到部署服务器 / GitHub Pages
- 网站更新完成,访问即见效果
✅ 总结:GitHub 仓库可以个人使用,同时实现“保存一份 + 自动上线”。