title: GitHub+hexo to Blog
date: 2014-12-26 09:44:53
tags: hexo, github
---css
一直想要一个本身的博客,不过一直怯于对网站开发一一窍不通,因此终究仍是没有去搭建本身的博客,而是选择展转于CSDN和博客园之间。最近看到了MarkDown,了解到写文章、写博客原来能够换种方式。而后又在学习IOS开发,因而在GitHub上爬各类开源的IOS项目,期间发现了不少前辈写的IOS博客,由此又想到本身没有的悲哀。因而乎,做为半吊子程序员的我,想当技术程序员的我,发现有些博客的地址有github
这一url
字段,因而抱着试试的态度在某度输入了GitHub 搭建博客
。而后就发现了GouHub真的能够用来搭建博客,本着探索研究的精神,看了几篇使用GitHub搭建博客的文章,而后就发现了Github+hexo
,发现了hexo还支持MarkDown,因此那个使用GitHub和hexo搭建博客
便给了我行动的力量。由于昨天在俺的小租房的mac上成功搭建了一个博客,可是没有记录过程,今天复习记录下,顺便一步一步在windows下搭建一个本身的博客,看看运气咋样。html
下载GitHub的Windows客户端,配置GitHub,包括用户名密码以及把本机的ssh-key复制到GitHub里面去node
#### 配置GitHub帐户信息 #### git config --global user.name "username" git config --global user.email "email" #### 添加SSH-KEY #### #这一步是为了省去每次部署代码时须要输入帐户密码。检查是否已经有SSH Key。 $cd ~/.ssh #若是说没有这个目录,就直接看第三步 #备份 #生成一个新的SSH。 $ssh-keygen -t rsa -C "email" # 以后直接回车,不用填写东西。以后会让你输入密码。而后就生成一个目录.ssh ,里面有两个文件:id_rsa , id_rsa.pub # 把这个SSH放到github上。用公钥。先在GitHub上注册一个用户,而后进入account-setting ,把id_rsa.pub的内容复制进去就能够了。 # 而后把id_rsa.pub里的内容复制进去就能够了。 # 测试OK。输入命令: $ssh -vT git@github.com
node.js
安装包,直接点击安装便可,安装时默认会安装npm软件的,该软件能够用来安装hexo
.(mac下直接在命令行使用brew install node.js
便可安装)安装、初始化、测试hexogit
#安装 C:\Users\Administrator>npm install -g hexo npm WARN optional dep failed, continuing fsevents@0.2.0 C:\Users\Administrator\AppData\Roaming\npm\hexo -> C:\Users\Administrator\AppData\Roaming\npm\node_m odules\hexo\bin\hexo hexo@2.8.3 C:\Users\Administrator\AppData\Roaming\npm\node_modules\hexo ├── hexo-front-matter@0.0.4 ├── strip-indent@0.1.3 ├── minimist@0.2.0 ├── sprintf-js@0.0.7 ├── graceful-fs@3.0.5 ├── colors@0.6.2 ├── mime@1.2.11 ├── async@0.9.0 ├── lodash@2.4.1 ├── highlight.js@8.1.0 ├── moment@2.8.4 ├── warehouse@0.2.2 (async@0.7.0) ├── chokidar@0.8.2 (recursive-readdir@0.0.2) ├── morgan@1.5.0 (basic-auth@1.0.0, depd@1.0.0, on-finished@2.1.1, debug@2.1.0) ├── connect@3.3.3 (utils-merge@1.0.0, parseurl@1.3.0, debug@2.1.0, finalhandler@0.3.2) ├── compression@1.2.2 (bytes@1.0.0, vary@1.0.0, on-headers@1.0.0, compressible@2.0.1, debug@2.1.0 , accepts@1.1.4) ├── serve-static@1.7.1 (utils-merge@1.0.0, escape-html@1.0.1, parseurl@1.3.0, send@0.10.1) ├── js-yaml@3.2.4 (esprima@1.0.4, argparse@0.1.16) ├── cheerio@0.17.0 (entities@1.1.1, dom-serializer@0.0.1, CSSselect@0.4.1, htmlparser2@3.7.3) └── swig@1.4.1 (optimist@0.6.1, uglify-js@2.4.16) C:\Users\Administrator\blog>npm install hexo-renderer-ejs@0.1.0 node_modules\hexo-renderer-ejs ├── ejs@1.0.0 └── lodash@2.4.1 hexo-renderer-marked@0.1.0 node_modules\hexo-renderer-marked ├── marked@0.3.2 └── lodash@2.4.1 hexo-renderer-stylus@0.1.0 node_modules\hexo-renderer-stylus ├── nib@1.0.4 (stylus@0.45.1) └── stylus@0.44.0 (css-parse@1.7.0, mkdirp@0.3.5, sax@0.5.8, debug@2.1.0, glob@3.2.11) # 初始化 C:\Users\Administrator\blog>hexo init [info] Copying data [info] You are almost done! Don't forget to run `npm install` before you start blogging with Hexo! # 测试,浏览器访问http://localhost:4000/便可看到网页效果 C:\Users\Administrator\blog>hexo s [info] Hexo is running at http://localhost:4000/. Press Ctrl+C to stop.
使用hexo写博客程序员
C:\Users\Administrator\blog>hexo n "GitHub+hexo to Blog" [info] File created at C:\Users\Administrator\blog\source\_posts\GitHub-hexo-to-Blog.md C:\Users\Administrator\blog>hexo g
hexo部署github
# 编辑_config.yml(在博客目录下)。你在部署时,要把下面的user都换成你的帐号名。 # 最好使用SSH,HTTPS有时出错 deploy: type: github repository: git@github.com:arbboter/arbboter.github.io.git branch: master #执行下列指令便可完成部署。 hexo generate hexo deploy
注意:有些新用户须要设置 ssh,不然上述命令会失败。ssh 的介绍和设置方法请看官方教程,不用担忧,很简单。
记住:每次修改本地文件后,须要hexo generate才能保存。每次使用命令时,都要在H:\hexo目录下。
Okay,咱们的博客已经彻底搭建起来了,在浏览器访问user.github.io就能看到你的成就了!npm