最近无聊有想整点东西,想这写blog,就心血来潮又搞了hexo,想着这次一定要静下心来。
安装 hexo
1 | npm install hexo-cli -g --registry=https://registry.npm.taobao.org |
根据配置 修改自己的信息
官网:https://hexo.io/zh-cn/docs/configuration
安装主题 next
1 | cd blog |
修改 主题配置
官网:https://theme-next.iissnan.com/getting-started.html
集成第三方插件
1.搜索
安装插件
1 | npm install hexo-generator-searchdb --save --registry=https://registry.npm.taobao.org |
配置博客
安装完成,编辑博客配置文件:_config.yml
1 | search: |
配置主题
Next 主题自带搜索设置,编辑主题配置文件:_config.yml
找到文件中 Local search 的相关配置,设为 true
1 | # Local search |
2.评论和阅读次数
注册 learncloud 进行部署
3.seo优化
参考:[https://hoxis.github.io/Hexo+Next%20SEO%E4%BC%98%E5%8C%96.html](https://hoxis.github.io/Hexo+Next SEO优化.html)
安装插件
需要安装两个插件来生成 sitemap 文件,前一个是传统的 sitemap,后一个是百度的 sitemap。
1 | npm install hexo-generator-sitemap --save |
修改站点配置文件
将sitemap文件添加到站点配置文件_config.yml中,并修改url字段的值,其值默认为http://yoursite.com。
1 | sitemap: |
rabots 协议
在站点source文件夹下新建robots.txt文件,文件内容如下:
1 | User-agent: * |
安装完成后执行hexo g即会在站点public目录下生成sitemap.xml和baidusitemap.xml。
Allow字段的值即为允许搜索引擎爬区的内容,可以对应到主题配置文件中的menu目录配置,如果菜单栏还有其他选项都可以按照格式自行添加。
需要将https://hoxis.github.io改成自己的域名。
github部署
github:https://hexo.io/zh-cn/docs/github-pages
一键部署:https://hexo.io/zh-cn/docs/one-command-deployment
安装插件:npm install hexo-deployer-git --save --registry=https://registry.npm.taobao.org
1 | deploy: |