How to successfully implement og:image for the LinkedIn

有些话、适合烂在心里 提交于 2019-12-02 19:56:43
GothamCityRises

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.

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

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/

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.

This may be a bit late for the OP, but there is new documentation at https://www.linkedin.com/help/linkedin/answer/46687/making-your-website-shareable-on-linkedin. Hopefully this helps others.

If @Kym's answer works for you, and you don't want to have a fake URL parameter in your LinkedIn links, a simple solution is just to sign out and then sign back in.

*Writing my own answer since I don't have enough rep to comment on theirs

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.

I spent whole day implementing it. My main criteria was to do it for all my posts without touching even a single post in Wordpress.

LinkedIn solution didn't work. Also LinkedIn caches the images for 7 days and if you changed the image, you are not able to look at refreshed image. So these were the constraints and I was able to implement it using some PHP, Javascript and using dummy parameter to refresh LinkedIn cache. Here's the solution

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/

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

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/

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!