Hexo搭建

环境准备

安装Git

官网:https://git-scm.com/

1、访问Git官网,下载对应安装包,一路确定安装即可

  • Additional icons下的On the Desktop | 表示是否在桌面创建快捷方式
  • Windows Explorer integration | 右键菜单显示选项
  • (NEW!)Add a Git Bash ProFile to Windows Terminal | 如果安装了Terminal(终端)则会在终端里添加Git选项

其他默认即可

安装Node.js

官网:https://nodejs.org/

访问Node.js官网,下载对应安装包,一路确定安装即可

安装Hexo

Git终端输入

npm install hexo -g

配置SSH Key

标题说了使用Github Page建造,所以你得先有一个Github账号
Github官网:https://github.com | 可能需要VPN
相关教程请Google

配置key

终端输入

ssh-keygen -t rsa -C "______"
  • “______”填写你注册Github的邮箱
  • 输入命令后三次回车即可

进入 | C:\Users\你的用户名\ .ssh

文件夹中会生成 id_rsa.pub 文件,建议使用Vscode打开

复制里面的全部内容,打开https://github.com/settings/keys

点击 [New-SSH-Key]

  • Title为备注
  • 在Key输入粘贴在id_rsa.pub里的全部内容
  • 然后点击Add-SSH-Key blue
  • 输入Github账号密码

配置账号密码

git config --global user.name "你的Github用户名"
git config --global user.email "你的Github邮箱"

搭建

在任意一个硬盘新建文件夹,进入文件夹右键打开终端

hexo init
  • 创建博客相应文件

文件 详细
_config.yml 网站的配置信息,您可以在此配置大部分的参数
package.json 应用程序的信息
scaffolds 模版文件夹,当您新建文章时,Hexo会根据scaffold来建立文件
source 存放用户资源的地方
themes 存放主题的地方
source/_posts 存放文章

生成静态页面

hexo g

预览页面

hexo s

浏览器打开localhost:4000
看到以下页面说明成功创建

卸载Hexo

npm uninstall hexo-cli -g
Have a Nice Day
上一篇
下一篇