我是跨考计算机研究生的复合型学渣一枚,接触考研之前还没学高等数学。现在研一入学没多久,感觉自己很健忘,于是乎决定开始写点东西,记录自己的学习历程,并且想跟大家多多讨论,希望大家多多指教。今天用Hexo+github搭建了个博客,并把全程都记录了下来。
node.js安装
下载安装 node.js(https://nodejs.org/en/) 如下图,选择左边的8.12.0LTS版
注:①安装途中可以自定义安装地址
②安装时会默认ADD to PATH,直接下一步即可
测试安装情况
首先用Win+R调出运行窗口,然后输入cmd打开cmd窗口
输入
$ node-v
安装git
官网下载git(https://gitforwindows.org/)
除了下面两步改一下,其它都是Next
这里左下角打勾,然后NEXT
这里选择第二项,然后Next
github SSH配置(与github关联)
找到git安装目录,打开git-bash,然后输入
$ ssh-keygen –t rsa –C “邮箱号(GitHub账号)”
然后一直回车,就会生成id_ras文件(记住地址,后面要打开)
打开GitHub,选择Settings,New SSH key
** 记事本打开刚刚生成的.ssh文件下的id_ras文件,复制到Key栏**
接着打开git,测试连接是否成功
$ ssh -T git@github.com
如果提示Hi sysuleo You’ve successfully authenticated, but GitHub does not provide shell access.说明连接成功。
hexo安装
首先,我在E盘新建了个Myblog文件夹,然后打开cmd窗口,cd到Myblog文件夹,然后输入
$ npm install -g cnpm --registry=https://registry.npm.taobao.org
$ npm install -g hexo-cli
$ hexo init liuwBlog(后面是你的博客名)
安装依赖
cd 到博客目录,然后输入
$ npm install
$ hexo s –p 5555
然后在浏览器输入(http://localhost:5555) 就是我们的博客初始界面
发布到github
在Github上创建名字为.github.io的repository。请务必注意该repo的名字,必须保持格式 username.github.io,其中 username替换成你的github账户名,这里创建的repo为sysuleo.github.io
打开本地的MyBlog文件夹项目内的_config.yml配置文件
$ deploy :
type: git
repository: https://github.com/sysuleo/sysuleo.github.io.git
branch: master
然后依次运行
$ npm install hexo-deployer-git –save
$ hexo d
$ git config --global user.email "you@example.com"
$ git config --global user.name "(github名)"
$ hexo d
输入用户名密码
然后输入在浏览器输入sysuleo.github.io出来博客页面就成功了