Fix seo schema (#727)

* adding seo schema from json file

* range trought schema files list

* article json-ld, all schemas from files

* fixes

* fixes

* seo schema fixes

* fix
This commit is contained in:
trean
2024-04-03 00:00:56 +02:00
committed by GitHub
parent 7cb80f1993
commit 8acc0ade70
5 changed files with 233 additions and 85 deletions
@@ -14,101 +14,85 @@
<meta name="keywords" content="{{ range .Site.Params.Keywords }}{{ . }}, {{ end }} qdrant">
{{ end }}
{{ if .IsHome }}
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "Organization",
"name": "Qdrant",
"legalName" : "Qdrant Solutions GmbH",
"url": "https://qdrant.tech",
"email": "info@qdrant.com",
"@id": "https://qdrant.tech",
"logo": "https://qdrant.tech/images/logo_with_text.png",
"headline" : "{{ .Title }}",
"description" : "{{ .Site.Params.description }}",
"keywords" : [ {{ range .Site.Params.Keywords }}"{{ . }}", {{ end }} "Qdrant" ],
"foundingDate": "2021",
"founders": [
{
"@type": "Person",
"name": "{{ .Site.Params.Author }}"
}, {
"@type": "Person",
"name": "Andre Zayarni"
}
],
"location": "Berlin, Germany",
"address": {
"@type": "PostalAddress",
"streetAddress": "Chausseestraße 86",
"addressLocality": "Berlin",
"addressRegion": "Berlin",
"postalCode": "10115",
"addressCountry": "DE"
},
"contactPoint": {
"@type": "ContactPoint",
"contactType": "customer support",
"telephone": "+49 3040797694",
"email": "info@qdrant.com"
},
"sameAs": [
{{ .Site.Params.github }},
{{ .Site.Params.twitter }},
{{ .Site.Params.linkedin }},
{{ .Site.Params.discord }}
],
"mainEntityOfPage": {
"@type": "SoftwareApplication",
"name": "Qdrant",
"applicationCategory": "Vector Search Engine",
"operatingSystem": "linux, macOS",
"downloadUrl": "https://github.com/qdrant/qdrant",
"installUrl": "https://hub.docker.com/r/qdrant/qdrant",
"abstract": "{{ .Site.Params.description }}",
"image": "https://qdrant.tech/images/logo_with_text.png"
}
}
</script>
{{ else if .Params.seo_schema }}
<!-- todo: use as default option -->
<script type="application/ld+json">
{{ .Params.seo_schema }}
</script>
{{ else if and (eq .Section "articles") .IsPage }}
{{ if .Params.seo_schema_json }} <!-- if schema is defined in front matter as a list of json files -->
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "Article",
"headline": "{{ .Params.title }}",
"image": [
{{ .Params.social_preview_image | absURL }},
],
"abstract": {{ .Params.description }},
"datePublished": {{ .Params.date }},
"dateModified": {{ .Params.date }},
"author": [{
"@type": "Person",
"name": {{ .Params.author }},
"url": {{ .Params.author_link }}
}]
"@graph":
[
{{- $context := . -}}
{{- range $index, $element := .Params.seo_schema_json -}}
{{- $template := resources.Get $element -}}
{{- $schema := $template | resources.ExecuteAsTemplate (printf "schema%d.json" $index) $context -}}
{{ $schema | unmarshal }}
{{- if not (eq $index (sub (len $.Params.seo_schema_json) 1)) -}},
{{- end -}}
{{- end -}}
]
}
</script>
{{ else if and (eq .Section "case-studies") .IsPage }}
{{ else if .IsHome }}
{{ $organizationTemplate := resources.Get "schema/organization-schema.json" }}
{{ $organizationSchema := $organizationTemplate | resources.ExecuteAsTemplate "schema-organization-home.json" . }}
{{ $productTemplate := resources.Get "schema/product-schema.json" }}
{{ $productSchema := $productTemplate | resources.ExecuteAsTemplate "schema-product-home.json" . }}
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "Article",
"headline": "{{ .Params.title }}",
"image": [
{{ .Params.social_preview_image | absURL }},
],
"abstract": {{ .Params.description }},
"datePublished": {{ .Params.date }},
"dateModified": {{ .Params.date }}
"@graph": [
{{ $organizationSchema | unmarshal }},
{{ $productSchema | unmarshal }}
]
}
</script>
{{ else if or (in (slice "documentation" "benchmarks") .Section) (and (in (slice "blog" "articles") .Section) .IsPage) }}
{{ $organizationTemplate := resources.Get "schema/organization-schema.json" }}
{{ $organizationTarget := printf "schema-org-1-%s.json" (replaceRE "(\\s)" "" .Params.title) }}
{{ $organizationSchema := $organizationTemplate | resources.ExecuteAsTemplate $organizationTarget . }}
{{ $articleTemplate := resources.Get "schema/article-schema.json" }}
{{ $articleTarget := printf "schema-art-%s.json" (replaceRE "(\\s)" "" .Params.title) }}
{{ $articleSchema := $articleTemplate | resources.ExecuteAsTemplate $articleTarget . }}
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@graph": [
{{ $articleSchema | unmarshal }},
{{ $organizationSchema | unmarshal }}
]
}
</script>
{{ else }}
{{ $organizationTemplate := resources.Get "schema/organization-schema.json" }}
{{ $organizationTarget := printf "schema-org-2-%s.json" (replaceRE "(\\s)" "" .Params.title) }}
{{ $organizationSchema := $organizationTemplate | resources.ExecuteAsTemplate $organizationTarget . }}
{{ $productTemplate := resources.Get "schema/product-schema.json" }}
{{ $productTarget := printf "schema-prod-%s.json" (replaceRE "(\\s)" "" .Params.title) }}
{{ $productSchema := $productTemplate | resources.ExecuteAsTemplate $productTarget . }}
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@graph": [
{{ $organizationSchema | unmarshal }},
{{ $productSchema | unmarshal }}
]
}
</script>
{{ end }}
{{ if .Params.seo_schema }} <!-- if schema is defined in front matter -->
<script type="application/ld+json">
{{ .Params.seo_schema | jsonify | unmarshal }}
</script>
{{ end }}
{{ $url := urls.Parse .Site.BaseURL }}