calintat / minimal

Personal blog theme powered by Hugo
https://themes.gohugo.io/minimal/
MIT License
401 stars 220 forks source link

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

Open henningsway opened 6 years ago

henningsway commented 6 years ago

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?

PaulRBerg commented 5 years ago

+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 commented 5 years ago

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 }}