Hexo-GitHub 搭建

153 阅读1分钟

注册 Github

Github下载地址: github.com



安装 Nodejs

Node.js下载地址: nodejs.org/en/download



安装 Git

Git下载地址: git-scm.com/download



安装 Hexo

Hexo下载地址: Hexo

//安装
$ npm i hexo-cli -g

//初始化(MyBlog是您要创建的文件名)
$ hexo init MyBlog

//安装组件
$ npm install

//打开本地服务器
$ hexo s

//地址
http://localhost:4000/

//关闭本地服务器
$ ctrl+c



连接 Github

//设置用户名和邮箱
$ git config --global user.name "wy8898"

$ git config --global user.email "13753068898@163.com"


//生成密钥SSH key
$ ssh-keygen -t rsa -C "13753068898@163.com"

$ cat ~/.ssh/id_rsa.pub
//👆复制输出内容key

步骤: 打开Github ==> settings ==> SSH and GPG keys ==> 新建SSH,名字随便 ==> 粘贴key ==> 保存

//测试SSH连接
$ ssh -T git@github.com

//👇成功
//Hi wy8898! You've successfully authenticated, but GitHub does not provide shell access.

打开 MyBlog 文件根目录 _config.yml

//修改配置:
deploy:
  type: git
  //你的项目地址👇
  repository: https://github.com/wy8898/wy8898.github.io
  branch: master



发布文章

MyBlog\source\_posts 下创建 .md, 编写 md 文件

//生成静态网页
$ hexo g

//本地预览
$ hexo s

//上传到 Github
$ hexo d



更换主题

Hexo主题官网地址: hexo.io/themes

$ git clone https://github.com/theme-next/hexo-theme-next themes/next

修改 _config.yml 中的 theme: next



添加 about 页面

$ hexo new page "about"



设置头像

打开文件 wyBlog/themes/black-blue/_config.yml

//修改配置
$ avatar: /images/header.jpg

//重新提交审核
$ hexo d -g