Git+Github+hexo创建个人博客

首先你要有自己的GitHub账号(可以自己去官网申请)

第一步:新建仓库
Git+Github+hexo创建个人博客
Git+Github+hexo创建个人博客
Git+Github+hexo创建个人博客

安装Git

程序猿应该基本都会用git了,不会的建议参考本人git学习笔记:笔记一笔记二笔记三笔记四笔记五

建立新的Repository,仓库名为【your_user_name.github.io】
后续想要把网站部署到Github上,需要在【your_user_name.github.io】此仓库下的Setting配置中添加一个Deploy keys

生成与添加ssh key

1:打开终端(邮箱是你申请github用的邮箱)

$ ssh-****** -t rsa -b 4096 -C "[email protected]"

然后一路按Enter就可以了
2:添加ssh key到ssh agent

$ eval "$(ssh-agent -s)"
$ ssh-add ~/.ssh/id_rsa

3:添加到github

$ sudo apt-get install xclip
$ xclip -sel clip < ~/.ssh/id_rsa.pub

或者:

$ cd .ssh
$ vim id_rsa.pub

将里边的内容粘贴到
Git+Github+hexo创建个人博客
Git+Github+hexo创建个人博客

安装nodejs,npm(如果没有安装的话)

$ sudo apt-get install nodejs

$ sudo apt-get install npm

可以用

   $ nodejs --version
   $ npm --version

查看是否安装成功

安装hexo

 # 使用npm安装Hexo
$ npm install -g hexo-cli

#初始化Hexo
$ hexo init

#生成静态页面
$ hexo generate

#启动本地服务,浏览器访问:http://localhost:4000
$ hexo server

#配置Hexo的_config.yml
deploy:
     type: git
     repo:https://github.com/myloveyy/test.github.io.git
     branch:master

#要提交到Github上需要安装hexo-deployer-git插件 
$ npm install hexo-deployer-git --save

#部署网站到Github上
$ hexo deploy

然后点击github你建的那个仓库settings下的 github pages下生成的网址就能看见你个人的博客页面了
Git+Github+hexo创建个人博客

部署

每次部署的步骤,可按以下三步来进行。

hexo clean
hexo generate
hexo deploy