adding event schema for seo (#2528)

This commit is contained in:
trean
2026-07-24 12:01:30 +02:00
committed by GitHub
parent 068dd6d2d5
commit b03b657eca
5 changed files with 117 additions and 30 deletions
@@ -0,0 +1,51 @@
{
"@type": "Event",
"@id": "{{- with .Params.link -}}{{- . -}}{{- else -}}{{- .Permalink -}}{{- end -}}#event",
"name": "{{- with .Params.event_name -}}{{- . | htmlEscape -}}{{- else -}}{{- .Title | htmlEscape -}}{{- end -}}",
"description": {{ $description := printf "%s" (.Params.description | plainify | replaceRE "(\n)" "" | replaceRE "[^\\w\\s:\\[\\]{}\"]" "" | htmlEscape ) -}}"{{- $description -}}",
{{- $image := "" -}}
{{- with .Params.social_preview_image -}}{{- $image = . | absURL -}}{{- end -}}
{{- if and (not $image) .Params.preview_image -}}{{- $image = .Params.preview_image | absURL -}}{{- end -}}
{{- if $image }}
"image": ["{{- $image -}}"],
{{- end }}
"url": "{{- with .Params.link -}}{{- . -}}{{- else -}}{{- .Permalink -}}{{- end -}}",
"startDate": "{{- .Params.start -}}"{{- with .Params.end -}},
"endDate": "{{- . -}}"{{- end -}},
"eventStatus": "{{- with .Params.eventStatus -}}{{- . -}}{{- else -}}https://schema.org/EventScheduled{{- end -}}",
{{- $attendanceMode := "https://schema.org/OfflineEventAttendanceMode" -}}
{{- if eq (lower (printf "%s" .Params.place)) "online" -}}
{{- $attendanceMode = "https://schema.org/OnlineEventAttendanceMode" -}}
{{- end -}}
{{- with .Params.eventAttendanceMode -}}{{- $attendanceMode = . -}}{{- end }}
"eventAttendanceMode": "{{- $attendanceMode -}}",
{{- if .Params.location }}
"location": {
"@type": "Place",
"name": "{{- .Params.location.name | htmlEscape -}}"{{- with .Params.location.streetAddress -}},
"address": {
"@type": "PostalAddress",
"streetAddress": "{{- . | htmlEscape -}}",
"addressLocality": "{{- $.Params.location.addressLocality | htmlEscape -}}",
"addressRegion": "{{- $.Params.location.addressRegion | htmlEscape -}}",
"postalCode": "{{- $.Params.location.postalCode | htmlEscape -}}",
"addressCountry": "{{- $.Params.location.addressCountry | htmlEscape -}}"
}{{- end -}}
},
{{- else if eq (lower (printf "%s" .Params.place)) "online" }}
"location": {
"@type": "VirtualLocation"{{- with .Params.link -}},
"url": "{{- . -}}"{{- end -}}
},
{{- else if .Params.place }}
"location": {
"@type": "Place",
"name": "{{- .Params.place | htmlEscape -}}"
},
{{- end }}
"organizer": {
"@type": "Organization",
"name": "Qdrant",
"url": "https://qdrant.tech"
}
}
@@ -12,7 +12,7 @@
"founders": [
{
"@type": "Person",
"name": "{{ .Site.Params.Author }}"
"name": "Andrey Vasnetsov"
}, {
"@type": "Person",
"name": "Andre Zayarni"
@@ -3,6 +3,19 @@ title: Vector Space Day SF 2026 Recap
description: Watch session recordings, meet the speakers, and relive Vector Space Day 2026 in San Francisco.
url: /vector-space-day-sf-26-recap/
social_preview_image: /vsd/vsd-link-preview.jpg
event_name: Vector Space Day SF 2026
start: "2026-06-11T08:30:00-07:00"
end: "2026-06-11T18:00:00-07:00"
location:
name: The Midway
streetAddress: 900 Marin St
addressLocality: San Francisco
addressRegion: CA
postalCode: "94124"
addressCountry: US
seo_schema_json:
- schema/organization-schema.json
- schema/event-schema.json
build:
render: always
cascade:
@@ -16,22 +16,15 @@
{{ 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",
"@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 -}}
]
}
{{- $data := merge (dict "@context" "https://schema.org") ($schema | unmarshal) -}}
<script type="application/ld+json">
{{ $data | jsonify | safeJS }}
</script>
{{- end -}}
{{ else if .IsHome }}
{{ $organizationTemplate := resources.Get "schema/organization-schema.json" }}
{{ $organizationSchema := $organizationTemplate | resources.ExecuteAsTemplate "schema-organization-home.json" . }}
@@ -47,6 +40,24 @@
]
}
</script>
{{ else if and (eq .Section "events") (not .IsPage) }}
{{ $organizationTemplate := resources.Get "schema/organization-schema.json" }}
{{ $organizationTarget := printf "schema-org-events-%s.json" (replaceRE "(\\s)" "" .Params.title) }}
{{ $organizationSchema := $organizationTemplate | resources.ExecuteAsTemplate $organizationTarget . }}
{{- $orgData := merge (dict "@context" "https://schema.org") ($organizationSchema | unmarshal) -}}
<script type="application/ld+json">
{{ $orgData | jsonify | safeJS }}
</script>
{{- $eventTemplate := resources.Get "schema/event-schema.json" -}}
{{- range $index, $event := .Pages -}}
{{- if not $event.Params.start -}}{{- continue -}}{{- end -}}
{{- $target := printf "schema-event-%d-%s.json" $index (replaceRE "[^a-zA-Z0-9]+" "" $event.Title) -}}
{{- $schema := $eventTemplate | resources.ExecuteAsTemplate $target $event -}}
{{- $data := merge (dict "@context" "https://schema.org") ($schema | unmarshal) -}}
<script type="application/ld+json">
{{ $data | jsonify | safeJS }}
</script>
{{- end -}}
{{ 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) }}
@@ -15,22 +15,15 @@
{{ end }}
{{ 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",
"@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 -}}
]
}
{{- $data := merge (dict "@context" "https://schema.org") ($schema | unmarshal) -}}
<script type="application/ld+json">
{{ $data | jsonify | safeJS }}
</script>
{{- end -}}
{{ else if .IsHome }}
@@ -49,6 +42,25 @@
}
</script>
{{ else if and (eq .Section "events") (not .IsPage) }}
{{ $organizationTemplate := resources.Get "schema/organization-schema.json" }}
{{ $organizationTarget := printf "schema-org-events-%s.json" (replaceRE "(\\s)" "" .Params.title) }}
{{ $organizationSchema := $organizationTemplate | resources.ExecuteAsTemplate $organizationTarget . }}
{{- $orgData := merge (dict "@context" "https://schema.org") ($organizationSchema | unmarshal) -}}
<script type="application/ld+json">
{{ $orgData | jsonify | safeJS }}
</script>
{{- $eventTemplate := resources.Get "schema/event-schema.json" -}}
{{- range $index, $event := .Pages -}}
{{- if not $event.Params.start -}}{{- continue -}}{{- end -}}
{{- $target := printf "schema-event-%d-%s.json" $index (replaceRE "[^a-zA-Z0-9]+" "" $event.Title) -}}
{{- $schema := $eventTemplate | resources.ExecuteAsTemplate $target $event -}}
{{- $data := merge (dict "@context" "https://schema.org") ($schema | unmarshal) -}}
<script type="application/ld+json">
{{ $data | jsonify | safeJS }}
</script>
{{- end -}}
{{ else if or (in (slice "documentation" "benchmarks") .Section) (and (in (slice "blog" "articles") .Section) .IsPage) }}
{{ $organizationTemplate := resources.Get "schema/organization-schema.json" }}