HEXO搭建个人博客

我们搭建的前提是你有一个github账号(现在默认有喽),跟着步骤走吧,下面以我自己的博客为例(记得改为自己的账号)

1. $ sudo npm install hexo -g 安装博客搭建环境hexo

2. $ git clone https://github.com/Jasonellen/Jasonellen.github.io.git到本地

3. $ cd Jasonellen.github.io仓库

4. $ hexo init 初始化文件夹

5. 初始化OK可以用$ hexo server开启服务器查看个人搭建的博客

6. 进入_config.xml 修改个人相关信息

title: 奋斗蚁🐜
subtitle: 前端拼搏中的小小蚁🐜
description:
author: Jasonellen

7. $ npm install hexo-deployer-git --save

8. 同步到github账号

_config.xml拉倒最底部修改文件
deploy:
      type: git
      repo: https://github.com/Jasonellen/Jasonellen.github.io.git

9. 写博客

  • $ hexo new 论天气

    新建文件,对应生成到source下面的.MD文件,可以用markdown编写,Markdown简易语法教程请查看我上一篇的博客
    
  • hexo g

    编译生成对应的html文件
    
  • hexo server 预览

    开启服务器,本地预览写好的文章
    
  • hexo d 发布

    同步到github账号
    

10. 博客Markdown css样式修改

样式修改的地址是 themes--languages--source--css
如果博客打开后台有jq引入报错是因为默认引入的是谷歌CDN文件不稳定,可以修改为其他在线jquery文件即可,修改路径为themes--landscape-layout-_partial-after-footer.ejs

11. 添加评论系统--这里用的是多说评论

  • 进入多说官网
  • 点击我要安装
  • 填完注册信息(记得有一个多说域名 xxx.duosho.com)自己写的xxx要记得后面会用到
  • 注册完会生成一段html代码如下(就是通用代码)
  • 进入前面的配置文件_config.xml,找个空白地新增 duoshuo_shortname: 上面注册时用的xxx
  • 进入themes\landscape\layout_partial\article.ejs
1
2
3
4
5
6
7
8
把最后一段这个代码
<% if (!index && post.comments && config.disqus_shortname){ %>
<section id="comments">
<div id="disqus_thread">
<noscript>Please enable JavaScript to view the <a href="//disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
</div>
</section>
<% } %>
1
2
3
'换成上面注册信息后生成的通用代码,然后把多说评论start全部替换为下面这段
<!-- 多说评论框 start -->
<div class="ds-thread" data-thread-key="<%= post.layout %>-<%= post.slug %>" data-title="<%= post.title %>" data-url="<%= page.permalink %>"></div>

OVER 喜欢就点个赞吧