(由于gitee网站正在进行绿色网络环境改造,服务改造结束前,无法开通新的Gitee Pages服务!!要等网站改造好!!!!未完成,差最后一步!只可以在本地部署)
前置准备
- git (管理代码)
- node.js(hexo环境依赖)
一、hexo搭建个人博客
- 安装hexo:
npm install -g hexo #我装了cnpm,所以可能后面会看到npm变成cnpm,都一样
- 初始化创建
hexo init /Users/leitianxiao/Documents/700_TestDev/blog
这样hexo就安装完成了。

- 安装hexo所需要的其它文件
cd /Users/leitianxiao/Documents/700_TestDev/blog #进入文件夹
npm install # 安装hexo所需文件

- 启动hexo
hexo clean # 清除所有记录
hexo generate # 生成静态网页
hexo server -p 80 # 启动服务,80为端口号


hexo的一些常用命令:

二、主题配置
-
挑选主题
可以在https://hexo.io/themes/挑选自己喜欢主题。
我选择了这个主题:https://github.com/miccall/hexo-theme-Mic_Theme
下载压缩包放到blog下的themes目录下。

-
修改配置
修改根目录的配置文件
_config.yml
文件中的theme的值。(确保themes目录下的文件名和配置文件的名字一样即可)theme: daybreak

-
重启hexo服务
hexo clean # 清除所有记录 hexo generate # 生成静态网页 hexo server -p 80 # 启动服务,80为端口号
再访问http://localhost:80,主题就会变为我们喜欢的主题了。
三、生成博客文章
hexo new test # 会生成一个test.md在`/source/_posts`下
四、上传到gitee
-
在gitee创建自己的账户
-
新建一个仓库
(由于有个操作搞乱了文件夹,新建了一个myblog的文件夹,相当于前面的blog就好)

进入仓库,获得仓库的地址:https://gitee.com/leitianxiao/myblog.git
-
复制URL,到hexo的配置文件
_config.yml
deploy: type: git # type为git repo: https://gitee.com/leitianxiao/myblog.git # 仓库的URL
-
Git全局设置(建完仓库时,页面会提示,可以直接复制你的)
需要先装一个hexo的插件
cnpm install hexo-deployer-git --save
全局配置:
git config --global user.name "xx" # 设置用户名(git的注册昵称) git config --global user.email "xx@126.com" # 设置gitee邮箱(gitee的注册邮箱)
-
上传到gitee
hexo deploy

五、gitee pages 网页解析服务

最后一步被卡住了。等待开放吧。我也不知道能不能成功。。。醉了。

六、遇到问题
-
Hexo启动页面显示extends includes/layout.pug block content include includes/recent-posts.pug include
https://blog.csdn.net/weixin_44318830/article/details/104884936
-
一些好看的hexo主题
-
hexo deploy后, ERROR Deployer not found: git
https://blog.csdn.net/weixin_36401046/article/details/52940313
-
本地图片引用了却无法显示
使用图床:https://www.superbed.cn/ 或者引用本地图片。为了防止路径出错,建议使用图床。
网友评论