How to successfully implement og:image for LinkedIn
Asked Answered
T

13

53

THE PROBLEM:

  • I am trying, without much success, to implement open graph image on site: http://www.guarenty-group.com/cz/
  • The homepage is completeply bypassing the og:image tag, where internal pages are reading all images from the site and place og:image as the last option.
  • Other social networks are working fine on both internal pages and homepage.

THE CONFIGURATION:

  • I have no share buttons or alike, all I want is to be able to share the link via my profile.
  • The image is well over 300x300px: http://guarenty-group.com/img/gg_seal.png
  • Here is how my head tag looks like:

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
            <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
            <title>Guarenty Group : Pojištění pro nájemce a pronajímatelé</title>
    
            <meta name="keywords" content="" />
            <meta name="description" content="Guarenty Group pojišťuje příjem z nájmu pronajímatelům, kauci nájemcům - aby nemuseli platit velkou částku v hotovostí předem - a dále nájemcům pojišťuje příjmy, aby měli na nájem při nemoci, úrazu či nezaměstnání." />
            <meta name="image_src" content="http://guarenty-group.com/img/gg_seal.png" />
            <meta name="image_url" content="http://guarenty-group.com/img/gg_seal.png" />
    
            <meta property="og:title" content="Pojištění pro nájemce a pronajímatelé" />
            <meta property="og:url" content="http://guarenty-group.com/cz/" />
            <meta property="og:image" content="http://guarenty-group.com/img/gg_seal.png" />
            <meta property="og:description" content="Guarenty Group pojišťuje příjem z nájmu pronajímatelům, kauci nájemcům - aby nemuseli platit velkou částku v hotovostí předem - a dále nájemcům pojišťuje příjmy, aby měli na nájem při nemoci, úrazu či nezaměstnání [...]" />
            ...
    </head>
    

THE TESTING RESULTS:

In order to trick the cache i have tested the site with http://www.guarenty-group.com/cz/?try=N, where I have changed the N every time. The strange thing is that images found for different value of N is different. Sometimes there is no image, sometimes there is 1, 2 or 3 images, but each time there is a different set of images. But, in any case I could not find the image specified in the og:graph!


MY QUESTIONS:

  1. https://developer.linkedin.com/documents/setting-display-tags-shares is saying one thing, and the personnel on the support forum is saying "over 300" Does anyone know What is the official minimum dimension of the image (both w and h)?
  2. Can an image be too large?
  3. Should I use the xmlns, should I not use xmlns or it doesn't matter?
  4. What are the maximum (and minimum) lengths for og:title and og:description tags?

Any other suggestion is of course welcomed :)

Thanks in advance, cheers~

Trackman answered 6/4, 2012 at 11:25 Comment(0)
B
50

This answer I found on LinkedIn forums might be of help to you:

Guys, I've spent a whole day trying different things. What worked for me is using the mata [sic] tags as following:

<meta prefix="og: http://ogp.me/ns#" property="og:title" content="{Your content}" />
<meta prefix="og: http://ogp.me/ns#" property="og:type" content="{Your content}" />
<meta prefix="og: http://ogp.me/ns#" property="og:image" content="{Your content}" />
<meta prefix="og: http://ogp.me/ns#" property="og:url" content="{Your content}" />

Just try to add prefix to every tag (not to html tag), then re-sign in with your LI account to clear the cache... Post your results.

Bowman answered 2/8, 2014 at 8:44 Comment(0)
S
23

I found this simple fix which worked for me after lots of complicated solutions which didn't work:

LinkedIn

The only way to “clear” the sharing preview cache for LinkedIn is to trick LinkedIn into thinking your page is a different (and new) page.

This is done by adding a made-up parameter to the link. It doesn’t affect your webpage, but it does force the metadata to be re-fetched.

Example:

Original link: //beantin.se/consultant-resume "New" link: //beantin.se/consultant-resume?1

Schistosomiasis answered 9/10, 2017 at 8:10 Comment(2)
This is what worked for me. I had all the proper meta tags in place but couldn't bet LinkedIn to display my image. Adding a bogus query string to the url did the trick and forced it to fetch the page with new meta tags containing the reference to the image. Thanks!Length
Easy and effective. Thanks a lot!Hijack
H
23

I was having the same issue last night. Spent hours researching solutions and I tried the solutions recommended by others in this post but to no avail. Finally I contacted LinkedIn about this issue and they responded right away. Their development team has implemented a new tool called "Post Inspector", which allows you to optimize content sharing. Literally, in just minutes this actually worked.

All you have to do is type in your URL and they do all the busy work i.e. verifying correct code of properties such as image, author, title, description, publication date etc. Not only do they verify, they also tell you what code to include, what is missing, and how to fix it.

Here is the website to use Post Inspector:

https://www.linkedin.com/post-inspector/

Hispanicism answered 11/8, 2018 at 13:22 Comment(2)
Although it deserves a +1 for the link being useful, beware that the Post Inspector doesn't seem to use the same caching than e.g. the profile one. That is, if you made modifications to your website and they don't seem to be taken into account you may want to first check Kym's answer.Beeler
This worked for me and I think this should be the accepted answer. Enter your URL to the post inspector and it will update the LinkedIn cache for the URLDisfigure
T
4

LinkedIn is also caching previews. If OpenGraph image was incorrectly cached at some point before, try defeating the cache with a query parameter on a shared link, e.g. https://your-website.com/?1.

Tatianna answered 20/4, 2018 at 10:35 Comment(0)
K
3

Make sure your og: tags are part of the head tag.


I ran into this recently, spent a huge amount of time working on it with all the types of solutions above. I was working with someone else's HTML and finally figured out that the html was simply missing the head tag, while it did have the closing tag for head.

Linked In is apparently not scanning page text for the og tags, but processing the page dom, and if the dom objects aren't properly coded, they won't process. If you have issues with unmatched tags or unclosed tags, this could be your issue if everything else is not working.

I did not need to add prefix to the meta tags or add og image height and width tags once the html was fixed. Linked In processed it fine once the html was fixed.

Kendyl answered 11/3, 2019 at 17:32 Comment(0)
P
2

If you don’t want to add a fake query string parameter to your LinkedIn URLs—as suggested in e.g., @Kym's answer—a simple solution is just to sign out and then sign back in.

Paperweight answered 27/1, 2018 at 15:31 Comment(0)
A
2

Just a little late lol,

But I came across this exact issue, figured out that linkedIn was pulling the meta tags from the final landing page.

My website that i was trying to link to had an instant redirect, adding the og tags to the page where it was redirected to fixed the issue.

Avens answered 7/1, 2020 at 7:44 Comment(0)
W
1

For me solution was to put all the <meta> tags (without prefix) inside <head> tag.

For other social networks like Facebook, Twitter or Google you don't even need to have <head> tag. (because it it optional in HTML5 specs)

PS. There is a new nice way for testing <meta> tags on your website: https://metatags.io/

Whimwham answered 14/11, 2018 at 12:25 Comment(0)
R
1

After researching for a day, I found that meta tag with attribute property should be used instead of name.

<!doctype html>
<html prefix="og: http://ogp.me/ns#">
<head>
     <meta property="og:type" content="website" />
     ...

Ref: https://ogp.me/

Rood answered 21/10, 2019 at 12:29 Comment(0)
W
1

I've tried for more than half an hour and I found this one which worked 100% correctly

Source: https://www.linkedin.com/help/linkedin/answer/a521928/making-your-website-shareable-on-linkedin?lang=en

• You can also check your Open graph credentials on https://www.opengraph.xyz/

<meta name="title" property="og:title" content="Enter your title here">
<meta property="og:type" content="Enter any tyoe like Article or Website">
<meta name="description" property="og:description" content="Enter description here">
<meta name="image" property="og:image" content="Enter image URL here">
<meta property='og:url' content='Enter website URL here'/>
Widener answered 2/6, 2022 at 7:41 Comment(0)
W
0

In my case I did exactly this and it worked fine (on my page of course).

Put these four lines in the head:

<title> aanalytics </title>
<meta data-react-helmet="true" property="og:image" content="/photos/s5.jpg">
<meta data-react-helmet="true" property="og:type" content="website">
<meta data-react-helmet="true" property="og:url" content="https://www.aanalytics.de">

BUT, pay attention that if you have more than one head in your page, these lines need to be inserted in the first head otherwise it will not work.

I also had prefix="og: http://ogp.me/ns#” in the html

Worry answered 23/2, 2019 at 19:18 Comment(0)
E
0

I got it finally working by adding the full image path:

<meta name="image" property="og:image" content="https://hasan.life/images/preview.png">

Electrosurgery answered 30/9, 2020 at 12:19 Comment(0)
S
0

This is worked for me.

Somehow this problem happens if you don't set your open graph tags properly.

Instead of this:

<meta name="image" property="og:image" content="{content}" />

Try this:

<meta name="image" property="og:image" content="{content}" />
<meta property="og:image:secure_url" content="{content}" /> 
<meta property="og:image:width" content="640" /> 
<meta property="og:image:height" content="442" />
Sage answered 21/4, 2021 at 23:55 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.