概述
Hexo是什么?
GitHub Pages是什么?
GitHub Pages 是由 GitHub 官方提供的一种免费的静态站点托管服务,让我们可以在 GitHub 仓库里托管和发布自己的静态网站页面。我把它理解为动态网站的主机。功能都很类似。
1.安装
**1.**Hexo基于Node.js,搭建中还需要npm(Node.js自带)和git,因此我们需要首先搭建本地环境。安装Node.js和Git。
Node.js安装:
Node.js官网:https://nodejs.org/zh-cn/
进入官网后下载Windows(x64)长期支持版。
安装Git:
Git官网下载网址:https://git-scm.com/downloads
选择自己的平台,我选择Windows。点击下载。
下面验证Node.js和Git是否安装成功,也就是本地环境是否搭建成功。Win+R打开运行。输入cmd,进入命令提示符。
依次输入:(注意输入法在英文状态下)
node -v
npm -v
git --version

若如上图所示,则表明安装成功!
2.注册github
下来在桌面或者哪儿都可以,鼠标右键,点击【Git Bash Here】。
依次输入:
git config --global user.name "GitHub用户名"
git config --global user.email "GitHub邮箱"
3.生成ssh并连接
(如果想在多平台部署请忽略这步,直接看2,3)
输入:
ssh-keygen -t rsa -C "GitHub邮箱"
然后一路回车。创建SSH密匙。
进入下面路径,如果不显示的记得选择显示隐藏的项目。
路径:C:\用户\用户名\ .ssh
用记事本打开id_rsa.pub文件。复制文件中的内容。
登陆GitHub,进入setting。
选择左边SSH and GPG Keys选项。进行添加密匙。
点击New SSH Key进行添加。
title自己随便取,把刚才复制的密匙粘贴到Key中,点击Add SSH Key添加完成。
打开Git Bash,输入:
ssh -T git@github.com
出现Are you sure……的时候输入yes回车。
最后显示You’ve successfully……的时候表示连接成功。
点击右上角加号,点击New repository新建GitHub Pages仓库。
在Repository name中输入:用户名.github.io
勾选“Initialize this repository with a README”
Description选填。
填好后点击Create repository。创建后默认启用HTTPS。
博客的地址为:https://用户名.github.io
首先安装hexo-deployer-git。输入:
npm install hexo-deployer-git --save
耐心等待
2.多SSH连接
ssh-keygen -t rsa -C "xxxxxx@xxx.com" -f "id_rsa_gitee"
ssh-keygen -t rsa -C "xxxxxx@xxx.com" -f "id_rsa_github"
在.ssh目录下创建config文件,添加如下内容:
# github
Host github.com
HostName github.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa_github
# gitee
Host gitee.com
HostName gitee.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa_gitee
3.多平台部署
github
vercel
套了cf后,链接1,链接2
netlify
coding
部署效果
gitee
部署效果
csdn
目前仅支持企业版,可以用来当个备份!
扩展
Hexo 配置文件中的 theme_config
的优先级最高,其次是 _config.[theme].yml
文件,最后是位于主题目录下的 _config.yml
文件。