2025年8月4日
效果预览:https://github.com/archives/index.html
准备:
- Windows电脑
- GitHub账号
- Git、Node.js、Hexo框架搭建blog软件
安装过程:
(1)Git安装
参考网址:https://git-scm.com/
步骤:
- 下载并安装Git;
- 打开命令提示符或终端,输入
git --version
查看是否安装成功。
(2)Node.js安装
参考网址:https://nodejs.org/en/
步骤:
- 下载并安装Node.js;
- 打开命令提示符或终端,输入
node -v
检查安装版本。
(3)Hexo框架搭建
- 步骤1:先检测Node和Git是否安装成功
node -v
git --version
- 步骤2:安装淘宝的镜像源(如果错误就重来,因为连接可能不稳定)
npm install -g cnpm --registry=https://registry.npm.taobao.org
-
步骤3:建立仓库(repository)
参考示例:hansonpang99.github.io -
步骤4:在Blog目录下安装Hexo部署插件
cnpm install --save hexo-deployer-git
-
步骤5:打开_config.yml文件,更改仓库信息
# _config.yml中的配置项
deploy:
type: git
repository: https://github.com/用户名/仓库名.git
branch: master
步骤6:将本地文件部署到GitHub上
- 进入Blog目录,输入以下命令:
hexo g
生成静态文件;hexo d
部署到GitHub。
访问网站:
- 通过访问 https://+你的仓库名 就可以访问部署 到GitHub上的blog了(例如:https://hansonpang99.github.io)。
进一步深化操作 process:
(1)更换Blog的主题
以yilia主题为例进行更换:
步骤:
- 下载yilia主题,打开Git命令行
git clone https://github.com/litten/hexo-theme-yilia.git themes/yilia
- 打开_config.yml文件,更改配置项
theme
为 newly downloaded theme path。
例如:
# _config.yml中的配置项
theme: themes/yilia
步骤:
- 清除数据库缓存
hexo clean
- 重新生成静态页面
hexo g
- 部署到GitHub上
hexo d
这样就实现了主题的更改。