Hexo Quick Start

1. 安装hexo

1
sudo npm install -g hexo

目录结构

  • node_modules:是依赖包
  • public:存放的是生成的页面
  • scaffolds:命令生成文章等的模板
  • source:用命令创建的各种文章
  • themes:主题
  • _config.yml:整个博客的配置
  • db.json:source解析所得到的
  • package.json:项目所需模块项目的配置信息

2. 初始化

1
2
3
hexo init
hexo install
hexo s

此时打开http://localhost:4000可以看到静态页

3. 关联github

gitbash连接

1
2
3
git config --global user.name "用户名"
git config --global user.email "邮箱"
ssh-keygen -t rsa -C"邮箱"

找到ssh key

1
2
cd ~/.ssh
cat id_rsa.pub

将这段配置到github上后,检查一下是否配置成功

1
ssh -T git@github.com

创建项目名为:用户名.github.io
在/blog下配置

1
vim _config.yml

1
2
3
4
deploy:
type: git
repo: https://github.com/用户名/用户名.github.io
branch: master

退出保存

1
2
3
hexo clean
hexo g
hexo d

hexo d时提示ERROR Deployer not found:git

解决方法:
npm install –save hexo-deployer-git

4. 配置主题

这边使用了yilia

安装

1
git clone https://github.com/litten/hexo-theme-yilia.git themes/yilia

配置

  • 修改hexo根目录下的 _config.ymltheme: yilia

  • 配置yilia文件下的_config.yml

配置头像时出现了头像不能展示的问题

解决方法:

  • layout/_partial/left-col.ejs将第六行修改成如下形式:

    1
    <img src="<%=theme.root%><%=theme.avatar%>" class="js-avatar">
  • 将头像文件放在theme/source/img目录下,修改yilia的配置文件
    avatar: img/myicon.jpg