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

Amzaing00 2019-06-25

本文面向对象

  • 前端小白

  • windows用户

  • 懒癌晚期患者

准备工作:

  1. 一个Github账户

  2. 安装Git

  3. 安装Node.js

Step by Step

Step 1, 创建一个Github page

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

  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: 暂时先这样了,欢迎拍砖!

相关推荐

JingLisen / 0评论 2020-01-06