ssh方法git clone及hugo问题解决
引言
- 用其他电脑git clone项目时报错“Could not open a connection to your authentication agent.”的解决办法;
- 使用hugo报Warning:hugo WARN found no layout file for "html" for kind "home": You should create a template file which matches Hugo Layouts ;
主要内容
在个人电脑上用hugo创建个人博客并部署到github上,使用其他电脑克隆时报错的解决办法及使用hugo serve本地预览个人博客报错问题的原因及解决办法。
第一部分
git clone解决办法:可以使用ssh方式克隆;
-
进入到C:/Users/用户名/.ssh路径下
-
打开git bash, 输入如下指令:
ssh-keygen -t ed25519 -C "your_email@example.com" -
使用如下命令启用SSH代理:
$ ssh-agent -k $ eval $(ssh-agent) -
使用ssh-add命令添加ssh密钥到代理中
$ ssh-add ~/.ssh -
添加公钥到github
cat ~/.ssh/id_ed25519.pub复制输出内容
前往 GitHub → Settings → SSH and GPG keys → New SSH key,粘贴并保存。 -
测试SSH连接
ssh -T git@github.com出现 “Hi your_username! You’ve successfully authenticated” 则配置成功。
-
克隆仓库
git clone git@github.com:你的用户名/你的仓库名.git
第二部分
hugo报warning意思是config中指定的主题不存在,原因是git clone未克隆theme下的内容到本地,去下载引用的主题,并放到themes路径,重新运行hugo serve,即可解决问题
总结
-
记录了使用ssh方法克隆项目的方法
-
解决了运行hugo serve未正常显示个人博客的问题
本文作者:lopo,8年临床试验SAS程序员,竹笛、乒乓球爱好者
转载请注明出处:lopo的博客

浙公网安备 33010602011771号