diff --git a/tpl/tplimpl/embedded/templates/opengraph.html b/tpl/tplimpl/embedded/templates/opengraph.html index c245e5bd143..a9b348e9ef0 100644 --- a/tpl/tplimpl/embedded/templates/opengraph.html +++ b/tpl/tplimpl/embedded/templates/opengraph.html @@ -4,11 +4,11 @@ {{- end }} -{{- with or .Title site.Title site.Params.title | plainify}} +{{- with or .Title site.Title site.Params.title | plainify }} {{- end }} -{{- with or .Description .Summary site.Params.description | plainify }} +{{- with or .Description .Summary site.Params.description | plainify | htmlUnescape | chomp }} {{- end }} @@ -18,7 +18,9 @@ {{- if .IsPage }} - + {{- with .Section }} + + {{- end }} {{- $ISO8601 := "2006-01-02T15:04:05-07:00" }} {{- with .PublishDate }} diff --git a/tpl/tplimpl/tplimpl_integration_test.go b/tpl/tplimpl/tplimpl_integration_test.go index 28d442e0d63..6b2664c4d84 100644 --- a/tpl/tplimpl/tplimpl_integration_test.go +++ b/tpl/tplimpl/tplimpl_integration_test.go @@ -305,3 +305,109 @@ title: p2 "\n\n \n /p2/\n \n\n", ) } + +// Issue 12418 +func TestOpengraph(t *testing.T) { + t.Parallel() + + files := ` +-- hugo.toml -- +capitalizeListTitles = false +disableKinds = ['rss','sitemap'] +languageCode = 'en-US' +[markup.goldmark.renderer] +unsafe = true +[params] +description = "m n and **o** can't." +[params.social] +facebook_admin = 'foo' +[taxonomies] +series = 'series' +tag = 'tags' +-- layouts/_default/list.html -- +{{ template "_internal/opengraph.html" . }} +-- layouts/_default/single.html -- +{{ template "_internal/opengraph.html" . }} +-- content/s1/p1.md -- +--- +title: p1 +date: 2024-04-24T08:00:00-07:00 +lastmod: 2024-04-24T11:00:00-07:00 +images: [a.jpg,b.jpg] +audio: [c.mp3,d.mp3] +videos: [e.mp4,f.mp4] +series: [series-1] +tags: [t1,t2] +--- +a b and **c** can't. +-- content/s1/p2.md -- +--- +title: p2 +series: [series-1] +--- +d e and **f** can't. + +-- content/s1/p3.md -- +--- +title: p3 +series: [series-1] +summary: g h and **i** can't. +--- +-- content/s1/p4.md -- +--- +title: p4 +series: [series-1] +description: j k and **l** can't. +--- +-- content/s1/p5.md -- +--- +title: p5 +series: [series-1] +--- +` + + b := hugolib.Test(t, files) + + b.AssertFileContent("public/s1/p1/index.html", ` + + + + + + + + + + + + + + + + + + + + + + `, + ) + + b.AssertFileContent("public/s1/p2/index.html", + ``, + ) + + b.AssertFileContent("public/s1/p3/index.html", + ``, + ) + + // The markdown is intentionally not rendered to HTML. + b.AssertFileContent("public/s1/p4/index.html", + ``, + ) + + // The markdown is intentionally not rendered to HTML. + b.AssertFileContent("public/s1/p5/index.html", + ``, + ) +}