0%

搭建博客

哈哈,后来使用Next主题了,不适用啦,从新将现有博客系统的内容更新了一遍。2019年04月16日19:19:15

参考文章:

初始化hexo

1
2
3
4
5
6
7
npm install hexo-cli -g
hexo init sky0504
cd sky0504
npm install
npm install hexo-renderer-pug --save
npm install hexo-renderer-sass --save
npm install hexo-deployer-git --save

更换主题

  1. fork大道至简主题的仓库
  2. 克隆《大道至简》的主题

    1
    git clone https://github.com/sky0504/maupassant-hexo.git themes/maupassant
  3. 修改配置,启用主题vim _config.yml(将theme: landscape更改为theme: maupassant)

  4. 修改语言vim _config.yml(更改language:language: zh-CN)

添加评论系统

  1. 注册Oauth Application
  2. 查看注册应用的id、secret等信息
  3. 修改配置文件vim _config.yml,修改gitment的有关配置信息
  4. 修改主题文件themes/maupassant/layout/_partial/comments.pug,在gitment初始化时添加一行id: '#{page.date}',,整体如下所示:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    var gitment = new Gitment({
    id: '#{page.date}',
    owner: '#{theme.gitment.owner}',
    repo: '#{theme.gitment.repo}',
    oauth: {
    client_id: '#{theme.gitment.client_id}',
    client_secret: '#{theme.gitment.client_secret}',
    },
    })
  5. 需要评论的文章,第一次点击initialize comments按钮,然后在下边的评论框填写评论即可

部署到GitHub上

  1. 修改配置_config.yml中的deploy

    1
    2
    3
    4
    deploy:
    type: git
    repo: https://github.com/sky0504/sky0504.github.io.git
    branch: master
  2. 创建文件vim source/CNAME,写入一行sky.mafeifei.cn

  3. 打开https://github.com/sky0504/sky0504.github.io.git的设置,设置Custom domainsky.mafeifei.cn
  4. 修改域名解析,添加记录类型为CNAME的一条记录,指向sky0504.github.io

添加备案信息

  1. 公安部注册备案略
  2. 下载备案图标到hexo的source目录下
  3. vim themes/maupassant/layout/_partial/footer.pug在该文件最后添加备案图标和备案号信息代码
    1
    2
    3
    4
    5
    p 浙ICP备16006348号 | 
    |
    img(src="/images/ba.png")
    |
    a(rel='nofollow', target='_blank', href='http://www.beian.gov.cn/portal/registerSystemInfo?recordcode=33010302001929') 公安机关备案33010302001929号