Github Page + Hexo 搭建静态博客傻瓜式教程


本文面向对象

  • 前端小白
  • windows用户
  • 懒癌晚期患者


准备工作:

  1. 一个Github账户
  2. 安装Git
  3. 安装Node.js


Step by Step


Step 1, 创建一个Github page

新建github page


1. Repo name 的填写格式为 Github名 + github.io。举个栗子,我的repo name为 cnscorpions.github.io
2. Description可以写static blog/blog,反正你随意就好
3. 点击创建repo


Step 2, Hexo安装以配置 (假设你已经安装好Git和Node.js)

  • 打开Git bash命令行
  • 安装NPM —> Taobao NPM 镜像 (因为网络环境不好,你懂的)
    $ npm install -g cnpm --registry=https://registry.npm.taobao.org
  • 安装Hexo
    $ cnpm install -g hexo-cli
  • 创建blog根目录
    $ hexo init blog
  • 生成静态文件
    $ hexo g
  • 安装Hexo-server模块
    $ cnpm install hexo-server --save
  • 运行本地服务器 (一定要在blog根目录下运行)
    $ hexo s
  • 打开http://localhost:4000/已经可以看到一篇内置的blog了


Step 3, 安装Hexo主题 (Git在线安装 VS 本地安装)

  • Git安装
$ hexo clean
$ git clone https://github.com/iissnan/hexo-theme-next
  • 修改配置文件
    _config.yml/theme ---> next
  • 更新主题
$ hexo c 
$ hexo g   
$ hexo s


Step 4, 安装SSH

  • 安装hexo-deployer-git模块
    $ cnpm install hexo-deployer-git --save
  • 修改配置文件
deploy:
  type: git
  repo: https://github.com/cnscorpions/cnscorpions.github.io.git
  branch: master
  • 检查电脑中是否存在SSH key
    $ ls -al ~/.ssh
  • 创建新的SSH key
$ ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
Enter a file in which to save the key (/c/Users/you/.ssh/id_rsa):[Press enter] ---> 不要移动文件位置
Enter passphrase (empty for no passphrase): [Type a passphrase]
Enter same passphrase again: [Type passphrase again]
  • 复制id_rsa.pug
  • 复制到Github SSH key
  • 搞定
    $ hexo g ---> $ hexo d ----> OVER


PS: 暂时先这样了,欢迎拍砖!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值