How to force Social media to take header image as default?


#1

I coudn’t explain this in a better manner…

My Blog: Geek’s World
Theme: Casper Two
Git repo: github(dot)com/AbhinavSThakur/Geek-World

When I write blog posts, I assign each post a header image which shows up on Homepage but when I share those posts header image is not considered as default image, instead the first image is considered as default image!

Is there any way to force Social media to take header image as the default Image?

Github Discussion


#2

Hi, look for the Opengraph Metatags in your search engine. You will find a lot of solutions.


#3

The answer is: yes, there is. I looked at one of your posts, and you have nothing in your <head> that tells any social media site which image to use, but in my experience they prioritize content images over banner/header images. If you want the header image to be recognized, you need to make that clear. Search in here for SEO or opengraph.


#4

I have that working on my site, using a featured_image parameter per post, but you can do it with the first image of a page. (I believe there is a post about that here on the forum)

Anyway, this is how I did it in the header after setting the frontmatter:

{{ with .Params.featured_image }}
<meta property="og:image" content="{{ . | absURL }}" />
{{ else }}

You can find the full code here: https://github.com/brunoamaral/future-imperfect-DI/blob/master/layouts/partials/header.html