个人博客搭建


个人博客搭建

利用hexo博客框架部署个人博客到github,操作简单,教程全面且易于获取,对新手较为友好。

软件安装

// nginx要安装到普通用户目录,否则运行有权限冲突
git
nodejs 检测:node -v npm -v(node安装已包含)
hexo
// WSL迁移到D盘
wsl --list
wsl --manage kali-linux --move D:\WSL\Kali

连接Github

git config --global user.name "username"
git config --global user.email "email"
ssh -T git@github.com 远程测试连接github仓库
ssh-keygen -t rsa -C " " 一路回车,生成密钥复制到Github新建key中
ssh -T git@github.com 远程测试连接github仓库
github,Settings->Developer settings->Personal access tokens->Generate new token
	1. 填写note,勾选select scopes下的repo选项,提交生成一串口令,复制
	2. hexo d 部署,过程中填写note内容和口令,username,password
git clone https://github... 从github上下载主题包

配置hexo

// 安装hexo
npm install -g hexo-cli 
// 部署插件安装
npm install hexo-deployer-git --save git  
// 新建文件夹下初始化hexo
hexo init 
// 清除缓存/生成静态页面/运行本地服务/部署到服务器
hexo clean/generate/server/deploy
// 新建文章
hexo new "filename" 
// 新建页面
hexo new page "pageame"
// 查看帮助
hexo help 

// 修改全局配置文件文件应用主题和hexo配置
deploy:
	type: git
	repository: git@github.com:Loongbx/Loongbx.github.io.git  
	branch: master
// 部署到github
hexo g -d  
// 开启mathjax支持,显示数学公式
修改/home/blog/themes/hexo_theme_matery/_config.yml
mathjax:
	enable:false -> mathjax:true
文章Front-matter中加上:mathjax:true

常用命令

hexo clean	clean
hexo g	generate
hexo d  deploy

本地调试

_config.yml 全局配置文件
hexoblog/source/_posts/ 文章内容
themes/../_config.yml  主题配置文件

部署失败解决

case1:
删除.dploy_git文件夹
git config --global core.autocrlf false
hexo clean
hexo g -d
case2:
Token失效,修改其有效期Develop Settings  
case3:
spawn failed  
复制github上项目地址,更改为ssh的地址,覆盖_config.yml文件部署地址  

  目录