0%

Hexo

Welcome to Hexo! This is your very first post. Check documentation for more info. If you get any problems when using Hexo, you can find the answer in troubleshooting or you can ask me on GitHub.

写作

创建一篇新文章

1
$hexo new [layout] <title>

[layout] 制定文章的布局:post、page、draft

文章内容

开头标准部分

需要’title’、’categories’、’tags’依次来说明文章标题,分类、标签

1
2
3
4
5
6
7
8
# 例子
---
title: Hexo
categories:
- hexo
tags:
- hexo
---

图片引用

  • 方法一 资源文件夹
    资源(Asset)代表 source 文件夹中除了文章以外的所有文件,例如图片、CSS、JS 文件等。比方说,如果你的Hexo项目中只有少量图片,那最简单的方法就是将它们放在source/images文件夹中。然后通过类似于 ![](/images/image.jpg) 的方法访问它们。

  • 方法二 文章资源文件夹
    对于那些想要更有规律地提供图片和其他资源以及想要将他们的资源分布在各个文章上的人来说,Hexo也提供了更组织化的方式来管理资源。这个稍微有些复杂但是管理资源非常方便的功能可以通过将 config.yml 文件中的 post_asset_folder 选项设为 true 来打开。文章中引用图片的方法{% asset_img 首次请求index.js.png 首次请求index.jsp %}.

    1
    2
    # _config.yml
    post_asset_folder: true

    当资源文件管理功能打开后,Hexo将会在你每一次通过 hexo new [layout] <title> 命令创建新文章时自动创建一个文件夹。这个资源文件夹将会有与这个 markdown 文件一样的名字。将所有与你的文章有关的资源放在这个关联文件夹中之后,你可以通过相对路径来引用它们,这样你就得到了一个更简单而且方便得多的工作流。

markdown语法

链接1
链接2
链接3

配置

添加页面

针对于NEXT主题而言

添加「标签」页面

  1. 在终端窗口下,定位到 Hexo 站点目录下。使用 hexo new page 新建一个页面,命名为 tags :
    1
    2
    $ cd your-hexo-site
    $ hexo new page tags
  2. 编辑刚新建的页面,将页面的类型设置为 tags ,主题将自动为这个页面显示标签云。页面内容如下:
    1
    2
    3
    4
    title: 标签
    date: 2014-12-22 12:39:04
    type: "tags"
    ---
  3. 修改菜单
    在菜单中添加链接。编辑 主题配置文件 , 添加 tagsmenu 中,如下:
    1
    2
    3
    4
    menu:
    home: /
    archives: /archives
    tags: /tags

添加「分类」页面

  1. 在终端窗口下,定位到 Hexo 站点目录下。使用 hexo new page 新建一个页面,命名为 categories :
    1
    2
    $ cd your-hexo-site
    $ hexo new page categories
  2. 编辑刚新建的页面,将页面的 type 设置为 categories ,主题将自动为这个页面显示分类。页面内容如下:
    1
    2
    3
    4
    title: 分类
    date: 2014-12-22 12:39:04
    type: "categories"
    ---
  3. 在菜单中添加链接。编辑 主题配置文件 , 添加 categoriesmenu 中,如下:
    1
    2
    3
    4
    menu:
    home: /
    archives: /archives
    categories: /categories

添加图片标识

添加头像

到主题文件夹下的source/images/下用同名图片替换avatar.gif替换即可

添加favicon

将你的 favicon 放置到 站点 的 source 目录下,与站点的配置文件同级。 若你发现设置的 Favicon 并未生效,请先清除浏览器的缓存后直接访问 Favicon 的地址,这个地址通常是 http://your-domain.com/favicon.ico。
如果你的站点是放在子目录下,请设置为:favicon: favicon.ico

问题

Not a git repository

执行hexo d时出现错误:

1
Not a git repository (or any parent up to mount point /home)

解决办法:在目录中有一个文件名为.deploy_git,删除了就可以了

hexo deployer not found git

在执行hexo d 时出现错误:

1
error deployer not found:git

解决办法: 需要执行npm install hexo-deployer-git --save