Skip to content

Commit b675dfc

Browse files
Add schema.org JSON-LD structured data
Docsy calls Hugo's _internal/schema.html, which emits only a handful of sparse microdata meta tags. Search engines and retrieval systems get no explicit signal about what kind of page they are looking at, who publishes it, or when it was last updated. Emits one JSON-LD block per page: - WebSite on the home page - TechArticle for documentation pages - BlogPosting for blog posts, with datePublished and author All three carry an Organization publisher and inLanguage, so the four language variants are described accurately. dateModified comes from .Lastmod, which is already backed by git commit dates via enableGitInfo, making freshness explicit rather than something a crawler has to guess. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
1 parent e61746b commit b675dfc

1 file changed

Lines changed: 51 additions & 1 deletion

File tree

website_and_docs/layouts/partials/hooks/head-end.html

Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
<script src="/js/docsearch-fix.js"></script>
66
{{ end }}
77
{{/*
8-
Canonical and hreflang links. Docsy emits neither for HTML pages.
8+
Canonical and hreflang links, and schema.org structured data. Docsy emits no
9+
canonical link and no hreflang alternates, and its call to Hugo's
10+
_internal/schema.html produces only sparse microdata.
911

1012
Skipped for the "print" output format, whose pages already get a canonical
1113
link pointing back at the HTML page from Docsy's own alternate-format loop.
@@ -30,4 +32,52 @@
3032
{{- end }}
3133
{{- end }}
3234
{{- end }}
35+
36+
{{- $publisher := dict
37+
"@type" "Organization"
38+
"name" "Selenium"
39+
"url" .Site.BaseURL
40+
"logo" (dict "@type" "ImageObject" "url" (absURL "images/selenium_logo_square_green.png"))
41+
"sameAs" (slice
42+
"https://github.com/SeleniumHQ/selenium"
43+
"https://www.linkedin.com/company/4826427/"
44+
"https://x.com/SeleniumHQ"
45+
"https://www.youtube.com/@SeleniumHQProject/") -}}
46+
{{- $ld := false -}}
47+
{{- if .IsHome -}}
48+
{{- $ld = dict
49+
"@context" "https://schema.org"
50+
"@type" "WebSite"
51+
"name" .Site.Title
52+
"url" .Site.BaseURL
53+
"description" .Site.Params.description
54+
"inLanguage" .Language.Lang
55+
"publisher" $publisher -}}
56+
{{- else if eq .Section "documentation" -}}
57+
{{- $ld = dict
58+
"@context" "https://schema.org"
59+
"@type" "TechArticle"
60+
"headline" .Title
61+
"url" .Permalink
62+
"inLanguage" .Language.Lang
63+
"dateModified" (.Lastmod.Format "2006-01-02")
64+
"publisher" $publisher
65+
"isPartOf" (dict "@type" "WebSite" "name" .Site.Title "url" .Site.BaseURL) -}}
66+
{{- with .Description }}{{ $ld = merge $ld (dict "description" .) }}{{ end -}}
67+
{{- else if eq .Section "blog" -}}
68+
{{- $ld = dict
69+
"@context" "https://schema.org"
70+
"@type" "BlogPosting"
71+
"headline" .Title
72+
"url" .Permalink
73+
"inLanguage" .Language.Lang
74+
"datePublished" (.Date.Format "2006-01-02")
75+
"dateModified" (.Lastmod.Format "2006-01-02")
76+
"publisher" $publisher -}}
77+
{{- with .Description }}{{ $ld = merge $ld (dict "description" .) }}{{ end -}}
78+
{{- with .Params.author }}{{ $ld = merge $ld (dict "author" (dict "@type" "Person" "name" .)) }}{{ end -}}
79+
{{- end }}
80+
{{- with $ld }}
81+
<script type="application/ld+json">{{ . | jsonify (dict "indent" " ") | safeJS }}</script>
82+
{{- end }}
3383
{{ end }}

0 commit comments

Comments
 (0)