本文最后更新于:2020-06-02 19:48
本教程基于腾讯云的Ubuntu 18.04 64位
安装Node.js
1 2
| curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash - sudo apt-get install nodejs
|
安装完成后输入
若能提示版本则安装成功
更换国内源
1 2
| npm config set registry https: npm config get registry
|
如果更换了国内源则不用安装 cnpm
安装cnpm
1
| sudo npm install -g cnpm --registry=https://registry.npm.taobao.org
|
安装hexo
1
| sudo cnpm install -g hexo
|
安装Git
有些系统已经预装,可先用git --version确认
1 2 3
| sudo add-apt-repository ppa:git-core/ppa sudo apt-get update sudo apt-get install git
|
安装完成后输入
若能提示版本则安装成功
初始化hexo
1 2 3 4 5
| mkdir hexo cd hexo hexo init cnpm install hexo --save cnpm install hexo-deployer-git --save
|
本地编译预览
1
| hexo clean && hexo g && hexo s
|
Ubuntu 14可能出现没有hexo s命令
这时需执行
1
| sudo cnpm install hexo-server --save
|
然后用hexo clean && hexo g && hexo server命令
打开127.0.0.1:4000即可访问网页
编译发布
在hexo目录下的_config.yml最下面添加
1 2 3 4
| deploy: type: git repo: https://gitee.com/jupitersh/jupitersh.git branch: master
|
请将repo中的地址改为你码云的地址
Git 全局设置:
发布前请先全局设置Git
1 2
| git config --global user.name "辣椒小皇纸" git config --global user.email "arxhd.love@qq.com"
|
请将user.name和user.email的内容执行替换成您的码云用户名和邮箱
发布代码
1
| hexo clean && hexo g && hexo d
|
需输入码云的账号和密码