hexo搭建个人博客(基础)

准备工作:github账号(下面的nameemailgithub账号的)、安装gitnode.js

1、设置Gituser nameemail(如果是第一次的话)

$ git config –global user.name “cf9909”

$ git config -global user.email [email protected]

 

2、由于你的本地Git仓库和GitHub仓库之间的传输是通过SSH加密的,所以我们需要配置验证信息:

使用以下命令生成SSH Key$ ssh-keygen -t rsa -C [email protected]

之后会要求确认路径和输入密码,我们这使用默认的一路回车就行。成功的话会在~/下生成.ssh文件夹,进去,打开 id_rsa.pub,复制里面的 key

回到 github 上,进入 Account => Settings(账户配置)。

左边选择 SSH and GPG keys,然后点击 New SSH key 按钮,title 设置标题,可以随便填,粘贴在你电脑上生成的 key

验证是否成功:$ ssh -T [email protected]

 

3New repositorycf9909.github.io

 

4npm install hexo -g,安装Hexo

hexo -v,检查hexo是否安装成功

 

5、进入文件夹(例如D:\hexo\MyBlog)

hexo init,初始化该文件夹

npm install,安装所需要的组件

hexo s,开启服务器,访问该网址,正式体验Hexo

 

6、配置Deployment,在其文件夹中,找到_config.yml文件,修改repo

deploy:

  type: git

  repository: [email protected]:cf9909/cf9909.github.io.git

  branch: master

 

7、在生成以及部署文章之前,需要安装一个扩展:npm install hexo-deployer-git --save

使用编辑器(D:\hexo\MyBlog\source\_posts)编好文章,那么就可以使用命令:hexo g -d,生成以及部署了

 

8、github pages绑定域名

a)将你在Github上创建的Github Pages的域名 cf9909.github.io进行查询,得到一个IP地址[185.199.111.153](可以ping cf9909.github.io)获知。绑定到购买的域名上。

b)在Github的cf9909.github.io项目,进入【Settings】标签页,在【Custom domain】功能中,将刚刚申请的域名写进去。

 

猜你喜欢

转载自blog.csdn.net/qq_40333952/article/details/81781645