Xiaoshier Blog

hexo 搭建博客 常用命令

使用Hexo搭建博客! 可以查看 documentation
本文就是用搭建博客时自动创建的第一篇博客, 记录一些常用命令, 以便快速查阅.

安装配置 hexo

  1. 安装 Hexo 以及NexT 主题

    1
    2
    3
    4
    5
    6
    7
    npm install hexo-cli -g
    mkdir blog
    cd blog
    hexo init blog
    npm install
    git clone https://github.com/iissnan/hexo-theme-next themes/next
    hexo server
  2. 生成标签, 分类, 归档文件夹

    1
    2
    3
    hexo new page "tag"
    hexo new page "categoris"
    hexo new page "archives"
  3. 分别打开上面生成文件夹中的 index.md 文件
    添加

    1
    2
    3
    4
    5
    ---
    title: tag
    date: 2017-03-28 20:40:03
    type: "tag"
    ---
  4. 修改配置文件 _config.yml 和 themes/next/_config.yml* 文件, 详见

创建发布文章

  1. Create a new post 创建文章
    将文章创建在source/_posts 目录下
    使用hexo generate 时将文章生成在public目录下
    使用hexo deploy 将文章部署到 GitHub

    1
    $ hexo new "My New Post"

    More info: Writing

  2. Run server 本机预览文章

    1
    $ hexo server

    More info: Server

  3. Generate static files 生成文章
    为部署到服务器上而生成 HTML 文件

    1
    $ hexo generate

    More info: Generating

  4. Deploy to remote sites 发布文章
    在配置文件中配置部署到何处

    1
    $ hexo deploy

创建草稿

  1. Create a new draft 创建草稿
    将文件建立在 source/_draft 目录中
    hexo generate 不会生成相应 HTML 文件

    1
    $ hexo new draft "My New Draft"
  2. Run server 本机预览草稿

    1
    $ hexo server --draft
  3. Generate draft 将草稿发布为正式文章

    1
    $ hexo publish "My New Draft"