HEXO安装(以aircloud模板为例)

HEXO中文官方网址 & aircloud模板地址

安装

新建文件夹,准备在该文件夹内安装HEXO

1
2
3
4
5
npm install hexo-cli -g  
git clone https://github.com/aircloud/hexo-aircloud-blog.git --recursive
cd hexo-aircloud-blog
npm install
hexo serve

配置

可以直接修改 _config.yml 进行自定义配置

碰到的问题及解决方法

  1. 安装最新nodejs

    1
    2
    3
    4
    5
    sudo apt update -y  
    sudo apt install -y nodejs nodejs-legacy npm
    sudo npm config set registry https://registry.npm.taobao.org
    sudo npm install n -g
    sudo n stable
  2. npm install安装过程中如有报错

    1
    2
    npm config set user 0  
    npm config set unsafe-perm true

GITHUB

  1. 注册帐号
  2. 新建代码库 New repository,在Repository name下填写yourname.github.io
  3. Setting–GitHub Pages
  4. 在HEXO安装文件夹内
    1
    2
    3
    4
    //配置user.name  
    git config --global user.name "your user name"
    //配置user.email
    git config --global user.email "your user email"

关联

重新设置远程地址

  1. git remote remove origin 删除当前远程地址
  2. git remote add origin git@github.com:账户名/learngit.git 建立自己的远程地址

拷贝id_rsa.pub

打开GitHub的设置Settings–New SSH key,title随便填,内容拷贝id_rsa.pub(~/.ssh/id_rsa.pub)
如果出现问题,ssh-keygen -t rsa -C “xxxx@qq.com“,重新生成id_rsa.pub和id_rsa两个文件,重新上面拷贝

上传及部署

  1. hexo new post “article title” //生成一篇文章《article title》
  2. hexo g // 生成,生成public文件夹
  3. hexo d // 部署,2-3可以联合成一条命令 hexo d -g
  4. 部署成功后访问 你的地址,https://yourName.github.io,可以看到文章

碰到的问题

  1. 无法生成index.html
    根据log安装缺失的包,比如 npm install hexo-generator-archive –save
  2. 文章中添加图片
    确认_config.yml中有post_asset_folder:true,在每次生成文件的时候会生成同名文件夹,保存图片
    文件中使用![logo](本地图片测试/logo.jpg)引用图片