dont display special LD data on services for now

This commit is contained in:
Tobias Brunner 2025-07-11 09:41:27 +02:00
parent 48affa7000
commit 08b8175574
No known key found for this signature in database

View file

@ -106,37 +106,38 @@ def json_ld_structured_data(context):
} }
elif view_name == "service_detail" and "service" in context: elif view_name == "service_detail" and "service" in context:
service = context["service"] data = organization_data
service_url = request.build_absolute_uri()
# Check if service has offerings with pricing # service = context["service"]
has_offerings = hasattr(service, "offerings") and service.offerings.exists() # service_url = request.build_absolute_uri()
# # Check if service has offerings with pricing
# has_offerings = hasattr(service, "offerings") and service.offerings.exists()
if has_offerings: # if has_offerings:
# Use Product type when we have offerings (which provide the required offers data) # # Use Product type when we have offerings (which provide the required offers data)
data = { # data = {
"@context": "https://schema.org", # "@context": "https://schema.org",
"@type": "Product", # "@type": "Product",
"name": service.name, # "name": service.name,
"description": service.description, # "description": service.description,
"url": service_url, # "url": service_url,
"category": "Cloud Service", # "category": "Cloud Service",
} # }
# Add image if available # # Add image if available
if hasattr(service, "get_logo") and service.get_logo: # if hasattr(service, "get_logo") and service.get_logo:
data["image"] = request.build_absolute_uri(service.get_logo.url) # data["image"] = request.build_absolute_uri(service.get_logo.url)
# Add offerings # # Add offerings
data["offers"] = { # data["offers"] = {
"@type": "AggregateOffer", # "@type": "AggregateOffer",
"availability": "https://schema.org/InStock", # "availability": "https://schema.org/InStock",
"offerCount": service.offerings.count(), # "offerCount": service.offerings.count(),
} # }
else: # else:
# Use Organization data when no offerings are available # # Use Organization data when no offerings are available
# This avoids Google Search Console errors for Product without required fields # # This avoids Google Search Console errors for Product without required fields
data = organization_data # data = organization_data
elif view_name == "provider_detail" and "provider" in context: elif view_name == "provider_detail" and "provider" in context:
provider = context["provider"] provider = context["provider"]