这两天突然发现github.io的pags服务挂掉了,导致博客登录不上,为了防止以后类似情况的发生,决定把博客部署到国内的一些托管平台,比如开源中国和码市。因为二者都支持项目开启pages服务,所以迁移起来很简单;

step1、新建项目仓

  • 开源中国码市申请账号登录新建项目
  • 在新建项目的时候,对于pages项目,项目的名称一定要跟用户名一致,不然后面当博客源码推送到仓库上的时候,访问的时候会遇到静态资源都加载失败的情况;
  • 把项目的pages功能开启,默认使用master分支;

step2、修改修改hexo配置

  • 打开博客根目录的_config.yml文件,找到:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    # URL
    ## If your site is put in a subdirectory, set url as 'http://yoursite.com/child' and root as '/child/'
    #url: http://hillychen.github.io
    # Deployment
    ## Docs: https://hexo.io/docs/deployment.html
    deploy:
    type: git
    repo: https://github.com/HillyChen/HillyChen.github.io
    branch: master
  • 修改为(根据自己的仓库地址修改,其中增加了开源中国仓库地址和码云的仓库地址):

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    ## If your site is put in a subdirectory, set url as 'http://yoursite.com/child' and root as '/child/'
    url: https://git.oschina.net/chenxushan/chenxushan.git
    #url: http://hillychen.github.io
    #url: https://git.coding.net/hilly/hilly.git
    # Deployment
    ## Docs: https://hexo.io/docs/deployment.html
    deploy:
    type: git
    #repo: https://github.com/HillyChen/HillyChen.github.io
    repo: https://git.oschina.net/chenxushan/chenxushan.git
    #repo: https://git.coding.net/hilly/hilly.git
    branch: master
  • 然后执行下面命令,以重新生成baidusitemap.xml。

    1
    hexo generate -d