Created
February 23, 2022 02:28
-
-
Save DerekHawkins/6de0d34c195d175542933e54fc12a2f4 to your computer and use it in GitHub Desktop.
This file contains 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
### Schema Build ### | |
def SchemaBuild(author, title, url, datePub, dateMod, image, des): | |
builder = SchemaBuilder() | |
builder.add_schema({"@type": "Article"}) | |
builder.add_schema({"publisher": {'@type':'Organization', | |
'name': 'Your Organization', | |
'logo':{ | |
'@type':'ImageObject', | |
'url':'example.com/image.png', # the URL of your logo | |
'width':'xxx', | |
'height':'xxx' | |
}}}) | |
builder.add_schema({"author": {'@type':'Person', | |
'name': author}}) | |
builder.add_schema({"headline": title}) | |
builder.add_schema({"url": url}) | |
builder.add_schema({"datePublished": datePub}) | |
builder.add_schema({"dateModified": dateMod}) | |
builder.add_schema({"image": image}) | |
builder.add_schema({"description": des}) | |
builder.add_schema({'mainEntityOfPage':{ | |
'@type':'WebPage', | |
'@id':'https://www.example.com' # your website | |
}}) | |
meta_data = builder.to_schema() | |
meta_data['$schema'] = 'http://schema.org' | |
meta_data["@context"] = meta_data['$schema'] | |
del meta_data['$schema'] | |
meta = json.dumps(meta_data) | |
return meta |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment