Hexo blog 创建指导手册
Github仓库建站
进入个人github
Your Repositories
Create a new repository
仓库名:wangjstu.github.io
点击创建
cd ~/.ssh
ssh-keygen -t rsa -C "wangjstu@gmail.com" //一路回车
ssh-add id_rsa //添加秘钥
cat id_rsa.pub //输出公钥,并添加到github上
完毕
mkdir wangjstu.github.io && cd wangjstu.github.io
echo "# wangjstu.github.io" >> README.md
git init
git add README.md
git commit -m "first commit"
git remote add origin https://github.com/wangjstu/wangjstu.github.io.git
git push -u origin master
4. 验收
访问 https://wangjstu.github.io
Node.js安装
Hexo安装
执行命令
切换到目录上一级,并执行命令,先将blog文件初始化到一个blog目录。建议先单独放一个目录,后面有用。
hexo g
hexo server
打开浏览器,访问 就可以看到效果
node_modules: 依赖包
public:存放生成的页面
scaffolds:生成文章的一些模板
source:用来存放你的文章
themes:主题
_config.yml: 博客的配置文件
hexo g //生产静态文件
hexo server //启动服务
hexo clean //清除了你之前生成的东西
hexo generate //顾名思义,生成静态文章,可以用 hexo g缩写
hexo deploy //部署文章,可以用hexo d缩写
部署到github
# Deployment
## Docs: https://hexo.io/docs/deployment.html
deploy:
type: 'git'
repo: https://github.com/wangjstu/wangjstu.github.io.git
branch: master
hexo clean
hexo generate
hexo deploy
写文章及提交流程
Hexo主题修改
择主题
按照自己主题的github上或官网文档进行修改
git clone https://github.com/cofess/hexo-theme-pure.git themes/pure
更新主题
cd themes/pure
git pull
打开站点配置文件,找到theme字段,将其值更改为
# vim wangjstu.github.io/_config.yml
theme: pure
安装主题需要的插件
npm install hexo-wordcount --save
npm install hexo-generator-json-content --save
npm install hexo-generator-feed --save
npm install hexo-generator-sitemap --save
npm install hexo-generator-baidu-sitemap --save
npm install hexo-neat --save
主题配置
修改
language: zh-CN
修改
双分支保存源文件
cd wangjstu.github.io
rm -r themes/pure/.git
hexo clean
git add . //一定要确保代码只有源代码文件,其他不要
git stash //将源文件保存到stash
git status //这里检查一定要是干净的没有变化的
git checkout -b Hexo
git stash pop
git commit -m "add Hexo branch to save source file"
git push -u origin Hexo:Hexo
初始化仓库
git clone https://github.com/wangjstu/wangjstu.github.io.git
cd wangjstu.github.io
npm install hexo
npm install hexo-deployer-git --save
安装其他对应主题需要的插件
提交文章
hexo clean
hexo g
hexo d