记录下用hexo搭建Github Pages的过程
前言
之前一直都想在服务器上搭建一个hexo博客,但对node.js完全不熟悉以及在宝塔面板上部署静态博客好像有点麻烦,就简单的用typecho,随便找了一个主题搭建了博客。
typecho是适配markdown的,就是每个图片都要上传附件然后更改图片路径导致我自己写的md完全没有发上去的欲望
而git+hexo就很方便了,写完直接git push
就好了,组会也正好有这个任务,就借此机会完成了。(不能再拖了)
环境
Ubuntu 22.04
node.js and npm
Node的环境配置比较简单
1 | $ sudo apt install nodejs npm |
安装的是长期版本,搭建hexo已经够用了
git
1 | $ sudo apt-get install git-core |
通过ssh方式链接github账户
1 | $ git config --global user.email "[email protected]" |
然后打开github
进入setting选择SSH and GPG keys,点击New SSH key
取一个合适的名字,并将生成的id_rsa.pub中的内容复制到key中
1 | #以ssh方式clone创建好的github pages库 |
此时能正常git push
就是成功链接了
(记得打开Pages,以及github学生包可以白嫖一个**.me**后缀域名)
hexo
本地
1 | #只有root权限才安装成功了,原因未知 |
此时访问 https://localhost:4000 可以看到本地博客页面
github pages
在**_config.yml**的最后一行添加
1 | deploy: |
更改url为你的github pages
1 | $ hexo clean |
此时访问 https://xlccccc.github.io 就可看到博客啦
1 | $ hexo new photo "My Gallery" |
如果改了域名,在source下新建CNAME,内容为你的域名(如xlccccc.me
),然后hexo generate
hexo deploy
即可