add LD data for articles
This commit is contained in:
parent
08b8175574
commit
c0c27cd056
2 changed files with 75 additions and 0 deletions
Binary file not shown.
Before Width: | Height: | Size: 32 KiB After Width: | Height: | Size: 22 KiB |
|
@ -297,6 +297,81 @@ def json_ld_structured_data(context):
|
||||||
"seller": {"@type": "Organization", "name": "VSHN"},
|
"seller": {"@type": "Organization", "name": "VSHN"},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
elif view_name == "article_list":
|
||||||
|
data = {
|
||||||
|
"@context": "https://schema.org",
|
||||||
|
"@type": "CollectionPage",
|
||||||
|
"name": "Servala Articles",
|
||||||
|
"url": f"{base_url}/articles/",
|
||||||
|
"description": "Read our latest articles about cloud services, best practices, and industry insights.",
|
||||||
|
"isPartOf": {"@type": "WebSite", "name": "Servala", "url": base_url},
|
||||||
|
}
|
||||||
|
|
||||||
|
elif view_name == "article_detail" and "article" in context:
|
||||||
|
article = context["article"]
|
||||||
|
article_url = request.build_absolute_uri()
|
||||||
|
|
||||||
|
data = {
|
||||||
|
"@context": "https://schema.org",
|
||||||
|
"@type": "Article",
|
||||||
|
"headline": article.title,
|
||||||
|
"description": article.excerpt,
|
||||||
|
"url": article_url,
|
||||||
|
"author": {
|
||||||
|
"@type": "Person",
|
||||||
|
"name": article.author.get_full_name() or article.author.username,
|
||||||
|
},
|
||||||
|
"publisher": {
|
||||||
|
"@type": "Organization",
|
||||||
|
"name": "Servala",
|
||||||
|
"logo": {
|
||||||
|
"@type": "ImageObject",
|
||||||
|
"url": f"{base_url}/static/img/servala-logo.png",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
# Add publication date using article_date field
|
||||||
|
if article.article_date:
|
||||||
|
data["datePublished"] = article.article_date.isoformat()
|
||||||
|
|
||||||
|
# Add modification date
|
||||||
|
if article.updated_at:
|
||||||
|
data["dateModified"] = article.updated_at.isoformat()
|
||||||
|
|
||||||
|
# Add image using the model's get_image property or get_og_image
|
||||||
|
if article.get_og_image:
|
||||||
|
data["image"] = request.build_absolute_uri(article.get_og_image.url)
|
||||||
|
elif article.get_image:
|
||||||
|
data["image"] = request.build_absolute_uri(article.get_image.url)
|
||||||
|
|
||||||
|
# Add keywords from meta_keywords field
|
||||||
|
if article.meta_keywords:
|
||||||
|
data["keywords"] = article.meta_keywords
|
||||||
|
|
||||||
|
# Add main entity of page
|
||||||
|
data["mainEntityOfPage"] = {
|
||||||
|
"@type": "WebPage",
|
||||||
|
"@id": article_url,
|
||||||
|
}
|
||||||
|
|
||||||
|
# Add about field based on related entities
|
||||||
|
if article.related_service:
|
||||||
|
data["about"] = {
|
||||||
|
"@type": "SoftwareApplication",
|
||||||
|
"name": article.related_service.name,
|
||||||
|
}
|
||||||
|
elif article.related_consulting_partner:
|
||||||
|
data["about"] = {
|
||||||
|
"@type": "Organization",
|
||||||
|
"name": article.related_consulting_partner.name,
|
||||||
|
}
|
||||||
|
elif article.related_cloud_provider:
|
||||||
|
data["about"] = {
|
||||||
|
"@type": "Organization",
|
||||||
|
"name": article.related_cloud_provider.name,
|
||||||
|
}
|
||||||
|
|
||||||
else:
|
else:
|
||||||
# Default to organization data if no specific page type matches
|
# Default to organization data if no specific page type matches
|
||||||
data = organization_data
|
data = organization_data
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue