OK 记录一下这个博客是如何搭建的,与之前用阿里云——Wordpress 不同,这是托管在github上免费的博客,不用租服务器哈,还挺省钱,凑合用。
1 安装Node.js 和 Git
官网搜索,傻瓜式安装,一路点next
安装好之后打开终端看是否有版本号。
node -v
npm -v
git –version
2 打开Git bash
输入命令
npm install -g hexo-cli
mkdir blog-hexo
cd blog-hexo
hexo init .
npm install
然后敲
hexo server
会出现
Hexo is running at http://localhost:4000/. Press Ctrl+C to stop.
放进浏览器里会看到一个页面,就算成功了。
3 部署Github
新建仓库“你的GitHub用户名.github.io“ 比如我的就是“EdmondQing.github.io”,其他选项都默认。
然后回到git bash 的博客文件夹下
npm install hexo-deployer-git –save
打开_config.yml
修改
deploy:
type: git
repo: https://github.com/EdmondQing/EdmondQing.github.io.git
branch: main
然后浏览器就可以访问https://EdmondQing.github.io 了
可能报错 “Please tell me who you are”
只需要配置一下:
git config –global user.name “用户名”
git config –global user.email “邮箱”
就OK
4.如何写文章
hexo new “How to build a blog”
然后就会发现生成了一个md文件,并且附有路径,一般在source里面,然后就可以用markdown来敲代码写文章了。
写完之后保存,然后
hexo clean
hexo g -d