Hexo博客的迁移

当我们更换电脑或重装系统后,基于Hexo的个人博客可以通过以下方法来迁移

  1. 将原来的博客目录拷贝到新的环境下

  2. 安装git,并添加github、gitee公钥,见Git的安装和配置

  3. 安装nodejs

  4. 安装hexo

    1
    npm install hexo-cli -g
  5. 进到新的环境下,安装相应的模块

    1
    2
    npm install
    npm install hexo-deployer-git --save
  6. 之后就可以在原来的基础上继续执行了

遇到的问题

  • 如果在使用hexo g -d时,报以下警告:

    1
    2
    3
    4
    warning: LF will be replaced by CRLF in xxx
    The file will have its original line endings in your working directory
    warning: LF will be replaced by CRLF in xxx
    The file will have its original line endings in your working directory
    • 问题原因:git提供的换行符自动转换功能,将LF格式的换行符转化为CRLF

    • 解决方案:关掉自动转换功能

      1
      2
      git config core.autocrlf false 	# (仅对当前git仓库有效)
      git config --global core.autocrlf false # (全局有效,不设置推荐全局)
    • 本问题的解决参考了man_zuo的博客

  • 如果在使用hexo s时,报以下警告:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    INFO  Start processing
    INFO Hexo is running at http://localhost:4000 . Press Ctrl+C to stop.
    (node:7136) Warning: Accessing non-existent property 'lineno' of module exports inside circular dependency
    (Use `node --trace-warnings ...` to show where the warning was created)
    (node:7136) Warning: Accessing non-existent property 'column' of module exports inside circular dependency
    (node:7136) Warning: Accessing non-existent property 'filename' of module exports inside circular dependency
    (node:7136) Warning: Accessing non-existent property 'lineno' of module exports inside circular dependency
    (node:7136) Warning: Accessing non-existent property 'column' of module exports inside circular dependency
    (node:7136) Warning: Accessing non-existent property 'filename' of module exports inside circular dependency