007-使用hexo制作博客

关于博客

  • 使用Hexo搭建自己的博客
  • 首先你必须要有github账号(因为我们使用了免费的gitpage服务)
  • 环境安装
    • 安装homebrew
    • 安装git
    • 安装node.js
    • 安装Hexo
    • 当然以上你都可以通过homebrew安装
  • 安装
    • 安装homebrew
    • 安装nodejs brew install node
    • 安装hexo npm install -g hexo-cli

1 启动博客

1
hexo server -p 4400
  • 浏览 http://localhost:4400/ 就看到了!这里我使用端口 4400 (-p 4400),因为端口 4000 被其他程序占用

2 准备写博客

  • 1 参考 https://hexo.io/zh-cn/docs/configuration.html 进行配置。我只修改了 /hexo/_config.yml 里面很少的配置 (title description author url permalink 等, 其中的 language: default 临时解决不设置language导致缺省语言错误)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
# Site
title: viviwong's Blog
subtitle:
description: viviwong's Blog collection TECH
author: viviwong
language: en
timezone:

# URL
## If your site is put in a subdirectory, set url as 'http://yoursite.com/child' and root as '/child/'
url: http://viviwong.github.io
root: /
permalink: Blog/:year:month:day:title.html
permalink_defaults:
  • 2 开始写博文:
1
hexo new 001-item2使用快捷键

Hexo会在/hexo-dir/source/_posts 目录下创建 001-item2使用快捷键.md

  • 3 本地查看博客效果
1
hexo g; hexo s -p 4400

浏览 http://localhost:4400/

3 分类和标签

1
2
3
4
5
6
配置分类
---
title: categories
date: 2017-11-14 22:14:11
type: categories
---
1
2
3
4
5
6
配置标签
---
title: TagCloud
date: 2017-11-14 21:44:33
type: tags
---
  • 博文中直接添加
1
2
3
4
title: 005-第一性原理--黄晓杰
date: 2018-03-05 21:30:03
tags: 学习
categories: 得到

4 博客通过github发布

  • 调试
1
2
3
hexo clean
hexo g
hexo s --debug
  • 确认无误后上传发布
1
2
3
hexo clean
hexo g
hexo d

5 HEXO采用命令

1
2
3
4
5
6
7
hexo init       //在指定目录执行该命令,会将当前目录初始化为hexo站点,生成hexo站点所需的一切文件
hexo new “my new blog title” //新建一篇文章。如果没有设置 layout 的话,默认使用 _config.yml 中的 default_layout 参数代替。如果标题包含空格的话,请使用引号括起来。
hexo s --debug // 启动本地hexo 服务器,默认localhost:4000可以访问
hexo clean // 清除缓存,如果对本地文件做了修改,同步到远程验证修改的效果之前,先clean,清除缓存
hexo generate // 可以简写成hexo g 根据markdown文件生成静态文件
hexo deploy // 或者简写成hexo d 将本地修改,部署到远端
hexo version // 显示hexo版本
坚持原创技术分享,您的支持将鼓励我继续创作!