今天在龙湖准备写篇blog,发现在笔记本上执行hugo server
时报错:
1
2
3
| ERROR 2021/05/04 14:03:40 Failed to get JSON resource "https://api.twitter.com/1/statuses/oembed.json?id=xxxxx&dnt=false": Get "https://api.twitter.com/1/statuses/oembed.json?id=xxxxx&dnt=false": dial tcp 157.xxx.xx.xx:443: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
If you feel that this should not be logged as an ERROR, you can ignore it by adding this to your site config:
ignoreErrors = ["error-remote-getjson"]
|
我猜测可能是这边路由器没有翻墙,在处理包含了twitter shortcut的blog出现错误。
找到了一个处理方法:
https://github.com/gohugoio/hugo/issues/3869
对系统的shortcut进行覆盖,在 layouts\shortcodes
下创建一个tweet.html
1
2
3
4
5
6
| {{ if not .Site.IsServer }}
{{ template "_internal/shortcodes/twitter.html" . }}
{{ else }}
<!-- Render the placeholder for the shortcode -->
<pre>Twitter embed: {{ .Get 0 }}</pre>
{{ end }}
|
但这个方法确实是凑合,还是看看如何让hugo运行的时候也能翻墙吧。