本地安装
1
   | pkg update && pkg upgrade -y
   | 
1
   | pkg install nodejs-lts vim git  -y
   | 
1
   | npm config set registry http://registry.npm.taobao.org
   | 
1 2 3
   | hexo init blog cd blog npm install
   | 
注:此时的blog文件夹里存放的就是hexo博客系统的核心文件,以后你的文章创作和主题配置都要在此目录下完成,(此时的文件夹可以任意取名,不是非要叫blog)
正常启动之后,在浏览器输入:http://localhost:4000/ 这时候就能看到我们已经搭好的Hexo博客了!
部署到github
首先你需要先在github建一个仓库,名为 username.github.io, username就是你的github用户名,接着安装openssh:
1 2
   | git config --global user.name "yourname" git config --global user.email "youremail"
   | 
这里的yourname输入你的GitHub用户名,youremail输入你注册GitHub用的邮箱。
创建ssh:
1
   | ssh-keygen -t rsa -C "youremail"
   | 
1
   | cat /data/data/com.termux/files/home/.ssh/id_rsa.pub
   | 
此时显示的就是就是一个ssh秘钥,在github首页上,点击自己的头像,点击下面的setting,再找到_SSH and GPG keys_,添加ssh key。
如果出现yes&no的问题,选yes即可,当看到:
Hi username You've successfully authenticated, but GitHub does not provide shell access.
就代表已经成功了!
- 接着在blog目录下找到_config.yml,翻到最后,修改为:
 
1 2 3 4 5 6
   |       deploy:       type: git       repo: git@github.com:username/username.github.io.git       branch: master
 
  | 
- 再在blog目录下安装一个插件,来完成推送到github的事:
 
1
   | npm install hexo-deployer-git --save
   | 
你就可以在 https://username.github.io/ 看到自己的网站了!
常用命令:
1 2 3 4 5 6 7 8
   | hexo help   hexo clean   hexo new "name"  hexo new page "name"  hexo g  hexo s    hexo d   hexo g -d  
   | 
域名绑定
在任意网站购得域名,然后登录GitHub,进入之前创建的仓库,点击settings,设置Custom domain,输入你所购的域名,然后在你创建的博客文件夹blog下的source目录中创建一个名为CNAME文件,不要后缀。写上你的域名。