以前写过一篇关于octopress建立我的技术博客的文章,不少朋友说步骤好复杂啊(心塞)!此次,为了知足这群朋友,这里我要教你们的是用Hexo建我的技术博客。html
这一步我不想展开太多,由于真的很简单,关于GIT的配置我在以前的文章中已经提到过了,看官能够查看历史文章git
在桌面下使用GIT Bash输入下面代码,实现Hexo的安装github
$ sudo npm install hexo-cli -g
初始化本身的我的博客shell
使用GIT Bash切换到你但愿安装我的博客的文件夹下npm
$ hexo init username.github.io
username就是Github中的用户名,详细查看hexo
在完成上一步后,其实就能够运行查看页面了,这一步让你实现安装本身喜欢的主题,看官能够在Github网站中输入hexo关键字,能够搜索到不少相关主题,挑选一个就能够了工具
我这里使用NEXT这个主题进行讲解,其余的方式也是同样的。post
使用GIT Bash切换到你刚才我的博客安装目录测试
$ cd username.github.io $ git clone https://github.com/iissnan/hexo-theme-next themes/next
完成上面步骤,会在theme的目录下多了一个next文件,说明主题下载成功了,但如今尚未配置完成网站
在username.github.io文件下有一个_config.yml文件,编辑它
将theme的value设为本身的主题名,这里是next——完成主题的配置
将deploy的value进行配置——完成主题发布地址配置
# Extensions ## Plugins: https://hexo.io/plugins/ ## Themes: https://hexo.io/themes/ theme: next # Deployment ## Docs: https://hexo.io/docs/deployment.html deploy: type: git repo: git@github.com:username/username.github.io.git branch: master
在username.github.io/source/_posts目录下建立你本身的文章,文章格式为Markdown的.md格式
--- title: Hexo让博客梦变的简单 date: 2016-05-12 ---
title:文章名,date:发布的日期
安装自动部署发布工具
使用GIT Bash切换到username.github.io目录下
$ npm install hexo-deployer-git --save
编译
$ hexo generate
本地测试
$ hexo s -p 4000
-p:设置端口号,默认为4000,使用默认端口能够省略
发布到Github
首先在username.github.io文件下有一个_config.yml文件,编辑它
有一个depoly的key,对其进行配置,repo为你在github中生成的username.github.io工程的clone地址,branch就是的分支名称,就写master就好了
# Deployment ## Docs: https://hexo.io/docs/deployment.html deploy: type: git repo: git@github.com:username/username.github.io.git branch: master
username.github.io目录下,在编译完成后,执行以下命令,就会将编译生成的文件部署到github上,经过username.github.io的地址就能够访问了(本文章中的因此username都是你github的用户名)
$ hexo d
这里特别要提醒一下不要忘记在username.github.io文件下_config.yml文件,配置deploy
咱们经常可能会遇到系统重装或者换电脑编辑的场景,备份变得尤其重要,这里介绍一个hexo-git-backup备份工具
你们能够根据本身的实际状况,参照README.md说明进行配置
操做步骤1,2
将Github的备份clone到本地
$ git@github.com:username/username.github.io.git $ git checkout branchname
branchname:备份分支名
以上です(Ending)
ありがどう(Thank You)