Last active
May 5, 2023 13:01
-
-
Save KartikWatts/14c652dc64c15a812dd0486473defa1b to your computer and use it in GitHub Desktop.
Custom Html Script for `BlogPosting` type `Article` in Google structured data
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
(function(){ | |
var schema= | |
{ | |
"@context": "http://schema.org", | |
"@type": "BlogPosting", | |
"mainEntityOfPage": { | |
"@type": "WebPage", | |
"@id": {{Page URL}} | |
}, | |
"headline": {{Blog_Headline}}, | |
"image": { | |
"@type": "ImageObject", | |
"url": {{Blog_Image_URL}}, | |
}, | |
"author": { | |
"@type": "Person", | |
"name": {{Blog_Author_Name}}, | |
"url": {{Blog_Author_URL}} | |
}, | |
"datePublished": {{Blog_Date_Published}}, | |
"publisher": { | |
"@type": "Organization", | |
"name": {{Blog_Publisher_Name}}, | |
"logo": { | |
"@type": "ImageObject", | |
"url": {{Blog_Publisher_Logo_URL}}, | |
} | |
}, | |
"description": {{Blog_Description}} | |
} | |
// TODO:: These details can be added | |
// "dateModified": {{Blog_Date_Modified}}, | |
var script=document.createElement('script'); | |
script.type="application/ld+json"; | |
script.innerHTML=JSON.stringify(schema); | |
document.getElementsByTagName('head')[0].appendChild(script); | |
})(document); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment