美文网首页
Hexo + Github 搭建自己的博客网站(专属域名)

Hexo + Github 搭建自己的博客网站(专属域名)

作者: 页面仔小杨 | 来源:发表于2017-10-26 13:13 被阅读0次

Hexo + Github 搭建自己的博客网站


Hexo 官方文档

阿里云域名购买

一、Hexo 创建 博客

1.安装Hexo

$ npm install -g hexo-cli

2.Hexo init 项目

$ cd 项目目录(blog)

$ hexo init

$ npm install

$ hexo generate 或 hexo g

$ hexo server 或 hexo s

在浏览器输入

http://localhost:4000/

恭喜你博客搭建成功了!

二、github pages

1.登录你的github账号 创建一个新的仓库

倘若你对github还不熟悉,建议你暂停搭建博客。先学习常用的git操作命令

2.仓库的名字 = 你注册的昵称 + github.io

3.将项目目录的public代码push至仓库中

$ cd 项目目录(blog)/public

$ git init

$ git add -A

$ git commit -m 'init blog'

$ git remote add origin https://github.com/itxing666/itxing666.github.io.git

$ git push -u origin master

4.push 成功后看看你的线上博客

在浏览器输入

https://itxing666.github.io/

三、打造专属域名

1.购买域名 

去购买牛逼的域名

2.登录万网管理控制台

未实名认证的域名要进行实名认证

3.点击 解析 进入解析页面

获取记录值

$ ping itxing666.github.io

解析页面添加 获取的记录值

3.CNAME

在public目录下创建CNAME文件

$ cd public

$ touch CNAME

$ vim CNAME

添加域名

将代码push至仓库

$ git status

$ git add -A

$ git commit -m 'add CNAME'

$ git push

在浏览器输入itxing.net 查看你的博客

itxing.net

四、更换主题

目前使用人数最多的为next主题

$ cd 项目目录(blog)

$ git clone https://github.com/iissnan/hexo-theme-next themes/next

$ vim _config.yml

本地查看效果

$ cd 项目目录(blog)

$ hexo g

$ hexo s

将代码push至仓库

$ cd public

$ git status

$ git add -A

$ git commit -m 'replace theme'

$ git push

查看itxing.net的变化

感觉不错就赞一下

相关文章

网友评论

      本文标题:Hexo + Github 搭建自己的博客网站(专属域名)

      本文链接:https://www.haomeiwen.com/subject/mvbhpxtx.html