hexoblog

hexo 博客在windows 10下快速搭建步骤:

0x1 安装tortoisegit。

1.1 新建Repository yourname.github.io。
1.2 开通 page 服务。
1.3 本地新建index.html(hello world) push到username.github.io



 
    yourname's Blog
 
 
   

Hello World

I'm hosted with GitHub Paes

1.4 访问yourname.github.io 可以看到helloworld。

0x2 安装nodejs

2.1 http://nodejs.org 下载安装文件,点击安装。
2.2 配置npm的全局模块的存放路径以及cache的路:

$ npm config set prefix "C:\Program Files\nodejs\node_global" 
$ npm config set cache "C:\Program Files\nodejs\node_cache" 

2.3 设置环境变量 NODEPATH=C:\Program Files\nodejs\node_global
2.4 设置淘宝源

npm config set registry https://registry.npm.taobao.org 

2.5 淘宝镜像安装

$ cnpm install   

0x3 安装hexo

3.1 新建一个hexo目录,不带中文,不带空格。
3.2 打开git bash,cd到hexo。

方法A 使用默认源安装

    $ npm install hexo-cli -g 
    $ npm install hexo --save

方法B 如果未设置淘宝源,则安装hexo时单独指定淘宝源

 $ npm install -g hexo-cli --registry=https://registry.npm.taobao.org 
 $ npm install hexo --save

3.3 查看本地hexo是否安装正确

$ hexo -v
$ hexo init //如果出错忽略,直接输入下一步命令会自动安装需要的组件。
$ hexo g
$ hexo s //浏览器打开  http://localhost:4000/

0x4 修改hexo主题

在https://hexo.io/themes/ 查找中意的theme项目, 点进去找到 github项目,
之后按照theme 提示安装。
示例安装 https://github.com/chaooo/hexo-theme-BlueLake

$ git clone https://github.com/chaooo/hexo-theme-BlueLake.git themes/BlueLake 

0x5 安装完成后分别执行

  $ hexo clean
  $ hexo g
  $ hexo d
  $ hexo s //浏览器打开  http://localhost:4000/ 已经是新主题了

0x6 配置Deployment

6.1 git bash配置身份信息:

 $ git config --global user.name "yourname"
 $ git config --global user.email "youremail" 

6.2 在_config.yml文件中,找到Deployment,然后按照如下修改:

     deploy:
       type: git
       repo: [email protected]:yourname/yourname.github.io.git
     branch: master

上面的四个:对齐且type: repo: branch: 后面有空格.
6.3 安装所需插件

$ npm install hexo-deployer-git --save

6.4 发布项目

$ hexo d //出现错误信息则说明git bash没有配置ssh。

0x7 配置ssh

7.1 在gitbash中执行ssh-keygen

$ ssh-keygen -t rsa -C "[email protected]"   

7.2 打开 C:\Users\username.ssh\id_rsa.pub,复制字符串。
7.3 登录http://github.com 。点击右上角用户图片右边小三角,打开Settings。

hexoblog_第1张图片
github setting

7.4 右边菜单点击"SSH and GPG keys"->New SSH key->title文本框输入文字,key文本框右键粘贴->保存。


hexoblog_第2张图片
SH GPG keys

0x8 发布项目

$ hexo d //github 已更新,在ie中打开 yourname.github.io。
$ hexo d -g //如果服务端页面未更新的时候,加-g命令。

你可能感兴趣的:(hexoblog)