Hexo@零成本搭建个人博客站 | 部署到Gitee平台

参考资料:

运行环境

Windows 10 操作系统

准备环境

1. 安装Git

官方下载地址

image

打开下载好的exe文件.

image

默认安装目录为 C:\Program Files\Git

image

安装完毕

image

2. 安装 Node.js

Hexo框架是基于Node.js开发的,所以得准备Node.js环境.

官方下载地址

LTS版本表示当前较稳定、使用者最多的版本.

image

注:官方下载速度可能比较慢,可以在淘宝镜像站下载,下载地址:Node-v16.13.0-x64.msi

image

image

image

选择自动安装必要的工具这一项后点击Next.

image

最后点击 Install.

image

安装成功

image

image

3.本机安装 Hexo

切换Git镜像源为淘宝镜像源,查看hexo信息

Win + R -> cmd 打开命令提示符

npm config set registry https://registry.npm.taobao.org
npm info hexo

image

安装hexo

npm install -g hexo

image

找一个文件夹用于存储Hexo博客的资源. 以 D:\uniHexo为例 ,在文件夹下输入cmd回车可进入对应的位置,当然也可以在之前的命令提示符里通过:D切换磁盘,cd uniHexo 进入文件夹。

image

在命令提示符里输入安装hexo资源

hexo init home
cd home
npm install

image

image

4. 启动测试 hexo

Hexo常用命令

清除所有记录

hexo clean

image

生成静态网页

hexo generate

image

启动服务

启动后终端不能关闭,否则网站无法访问.

测试完成后,Ctrl + C 即可关闭.

hexo server -p 80

image

访问URL:http://localhost/ 默认端口是80

结果如下:

image

至此,本地的Hexo部署已完成.

5. Windows 配置 SSH 免密码登陆

打开 Git Base, 先查看本地是否存在私钥

cd ~/.ssh

image

如上图所示,则不存在私钥,接下来创建 SSH key,输入命令后连续回车.

ssh-keygen -t rsa -C "Gitee的注册邮箱"

image

最终生成的文件默认位置在 C:\Users\Lenovo\.ssh

image

复制 id_rsa.pub文件的内容,之后会用来与Gitee连接.

测试 SSH 连接

在系统命令提示符输入 ssh -T git@gitee.com,结果如下,说明配置完毕.

image

在Gitee中添加SSH公钥

image

image

image

部署 Gitee

1. 配置Hexo

配置 Hexo项目下的_config.yml文件

设置部署的typerepo属性,后者为Gitte仓库的URL,type则固定为git

image

使用Git命令安装Hexo-Git 插件

npm install hexo-deployer-git --save

image

设置 Gitee的邮箱和用户名

git config --global user.email 邮箱
git config --global user.name 用户名

image

上传到Gitee

hexo deploy

image

首次部署连接会要求输入Gitee的用户名和密码

image

image

部署完毕,Gitee 仓库出现项目文件

image

2. Gitee 新建 仓库

image

仓库名称 任意

路径必须和用户名一致,这样仓库地址就不会产生二级域名

设置项目许可证

image

image

选择 Mulan许可证
image

提交
image

3. 开启Gitee Pages服务

image

若Gitee账号未进行实名认证,按照网页中的步骤即可

image

实名认证审核一般在一个工作日内,审核通过后可申请 Gitee Pages服务

image

开启服务后,即可访问博客地址.

image

image

至此, 基于 Gitee的个人博客搭建完毕.

posted @ 2021-11-05 23:02  Unirithe  阅读(406)  评论(0)    收藏  举报