使用 github 搭建个人博客

使用 github 搭建个人博客

1. 新建文件夹 /hexo, cd /hexo,

  • 安装 hexo 插件

    1
    npm i hexo -g
    1
    hexo init
    1
    npm install
    1
    2
    hexo g
    hexo s
  • 成功以后访问 http://localhost:4000

2. 创建 github repositories, 建立连接

  • repositories 名以 用户名.github.io 格式

  • 生成密钥

    1
    ssh-keygen -t rsa -C "248173490@qq.com"
  • 找到 _config.yml 下的 deploy, 进行以下配置

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

3. 写文章

  • 新建文章

    1
    hexo new post "article"
  • 可以看到在 /source/post 下面生成一个名为 article.md 的文件, 可以编写, 再执行命令

    1
    2
    hexo g // 生成
    hexo d // 部署

然后就可以在你的 github 站点 https://llj4737.github.io/看到你的文章了

参考 https://yq.aliyun.com/articles/117271, https://www.jb51.net/article/125152.htm