Hexo个人博客的搭建
Hexo搭建的博客简单易操作,写下安装步骤希望对大家有帮助。
1.首先安装git
找到适合自己的版本进行安装,在命令行(cmd)中输入
$ git --version //有返回代表安装成功。
2.安装node.js
hexo是基于node.js的。
(如果Hexo没有安装到C盘,需要配置环境变量)。
3.注册好github账号
然后点击右上角 new repository 将Repository name设置你的用户名.github.io
例如:我的用户名是z12345那么就设置成: z12345.github.io其余默认即可。
进入新建的z12345.github.io这个repository中点击Settings一直向下滑直到
Theme Chooser点击Choose a theme选择一个自己喜欢的主题。
4.检查是否安装SSH KEY
打开git bash 输入cd .ssh显示No such file or directory则没有设置。
首先在git bash 中输入
$ ssh-keygen -t rsa -C "填写邮箱" #回车
Enter file in which to save the key (/c/Users/xxxx_000/.ssh/id_rsa): #直接回车
Enter passphrase (empty for no passphrase): #输入密码(可以为空)
Enter same passphrase again: #确认密码(可以为空)
生成SSH KEY完毕,登录github点自己头像的小三角形进入Settings有一栏点击SSH and GPG keys新创一个SSH key。名字任意填,ssh key在C:/User/你的用户名/.ssh 用文本编辑器打开id_rsa.pub文件Ctrl+a Ctrl+v复制到github上保存即可。
5.安装Hexo
任意盘创建一个文件夹用于存放你的博客,例如我的MyBlog。进入MyBlog右键点击git bash here。
如果没有vpn先将库调整成淘宝的库
$ npm config set registry https://registry.npm.taobao.org
安装hexo
$ npm install -g hexo-cli
初始化hexo
$ hexo init hexo
配置hexo:进入hexo目录用编辑软件打开_config.yml编辑最后的deploy:
deploy:
type: git
repository: https://github.com/你的Github用户名/你的Github用户名.github.io.git
branch: master
安装hexo-deployer-git插件将代码托管到github。
$ npm install hexo-deployer-git --save
部署到github
$ hexo clean
$ hexo generate # hexo g #皆可
$ hexo deploy # hexo d #皆可
部署成功显示
INFO Deploy done:git
6.常用命令
hexo new”postName” # new article
hexo new page”pageName” # new page
hexo generate/hexo g # generate the directory of public
hexo server # 本地服务演示地址localhost:4000
hexo deploy/hexo #部署到github
hexo version #查看Hexo的版本
借鉴文章:http://www.jianshu.com/p/465830080ea9
欢迎交流,博主常年在线