Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

LinkedIn URL preview not working while sharing

I have created a simple Node.js web server to render html content on the browser. Specifically the html contains meta tags for sharing on social media to enable URL preview as soon as the website link is shared on social platforms like FB,Twitter,LinkedIn,etc.

I have already added open graph tags for sharing in the returned html content. It works well for FB and Twitter but gives an error with "We encountered a server error while trying to inspect the URL." as response.

Here is code of server with a dummy endpoint.

const express=require('express');
const app = express();

require('dotenv').config();

app.get('/dummy',(req,res)=>{
    res.send(`
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>Dummy Endpoint</title>
        <meta name="type" content="article" />
        <meta name="title" content="Dummy Endpoint"/>
        <meta name="description" content="Used for testing"/>
        <meta name="image" content="https://www.kindpng.com/picc/m/252-2524695_dummy-profile-image-jpg-hd-png-download.png"/>
        <meta property="og:type" content="article"/>
        <meta property="og:title" content="Dummy endpoint"/>
        <meta property="og:description" content="Used for testing"/>
        <meta property="og:image" content="https://www.kindpng.com/picc/m/252-2524695_dummy-profile-image-jpg-hd-png-download.png"/>
        <meta property="og:image:secure_url" content="https://www.kindpng.com/picc/m/252-2524695_dummy-profile-image-jpg-hd-png-download.png"/>
        <meta property="og:image:secure" content="https://www.kindpng.com/picc/m/252-2524695_dummy-profile-image-jpg-hd-png-download.png"/>
        <meta property="og:image:width" content="600" />
        <meta property="og:image:height" content="450" />
        <meta name="twitter:title" content="Dummy Endpoint"/>
        <meta name="twitter:description" content="Dummy endpoint"/>
        <meta name="twitter:image" content="https://www.kindpng.com/picc/m/252-2524695_dummy-profile-image-jpg-hd-png-download.png"/>
        <meta name="twitter:card" content="summary"/>
    `)
})

app.listen(process.env.PORT || 5000, () => {
    console.log('Server started at '+process.env.PORT)
});


Website link : https://whispering-woodland-66525.herokuapp.com/dummy (Page is empty, check head section in Inspect)

Response of Facebook sharing debugger : https://developers.facebook.com/tools/debug/?q=http%3A%2F%2Fwhispering-woodland-66525.herokuapp.com%2Fdummy

Response of LinkedIn Post Inspector : https://www.linkedin.com/post-inspector/inspect/https:%2F%2Fwhispering-woodland-66525.herokuapp.com%2Fdummy

I have tried out refreshing the Post Inspector page multiple time and adding a dummy query parameter to the the url in the Post Inspector to prevent serving of cached content, but things are not working out.

I am unable to understand if there is something wrong or missing in the code or is it a problem with LinkedIn web crawlers.

like image 445
Vaidesh Shankar Avatar asked Mar 08 '26 03:03

Vaidesh Shankar


1 Answers

I believe LinkedIn Post Inspector is expecting a complete HTML document. Consider wrapping your metadata into the header of the document. Try returning:

<!DOCTYPE html>
  <html lang="en">
    <head>
       <meta charset="UTF-8">
       <meta name="viewport" content="width=device-width, initial-scale=1.0">
       <title>Dummy Endpoint</title>
       <meta name="type" content="article" />
       <meta name="title" content="Dummy Endpoint"/>
       <meta name="description" content="Used for testing"/>
       <meta name="image" content="https://www.kindpng.com/picc/m/252-2524695_dummy-profile-image-jpg-hd-png-download.png"/>
       <meta property="og:type" content="article"/>
       <meta property="og:title" content="Dummy endpoint"/>
       <meta property="og:description" content="Used for testing"/>
       <meta property="og:image" content="https://www.kindpng.com/picc/m/252-2524695_dummy-profile-image-jpg-hd-png-download.png"/>
       <meta property="og:image:secure_url" content="https://www.kindpng.com/picc/m/252-2524695_dummy-profile-image-jpg-hd-png-download.png"/>
       <meta property="og:image:secure" content="https://www.kindpng.com/picc/m/252-2524695_dummy-profile-image-jpg-hd-png-download.png"/>
       <meta property="og:image:width" content="600" />
       <meta property="og:image:height" content="450" />
       <meta name="twitter:title" content="Dummy Endpoint"/>
       <meta name="twitter:description" content="Dummy endpoint"/>
       <meta name="twitter:image" content="https://www.kindpng.com/picc/m/252-2524695_dummy-profile-image-jpg-hd-png-download.png"/>
       <meta name="twitter:card" content="summary"/>
   </head>
</html>
like image 164
TuanGeek Avatar answered Mar 09 '26 22:03

TuanGeek



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!