本文最后更新于 9 个月前,文中所描述的信息可能已发生改变。
基于 HEXO 的个人博客搭建教程
目录
参考文章:
友情链接:
基础环境配置
- 准备一个文本编译器VS Code或者其他(Trae/cursor)
- 安装Node.js: Node.js官方下载
- 安装Git: Git官方下载
Hexo安装
- 安装Hexo:
npm install -g hexo-cli
Hexo配置
Hexo主题配置
- 选择一个主题: 从HEXO的主题库选择一个你喜欢的主题, 例如:
hexo-theme-next - 安装主题:
npm install hexo-theme-next --save - 配置主题: 在博客根目录下的
_config.yml文件中, 找到theme字段, 并将其值设置为你安装的主题名称, 例如:theme: next
Hexo部署
配置github pages: 确保你有一个github账号, 并在github上创建一个新的仓库, 仓库名称为
yourusername.github.io, 其中yourusername是你的github用户名.配置git: 确保你已经配置了git的全局用户名和邮箱, 可以使用以下命令进行配置:
bashgit config --global user.name "yourusername" git config --global user.email "youremail@example.com"配置ssh密钥: 确保你已经配置了ssh密钥, 可以使用以下命令进行配置:
bashssh-keygen -t rsa -P "" -f ~/.ssh/id_rsa添加ssh密钥到github: 将
~/.ssh/id_rsa.pub文件的内容复制到github账号的ssh密钥设置中.配置部署: 在博客根目录下的
_config.yml文件中, 找到deploy字段, 并根据你选择的部署方式进行配置, 例如:yamldeploy: type: git repo: https://github.com/yourusername/yourusername.github.io.git branch: master部署:
hexo deploy
博客书写及上传
- 新建md文件:
hexo new "文章标题" - 编辑md文件: 使用你喜欢的文本编辑器打开
source/_posts/文章标题.md文件, 并在文件中编写你的博客内容. - 上传博客:
hexo deploy
常用命令
- 初始化博客:
hexo init - 安装依赖:
npm install - 生成静态文件:
hexo generate - 启动本地服务器:
hexo server - 部署到GitHub Pages:
- 安装部署插件:
npm install hexo-deployer-git --save - 新建md文件:
hexo new "文章标题" - 部署:bash
hexo clean hexo generate hexo deploy
- 安装部署插件:


