参考文档:
《Github入门与实践》
前面的步骤请参考官方文档“概述”和“建站”两节进行配置。
更换Hexo的主题为Next,参考官方Github页面,先转到该hexo项目的根目录(本例为myblog),执行:
1 | git clone https://github.com/theme-next/hexo-theme-next themes/next |
修改_config.yml文件,将theme:
后的landscape更改为next。
执行hexo s
,打开浏览器访问相应网页,以检查是否成功。
配置git:
1 | git config --global user.name "mushymuse" |
检查:
1 | git config user.name |
Github上连接已有仓库时的认证,是通过使用了SSH的公开秘钥认证方式进行的。现在让我们来创建公开秘钥认证所需的SSH Key。
1 | ssh-keygen -t rsa -C "hzlpyy@163.com" |
一直回车以使用默认设置。
获取公钥:
1 | cat ~/.ssh/id_rsa.pub |
夹在ssh-rsa
和邮箱之间的就是公钥,在Github的SSH Keys设置中添加这个公钥,要注意在添加时要粘贴整个文件的内容,即要包括开头的ssh-rsa
和结尾的邮箱。
测试:
1 | ssh -T git@github.com |
出现以下提示说明成功:
1 | Hi mushymuse! You've successfully authenticated, but GitHub does not provide shell access. |
编辑_config.yml:
1 | deploy: |
安装deploy-git:
1 | npm install hexo-deployer-git --save |
执行部署操作:
1 | hexo clean |
可用hexo g
和hexo d
代替hexo generate
和hexo deploy
。
deploy过程中会验证Github的用户名和密码,输入即可。
发现接下来每次deploy都要输入密码,解决方案:
编辑_config.yml
,将:
1 | deploy: |
改为:
1 | deploy: |
插入图片——以下方案不可行:
1 | npm install hexo-asset-image --save |
编辑_config.yml,将post_asset_folder:
后改为true
可行方案:
方案1:
最简单的方法就是将它们放在
source/images
文件夹中。然后通过类似于
的方法访问它们。
在Typora中,打开偏好设置→图像→插入图片时…,修改为“复制到指定路径”,路径设置为../images
,并勾上“优先使用相对路径”。
方案2:
参考https://hexo.io/zh-cn/docs/asset-folders#Embedding-an-image-using-markdown
使用插件hexo-renderer-marked
。