使用Github建个人博客

步骤:

本地电脑安装

  1. 安装Node

    1
    brew install node
  2. 安装yarn

  3. 1
    brew install yarn
  4. 安装hexo

    1
    yarn global add hexo
  5. 新建一个Blog项目

    1
    hexo init blog
  6. 启动本地Hexo服务,查看测试页面

    1
    2
    cd blog
    hexo server

    本机测试页面:

    http://localhost:4000/

网站修改

  1. 安装Next主题(或其它主题)
1
2
cd blog #blog为网站所在文件夹,可自定义或通过finder修改
git clone [https://github.com/next-theme/hexo-theme-next](https://github.com/next-theme/hexo-theme-next) themes/next
  1. 修改根文件夹下的_config.yml文件,theme指向next

    1
    theme: next
  2. hexo server启动服务查看测试页面。

    1
    hexo server
  3. 配置主题,以及网站_config.yml

相关命令

1
 hexo new page "about"   #生成about网页

关联Github

  1. 新建一个Reposity ,名字.github.io

  2. 根目录下_config.yml填写Reposity信息

    1
    2
    3
    4
    deploy:
    type: git
    repo: https://github.com/yjf2614/yjf2614.github.io.git
    branch: master
  3. deploy

    1
    hexo d
  4. 弹出填写用户名密码(github帐号)

    username:

    password: 密码不是登陆密码,在github setting上找personal access token

    Developer settings

  5. deploy完成后,使用.github.io访问网站。

 

其它

增加阅读人数统计功能

  • 注册leancloud国际版

  • 创建应用

  • 创建class

  • 转到应用凭证界面

  • 修改theme文件夹下的_config.yml文件

    1
    2
    3
    4
    leancloud_visitors:
    enable: true
    app_id: <your-id>
    app_key: <your-key>

换系统或者换电脑需要重装 hexo
 的时候,只需要在hexo
环境搭建好的基础上,只需要把 source
themes
 、 _config.yml
 覆盖到新的博客目录下即可

参考文章:

https://yogapan.github.io/2017/08/11/用Hexo-Github-Pages搭建個人部落格/ #部分命令已过时

如何在 GitHub 上写博客? - 吴师兄学算法的回答 - 知乎
https://www.zhihu.com/question/20962496/answer/1882882782   #Next主题修改