I am using reactjs , i want to share my content in facebook,it is happening but after sharing it is not showing images,title,description of the content. so I used react-helmet to dynamically add meta tags in index.html.
<Helmet>
<meta property="og:type" content="video.other" />
<meta property="og:image" content="https://www.w3schools.com/css/trolltunga.jpg" />
<meta property="og:title" content="My Title" />
<meta property="og:url" content="https://www.afnity.com/video/155" />
<meta property="og:description" content="some discription of the shared content" />
</Helmet>
and here is the share button
<button> <a title="dummy"
href="http://www.facebook.com/sharer.php? u=https://dummy.com/videos/id=25" target="_blank">
share</a>
</button>
but it is not working.
The meta description is a short text preview displayed for each search result that summarizes a page's content. Search engines show the meta description when it's highly relevant to what the user is searching otherwise they might pick text from the page and create a dynamic description.
As the building blocks of React applications, components are dynamic, in that they can describe a template of HTML and fill in variable data. This lesson builds a real example of a blogging application to illustrate dynamic components.
This can be achieved using react-document-meta npm module when server side rendering enabled in your react application
const meta = {
title: 'Samvikshana - New Perspective of Exploration',
meta: {
property: {
'og:title': 'Samvikshana',
'og:url': 'https://samvikshana.weebly.com/',
'og:image': imageUri,
'og:description': 'New Perspective of Exploration',
'twitter:card': 'summary_large_image',
'twitter:title': 'Samvikshana',
'twitter:description': 'New Perspective of Exploration',
'twitter:image': imageUri
}
}
};
return (
<div className='container-fluid'>
<DocumentMeta {...meta} />
</div>);
}
Read this blog for more information - https://samvikshana.weebly.com/blog/dynamic-meta-tags-in-react-components
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With