推荐参考
https://zhuanlan.zhihu.com/p/35668237
http://lijiankun24.com/Mac%E4%B8%8BHexo%E5%92%8CGitHub-Pages%E6%90%AD%E5%BB%BA%E4%B8%AA%E4%BA%BA%E5%8D%9A%E5%AE%A21/
https://blog.youkuaiyun.com/dajian790626/article/details/78595684
安装node.js、npm
安装Git
进入GitHub
1. 新建repository;
2. repository name格式必须为:username.github.io,后缀必须是github.io,username为GitHub用户名;
3. 勾选init with a README;
4. 创建后,settings,GitHub Pages,Source-->master branch,Theme chooser-->第一个默认的;
安装hexo
1. npm install -g hexo
2. hexo -v 验证,若command not found,配置环境变量(~/.bash_profile;hexo的bin,安装日志有输出;)
下载主题
https://github.com/YenYuHsuan/hexo-theme-beantech
1. 按说明(init):
git clone https://github.com/YenYuHsuan/hexo-theme-beantech.git ./hexo-beantech
cd hexo-beantech
npm install
2. 修改根目录下的_config.yml文件,在这里配置各种博客信息,如下做必要的修改:
2.1 文件末尾,deploy部分:
deploy:
type: git
repository: https://github.com/bigsherry/bigsherry.github.io.git
branch: master
2.2 注释# Note: don't forget to modify the CNAME file to your url,所在行,url不合法,发布后GitHub会给你发邮件,改成 http://yoursite.com 类似,不改也不影响使用;
安装发布工具
npm install hexo-deployer-git -save
本地测试
hexo clean
hexo g
hexo s --deploy
按输出提示,访问 http://localhost:4000/,就能看见博客,停止服务使用 Ctrl+C
发布
1. hexo d
2. 发布之后,大概10s左右,会更新
3. 访问 https://bigsherry.github.io
写文章
1. hexo new post "article title",article title为新文章标题;
2. 之后项目根目录/source/_posts目录下,多处一个同名目录和.md文件,前者可放置文章引用图片,后者即markdown文件(Mac版markdown编辑器推荐:https://typora.io/)文章内容引用本地图片(图片view.jpg已放置在同名目录下),语法如下:

3. 写完hexo g; hexo d; 发布即可;
基础自定义格式修改
1. _config.yml能做的修改:title、subtitle、author(影响底部的copyright)、language(简体中文:zh-Hans)、SEOTitle、email、friends标签、社交账号(注释掉即可)等;
2. 图片替换:(我有一个大胆的想法),不用改配置,用同名文件替换;
例如,去掉封面右下角签名:用一个同名空png代替签名图片;
封面图片基本都在:根目录/source/img目录下;
3. 回到top logo:在css目录下;
4. header anchor 'ℬ'符号修改,官网上有,theme目录下,layout/post.ejs;
5. 去掉右上角archive和about链接:删除source目录下的archive和about目录;
hexo博客源码托管
1. 将源码保存在新分支source上:
$ git clone https://github.com/bigsherry/bigsherry.github.io.git
$ cd bigsherry.github.io
$ git checkout -b source
2. 初始化hexo环境(在新建的blog目录下):
$ hexo init blog
$ cd blog
$ npm install
3. 拷贝主题和文章
替换source目录下的全部文件
替换_config.yml文件
将themes/beantech拷贝过来
4. 本地测试
$ hexo g
$ hexo s
5. 提交博客源码(到source分支)
$ git add .
$ git commit -am "create blog"
$ git push origin source
异地搭建hexo博客环境
1. 环境搭建
安装node、npm、git、hexo、hexo-deployer-git
下载博客源码:git clone -b source https://github.com/bigsherry/bigsherry.github.io.git
2. 本地测试
本地预览、同步源码、发布文章、提交更新源码