【发布时间】:2019-01-09 11:20:25
【问题描述】:
我刚刚收到了一个雨果网站。我需要添加一个 og:image 比如说示例 www.site.com/page1 以及子页面 www.site.com/page1/something 和几十个项目......
我正在阅读文档并找到了这个。
// First in config.toml use the following:
baseURL = "//example.com" [params] og_image = "/some-image.jpg"
// Then in a post’s frontmater set a parameter for the OpenGraph image
og_image = "/images/1.jpg"
// And in the HEAD partial put the following:
> {{ if .Params.og_image }} > `` > `` > {{ else }} > `` > `` > {{ end }}
// And that’s it.
我无法理解在 params 中输入的内容。 > `` > 是什么意思我应该在哪里包含meta-tag,你能解释一下吗?我以前从未使用过 Hugo,文档有点奇怪......基本上,对于这样的每个页面和子页面,我想为 og:image 使用图像..
目前在我的config.yaml,我有:
baseurl: "www.site.com/"
标题中的答案 {{ .Hugo.Generator }}
{{ if isset $.Params "ogtype" }}
<meta property="og:type" content="{{ .Params.ogtype }}">
{{ end }}
{{ if isset $.Params "ogimage" }}
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:site" content="@siteLtD">
<meta property="og:title" content="{{ .Params.title }}">
<meta property="twitter:title" content="{{ .Params.title }}">
<meta property="og:image" content="{{ .Params.ogimage }}">
<meta property="twitter:image" content="{{ .Params.ogimage }}">
{{ else }}
<meta property="og:image" content="www.site.com/images/site-ogi.png">
如果您能指导我实际需要包含哪些内容以使子页面获得特定图像,那将非常感谢!
【问题讨论】: