创建hexo博客

本文记录了在windows7下构建hexo环境的步骤。主要包括安装hexo,创建页面,添加tag页面,更换主题,修改主题,添加评论。目的在于快速构建一个实用,漂亮的blog。

安装hexo

前提条件

  1. 安装Node.js
  2. 安装Git
  3. 创建代码库(https://github.com/username/username.github.io.git)
  4. 删除C:\Users\username.ssh 下所有文件
  5. Generating a new SSH key and adding it to the ssh-agent
  6. Adding a new SSH key to your GitHub account
  7. 本文所有命令都在Git Bash中执行

安装Hexo

1
$ npm install -g hexo-cli

初始化Hexo

1
2
3
4
$ hexo init <folder>
$ cd <folder>
$ npm install hexo-deployer-git --save
$ hexo generate

本地查看效果

1
$ hexo server

启动服务,访问http://localhost:4000 查看效果

发布到github

  1. 修改/_config.yml文件内容

    1
    2
    3
    4
    deploy:
    type: git
    repo: https://github.com/username/username.github.io.git
    branch: master
  2. 发布到github

    1
    $ hexo deploy
  3. 访问https://username.github.io 查看效果

发布新页面到github

  1. 创建页面并发布

    1
    2
    3
    $ hexo new [layout] <title> --创建.md文件
    $ hexo generate --生成静态页面
    $ hexo deploy
  2. 编写内容
    Markdown语法
    Tag Plugins语法

更换主题

  1. 主题列表
  2. 更换成Light主题

添加标签页面

  1. 创建标签一览页面

    1
    hexo new page "tags"
  2. 添加以下内容到source/tags/index.md

    1
    type: "tags"

添加搜索功能

local search

TODO

  1. 修改theme
  2. 添加评论