Hello 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.

Quick Start

  • Create a new post

    1
    $ hexo new "My New Post"

    More info: Writing

  • Run server

    1
    $ hexo server(hexo s)

    More info: Server

  • Generate static files

    1
    $ hexo generate(hexo g)

    More info: Generating

  • Deploy to remote sites

    1
    $ hexo deploy(hexo d)

    More info: Deployment

常见问题

更新发布失效

如果部署到 github 上,但没有更新的话,需要在部署时清掉缓存,重新生成

  • 删除 public 文件,npm install 或者 hexo clean
  • hexo g -d

git 添加 next 主题

next 等主题是直接用 git clone 或 fork下来的,是一个子项目,所以需要引入子模块来管理,否则 next 主题是提交不上的。

  • 如果出现个问题:“already exists in the index”,可以先清掉 .git 中的主题文件:

    1
    git rm -r --cached theme/next
  • 在 GitHub 上 fork next 库,再在本地 hexo 的 git 库中添加 submodlue:

    1
    git submodule add git@github.com:lavnFan/hexo-theme-next.git themes/next
  • 修改 next 风格,再在 theme/next 的 git 库中提交

    1
    2
    3
    git add .   
    git commit -m "next settings in fork next rep"
    git push origin master //这是提交到fork后主题的仓库

  • 回到根目录提交 next,这样以 submodule 的子库形式关联 next 的仓库。

    1
    2
    3
    4
    cd ../../ //切到仓库的根目录   
    git add .
    git commit -m "update next"
    git push origin hexo //注意hexo分支

多端同步 hexo

基本思路是用俩个库分别管理:

  • master 分支:用来保存 Hexo 生成的博客文件,指向 GitHub Pages
  • Hexo 分支:用来保存所有 Hexo 的源文件,需私有,避免暴露,可以指向 GitHub 或 coding 等平台的私有仓库。

添加版权信息

在 hexo next 主题中,为文章添加版权信息步骤是:

  • 在 next 目录下修改 _config.yml 文件,设置 copyright: true
  • 在 hexo 根目录下修改 _config.yml 文件,设置 url: http://yoursite/ ,这里要注意是 http://yoursite/ ,不是 http://yoursite ,最后边还有个下划线,否则推送到远端时,会显示 http://yoursite/ ,一直更新不了。

按文章创建时间排序

文章的开头添加 date 的信息来表示创建时间,否则默认会按照最新修改时间。

问题:添加了 date ,本地显示正常,但远端一直更新不了。

原因:本以为是缓存的原因,但其实是添加的 date 的位置问题,date 必须在 title 之后,不能放在其他位置。

知道是不会有人点的,但万一被感动了呢?