利用Hexo和Git搭建自己的博客(2)
前言
本文跟上上期文章一样,也是搬运自站长csdn里的某个文章
1.准备工作
- 一个hexo博客
- 一个已经部署好hexo的github仓库
- 一个代码编辑器(推荐vscode)
2.安装hexo主题(以solitude为例)
2.1 安装主题
在[BlogRoot]
输入以下命令:
1 | git clone -b main https://github.com/everfu/hexo-theme-solitude.git themes/solitude |
2.2 应用主题
在[BlogRoot]
下的_config.yml
把第99行的内容改成以下内容:
1 | theme: solitude |
除此之外还要安装Pug
和Stylus
的渲染器。
1 | npm install hexo-renderer-pug hexo-renderer-stylus --save |
然后把主题的配置文件复制到博客根目录下。
Linux/mac:
1 | cp -rf ./themes/solitude/_config.yml ./_config.solitude.yml |
windows:
1 | copy .\themes\solitude\_config.yml .\_config.solitude.yml |
3.配置站点和主题
具体可以去主题官方文档看看
3.1 站点配置
_config.yml
:
1 | # Site |
_config.solitude.yml
:
1 | # 站点设置 |
3.2 导航栏配置
左上角group
:
1 | # 导航栏左侧 |
中间菜单
:
1 | menu: |
右上角按钮
:
1 | right: # right button |
3.3 首页顶部配置
1 | # 首页顶部样式 |
3.4 本地搜索
在`[BlogRoot]输入以下命令:
1 | npm install hexo-generator-search --save |
然后回车,在_config.yml最底端添加以下内容:
1 | search: |
然后在主题配置文件开启搜索功能。
1 | # 搜索 |
4.把添加主题后的hexo博客部署到GitHub
请确保你已经安装hexo-deployer-git
且已经配置好_config.yml
的deploy
配置项还有git的ssh公钥。
1 | hexo clean |
等待一分钟左右,再次访问<giithub_user_name>.github.io
,你会发现博客已经应用好主题了。
- 感谢您的赞赏。
赞赏名单
如果你觉得这个文章很好的话,请给本站捐赠一下😀
本文是原创文章,采用CC BY-NC-SA 4.0协议,完整转载请注明来自LinuxWin🍉
评论 ()