minimal icon indicating copy to clipboard operation
minimal copied to clipboard

How to include a picture for posts to show up in RSS-Reader?

Open henningsway opened this issue 7 years ago • 2 comments

This theme doesn't support images and I like it.

It would be nice for some posts to add an Image to the header of the file, which then gives a preview of the posts content, e.g. when viewed in an RSS-Reader. Would it be straightforward to build images like these into the theme (myself) and what would be the general way of doing this?

henningsway avatar Mar 09 '18 14:03 henningsway

+1 for this. I guess what needs to be done is integration with the OpenGraph protocol (promoted by Facebook, Twitter et al). There's a discussion going on here: https://discourse.gohugo.io/t/display-first-image-in-post-in-link-preview/10541/5

PaulRBerg avatar Dec 24 '18 21:12 PaulRBerg

Just for the record, I managed to do this by overriding head-open.html in the layouts folder:

<meta name="description" content="{{ .Description }}"/>

<meta name="og:type" content="website" />
<meta name="og:title" content="{{ .Title }}"/>
<meta name="og:description" content="{{ .Description }}"/>

<meta name="twitter:card" content="summary"/>
<meta name="twitter:title" content="{{ .Title }}"/>
<meta name="twitter:description" content="{{ .Description }}"/>

{{ with .Params.Images }}
      {{ range first 1 . }}
                  <meta property="og:image" content="{{ . | absURL }}" />
                  <meta property="twitter:image:src" content="{{ . | absURL }}" />
      {{ end }}
{{ end }}

PaulRBerg avatar Dec 26 '18 17:12 PaulRBerg