Hi, I’ve recently finally implemented social media cards for my Hugo-based homepage and blog. Given my research it doesn’t seem to be a solved problem in general, so I’m planning on blogging about it.
But before I do that I wanted to make sure I don’t embarrass myself by missing something simple/obvious and would like to run it past y’all.
So what I do is using fmcardgen to create the cards to static/cards for the pages I want them (blog, talks, TILs) that look like this:
Then I check whether that card exists and if so use it in my baseof.html, otherwise I just use my avatar pic:
Then with Image Processing | Hugo you can generate these social cover images directly without saving them to a folder, you can resize these images to be at the right dimensions for social medias.
How are you running fmcardgen? Is itmanually before you run Hugo? so it generates a card and saves it into your static folder, subfolder card. So when you run hugo, the file shall exist? or you integrate this somehow?
You place every cover generated in the correct post folder (at the root of this folder), and, in the name of that image you need at the end _cover.
You use the internal opengraph template I linked earlier.
Last point, if you want a fallback image like in your code (avatar pic), you will need to declare it in your config.toml or config.yaml file in the images section
OK, thanks for the input, I might use that for other problems.
For now I think I’m cool with my approach then, because I’m not a fan of all posts being called index.md, since it still confuses most Markdown editors (as in “quick open gets flaky” :-/) and I don’t see an immediate benefit.
Is there a better way to check for the existence of the card though? It feels weird to use a combination of printf and Join.
Truthfully, the Twitter conversation I had with you yesterday — and all the cool possibilities you mentioned — have me thinking about how to do that better, so that’s why I didn’t respond to this thread.
(Besides, what I’m doing now is very similar to what’s already in the Hugo docs.)