halogenica / beautifulhugo

Theme for the Hugo static website generator
Other
1.13k stars 601 forks source link

Nonstandard method used for deriving twitter card image #460

Closed ahelwer closed 6 months ago

ahelwer commented 1 year ago

Don't know whether this constitutes a bug but it did confuse me for a while. The usual method of defining images to use in twitter cards (and other websites) is with the images key in the front matter of a post, as documented here: https://gohugo.io/content-management/front-matter/

The images key accepts a list of images of which one is chosen. So for example:

---
title: Some Post Title
...
images: ["image1.jpg", "image2.jpg"]
---

However the way this theme seems to generate twitter cards is with the image key (not plural) and the image paths have to be absolute, not relative:

---
title: Some Post Title
...
images: "/path/to/post/directory/image.jpg"
---

Again, it's unclear whether this is a bug but it is confusing because all the documentation & tutorials out there say to use the images tag. I dug through the theme code to figure out it had to be image and that the path had to be absolute, not relative to the post directory like other image definitions.

There are a few possible fixes here: