Hexo博客搭建
2018.05.26
Grooter
前端
热度 89℃
Hexo环境搭建
安装Git Bash
安装Node.Js
安装hexocd到需要安装位置的目录,输入npm i -g hexo
初始化hexo在blog根目录下初始化blog,输入hexo init
搭桥到Github
在github上创建res,名称为grooters.github.io
在hexo根目录打开Git Bash上输入:
1 2
| git config --global user.name "grooter" git config --global user.email "figurers@163.com"
|
创建ssh:
1
| ssh-keygen -t rsa -C "figurers@163.com"
|
将用户目录下的id_rsa.pub文件内容复制到github上新建的ssh中去
本地Hexo配置
修改blog目录下_config.yml文件中的deploy:
1 2 3
| type: git repo: git@github.com:Grooters/grooters.github.io.git branch: master
|
坑
Error: fatal: HttpRequestException encountered
需要安装:GCMW-1.14.0.exe
unable to auto-detect email address
1 2
| git config --global user.email "figurers@163.com" git config --global user.name "grooters"
|
Git bash闪退并生成mintty.exe.stackdump文件
以下方法来自CSDN博主xxwsxx
需要替换掉C:\Windows\System32\drivers下的null.sys文件
null.sys
密码:1q4d
在C:/Window/System32/找到cmd并右键管理员模式运行,输入sc start null,若输出结果的STATE属性值为RUNNING,则问题解决。
ERROR Deployer not found: git
1
| npm install --save hexo-deployer-git
|
基本命令
1 2 3 4 5 6 7 8 9 10 11 12
| //可通过localhost:4000访问博客 hexo server
//清理博客目录下的文件 hexo clean
//重建博客文件 hexo generate
//上传到Github hexo deploy
|
fexoer主题的使用
官方文档
更改主题:
在博客根目录下的_config.yml文件中:
布局样式修改
- 各页面的布局可在主题文件根目录中的layout文件夹对应的ejs文件更改
- 主题的样式可以在主题文件根目录中的source文件夹中css文件夹的styles.css文件中更改
站内搜索
- 用主题写好的搜索引擎,详见文档
- 使用swiftype实现站内搜索:
在官网中注册账号添加站点,抓取数据,然后复制其提供的js代码到search.ejs文件中,将搜索框的id改为:st-default-search-input
Valine评论系统的使用
在post.ejs的div中加入:
Valine
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
| <script src="//cdn1.lncld.net/static/js/3.0.4/av-min.js"></script> <script src="//unpkg.com/valine@latest/dist/Valine.min.js"></script> <div id="comment" class="vcomment" ></div> <script> var notify = '<%= theme.valine.notify %>' == true ? true : false; var verify = '<%= theme.valine.verify %>' == true ? true : false; var GUEST_INFO = ['nick','mail','link']; var guest_info = '<%= theme.valine.guest_info %>'.split(',').filter(function(item){ return GUEST_INFO.indexOf(item) > -1 }); guest_info = guest_info.length == 0 ? GUEST_INFO :guest_info; window.valine = new Valine({ el: '.vcomment', notify: notify, verify: verify, appId: "<%= theme.valine.appid %>", appKey: "<%= theme.valine.appkey %>", avatar:'<%= theme.valine.avatar %>', placeholder: "<%= theme.valine.placeholder %>", guest_info:guest_info, pageSize:'<%= theme.valine.pageSize %>' }); </script>
|
添加不蒜子
在D:\Blog\themes\fexoer\layout目录下的post.yml文件中添加安装脚本js代码:
1
| <script async src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>
|
再修改D:\Blog\themes\fexoer\layout_partial目录下的article.ejs文件代码炜:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
| <header class="article-header">
........
<% if (theme.busuanzi){ %> <i class="fa fa-eye"></i> <span id="busuanzi_container_page_pv">  热度 <span id="busuanzi_value_page_pv"> <i class="fa fa-spinner fa-spin"></i></span>℃ </span> <% } %>
........
</div> </header>
|
v1.5.2