HEXO安装(以aircloud模板为例)
安装
新建文件夹,准备在该文件夹内安装HEXO1
2
3
4
5npm 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 进行自定义配置
碰到的问题及解决方法
安装最新nodejs
1
2
3
4
5sudo 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 stablenpm install安装过程中如有报错
1
2npm config set user 0
npm config set unsafe-perm true
GITHUB
- 注册帐号
- 新建代码库 New repository,在Repository name下填写yourname.github.io
- Setting–GitHub Pages
- 在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"
关联
重新设置远程地址
- git remote remove origin 删除当前远程地址
- 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两个文件,重新上面拷贝
上传及部署
- hexo new post “article title” //生成一篇文章《article title》
- hexo g // 生成,生成public文件夹
- hexo d // 部署,2-3可以联合成一条命令 hexo d -g
- 部署成功后访问 你的地址,https://yourName.github.io,可以看到文章
碰到的问题
- 无法生成index.html
根据log安装缺失的包,比如 npm install hexo-generator-archive –save - 文章中添加图片
确认_config.yml中有post_asset_folder:true,在每次生成文件的时候会生成同名文件夹,保存图片
文件中使用引用图片