搭建自己的博客
我这里用的是云服务器 centos的
1.安装git和nodejs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
| 使用非root用户!!!! git下载地址https://git-scm.com/downloads
nodejs下载地址https://nodejs.org/en/download/
v16.20.2
8.19.4
git version 1.8.3.1 这里就安装成功了
|
2.安装Hexo
以上环境准备好了就可使用 npm 开始安装 Hexo 了,在命令行输入执行如下命令:
若是上面的命令都没报错的话,就恭喜了,运行 hexo s 命令,其中 s 是 server 的缩写,在浏览
器中输入 http://localhost:4000 回车就能够预览效果了。

3.加载主题
1 2 3 4 5 6 7 8 9 10
| 大家可以从官网下载自己喜欢的主题:https://hexo.io/themes/
我这里的主题是:https://github.com/fluid-dev/hexo-theme-fluid?tab=readme-ov-file
随后将下载的主题文件夹放在 myblog/theme 中,在 _config.yml 文件中修改theme 为hexo-theme-fluid-master(注意和主题文件名一致)
theme: hexo-theme-fluid-1.9.8
hexo-theme-fluid-1.9.8 修改好之后执行 hexo g 命令,然后再 hexo s ,在浏览器中输入 http://localhost:4000/回车就能够预览修改主题后的效果了。
|
4.将博客部署在GitHub上
点击 右上角new repository 建立一个新的仓库,注意Github 仅能使用一个同名仓库的代码托管一个静态站点,这里注意仓库名一定要是: 用户名.github.io
配置 SSH key ,要使用 git 工具首先要配置一下SSH key,为部署本地博客到 Github 作准备
按照提示完成三次回车,便可生成 ssh key,采用以下指令也可以查看自己的ssh:

此时,本地和Github的工做作得差不了,是时候把它们两个链接起来了。你也能够查看官网的部署教程。先不着急,部署以前还须要修改配置和安装部署插件。第一:打开项目根目录下的_config.yml 配置文件配置参数。拉到文件末尾,填上以下配置。

1 2 3 4 5 6 7 8 9 10 11 12 13
|
theme: hexo-theme-fluid-1.9.8
url: https://www.tiantian123.asia root: / deploy: type: 'git' repo: [email protected]:lhtkk/lhtkk.github.io.git branch: master
|
第二要安装一个部署插件 hexo-deployer-git,输如以下指令:
最后执行如下两条命令就能够部署上传啦,如下 g 是 generate 缩写,d 是 deploy 缩写
这时用浏览器输入 用户名.github.io 就可以访问刚才的网站啦。
md格式的文件放在根目录下 source/_post/ 格式如下
1 2 3 4 5 6
| --- title: istio tags: 云原生 categories: istio ---
|
之后依次输入以下命令:
1 2 3 4 5 6
| hexo g hexo s hexo d
或者hexo clean; hexo g; hexo s; hexo d
|
5.主题优化
1 2 3 4
| 参考地址:https://fluid-dev.github.io/hexo-fluid-docs/guide/
https://blog.kevinchu.top/2023/07/17/hexo-theme-fluid-modify/
|
6.cdn加速
1
| 将/img/logo.png 改成 https:
|