使用Hexo建立独立博客

Hexo介绍

Hexo是一个快速、简洁且高效的博客框架。
Hexo使用Markdown来编写文章,通过Hexo生成静态网页,然后部署到服务器上。

安装 NodeJS

curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.30.1/install.sh | bash
nvm install 4

或者到Nodejs官网直接下载安装

https://nodejs.org/en/

安装 Hexo

npm install hexo-cli -g

初始化工作

hexo init blog
cd blog
npm install
hexo server

部署到Gitcafe

创建账号

https://gitcafe.com/

创建项目

建议一个跟用户名相同的项目

https://gitcafe.com/GitCafe/Help/wiki/Pages-%E7%9B%B8%E5%85%B3%E5%B8%AE%E5%8A%A9

添加ssh key

使用ssh-keygen 生成 ssh key

ssh-keygen -t rsa -C "your name"

ssh-keygen生成时会询问输入文件名,这个直接回车按默认的来,
密码按自己的需要设置一下。

这样默认会在本地的~/.ssh目录下生成id_rsa,id_rsa.pub两个文件,
id_rsa是私钥,id_rsa.pub是公钥。

cat ~/.ssh/id_rsa.pub

把里面的内容拷贝到gitcafe的ssh keys设置中

使用Hexo建立独立博客_第1张图片
gitcafe-sshkey.jpg

安装部署插件

npm install hexo-deployer-git --save

配置hexo

打开_config.yml, 修改deploy模块

deploy:
- type: git
  repo: [email protected]:xxxx/xxxx.git
  branch: gitcafe-pages

注意: 以上冒号后面必须都要有一个空格

开始部署

hexo d  -g

部署成功后,通过http://xxxx.gitcafe.io访问你的网站
xxxx是你gitcafe的用户名

写作命令

  • 建立新文章:hexo n "新文章名"
  • 预览文章:hexo s
  • 生成网页:hexo g
  • 发布文章:hexo d
  • 生成网页并发布文章:hexo d -g

你可能感兴趣的:(使用Hexo建立独立博客)