使用hexo和github pages搭建个人博客

稀土 2018-03-31

1. 创建Github 域名和空间

1.1注册

注册一个Github账号

1.2 创建仓库

记住Respository name 中的username.github.io 的username 一定与前面的Owner 一致。

2. 安装

  1. 安装Git

  1. 安装Nodej

  1. 安装Hexo(时间可能有点长,不要急)
    以上所有都安装完成之后再安装Hexo
    $ sudo npm install hexo-cli -g

3. 编写,发布

创建博客
$ hexo init username.github.io

更改配置

主题安装

为了使博客不太难看,我们需要安装一个主题,切换至刚刚生成的Hexo 目录,安装主题

$ cd username.github.io

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

基础配置:打开文件位置username.github.io/_config.yml修改几个键值对, 注意配置的键值之间一定要有空格。更多设置...

title: 沐雪的小小世界 //你博客的名字

author: 沐雪 //你的名字

language: zh-Hans //语言 中文

theme: next //刚刚安装的主题名称

deploy:

type: git //使用Git 发布

repo: https://github.com/username/username.github.io.git

主题配置:

主题配置文件在username.github.io/themes/next/_config.yml中修改,这里略过。

写文章

在username.github.io/source/_posts下创建一个名为FirstBlog.md的文件,随便写点,比如“Hello World”。

测试

$ hexo s

测试服务启动,在浏览器中输入https://localhost:4000就可以访问了。

安装hexo-deployer-git自动部署发布工具

$ npm install hexo-deployer-git --save

发布

$ hexo clean

$hexo g

$hexo d

其他的就看官方文档吧

相关推荐

JingLisen / 0评论 2020-01-06