-
Notifications
You must be signed in to change notification settings - Fork 7
Add JSON-LD structured data for BreadcrumbList and TechArticle #282
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| {% comment %} | ||
| BreadcrumbList JSON-LD Schema.org markup | ||
| Generates breadcrumb navigation structure for SEO | ||
| {% endcomment %} | ||
| {% if page.url != "/" %} | ||
| <script type="application/ld+json"> | ||
| { | ||
| "@context": "https://schema.org", | ||
| "@type": "BreadcrumbList", | ||
| "itemListElement": [ | ||
| { | ||
| "@type": "ListItem", | ||
| "position": 1, | ||
| "name": "Home", | ||
| "item": "{{ site.url | default: 'https://docs.falkordb.com' }}" | ||
| } | ||
| {% assign position = 2 %} | ||
| {% if page.parent %} | ||
| {% comment %}Find parent page{% endcomment %} | ||
| {% assign parent_pages = site.pages | where: "title", page.parent %} | ||
| {% if parent_pages.size > 0 %} | ||
| {% assign parent = parent_pages | first %} | ||
| ,{ | ||
| "@type": "ListItem", | ||
| "position": {{ position }}, | ||
| "name": "{{ parent.title }}", | ||
| "item": "{{ site.url | default: 'https://docs.falkordb.com' }}{{ parent.url }}" | ||
| } | ||
| {% assign position = position | plus: 1 %} | ||
| {% endif %} | ||
| {% endif %} | ||
| ,{ | ||
| "@type": "ListItem", | ||
| "position": {{ position }}, | ||
| "name": "{{ page.title }}", | ||
| "item": "{{ site.url | default: 'https://docs.falkordb.com' }}{{ page.url }}" | ||
| } | ||
| ] | ||
| } | ||
| </script> | ||
| {% endif %} | ||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,39 @@ | ||||||
| {% comment %} | ||||||
| TechArticle JSON-LD Schema.org markup | ||||||
| Provides structured data for technical documentation pages | ||||||
| {% endcomment %} | ||||||
| <script type="application/ld+json"> | ||||||
| { | ||||||
| "@context": "https://schema.org", | ||||||
| "@type": "TechArticle", | ||||||
| "headline": "{{ page.title | default: site.title }}", | ||||||
| {% if page.description %} | ||||||
| "description": "{{ page.description | strip_html | strip_newlines | escape }}", | ||||||
| {% endif %} | ||||||
| "url": "{{ site.url | default: 'https://docs.falkordb.com' }}{{ page.url }}", | ||||||
| {% if page.date %} | ||||||
| "datePublished": "{{ page.date | date_to_xmlschema }}", | ||||||
| {% endif %} | ||||||
| {% if page.last_modified_at %} | ||||||
| "dateModified": "{{ page.last_modified_at | date_to_xmlschema }}", | ||||||
| {% elsif page.date %} | ||||||
| "dateModified": "{{ page.date | date_to_xmlschema }}", | ||||||
| {% endif %} | ||||||
|
Comment on lines
+17
to
+21
|
||||||
| "author": { | ||||||
| "@type": "Organization", | ||||||
| "name": "FalkorDB" | ||||||
| }, | ||||||
| "publisher": { | ||||||
| "@type": "Organization", | ||||||
| "name": "FalkorDB", | ||||||
| "logo": { | ||||||
| "@type": "ImageObject", | ||||||
| "url": "{{ site.url | default: 'https://docs.falkordb.com' }}/images/falkor-logo.png" | ||||||
|
||||||
| "url": "{{ site.url | default: 'https://docs.falkordb.com' }}/images/falkor-logo.png" | |
| "url": "{{ site.url | default: 'https://docs.falkordb.com' }}/assets/logo.png" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot the logo is in images/falkor-logo.png
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Confirmed - the logo path /images/falkor-logo.png is correct and matches the site configuration in _config.yml (line 4). The file exists and the schema is using the correct path.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Critical: Invalid JSON syntax due to conditional leading commas.
The JSON-LD BreadcrumbList has a fatal flaw in how commas are handled around conditionally-rendered items.
When the parent block (lines 18–31) does not render, the resulting JSON is:
This violates JSON syntax and will be rejected by search engines. Similarly, when the parent block does render, you get a double-comma sequence (
},\n ,{), which is also invalid.The root cause: The leading commas at lines 23 and 32 assume a preceding element, but JSON requires commas between elements, not before them.
Suggested fix: Move the comma after the Home item and handle the parent conditionally:
{ "@type": "ListItem", "position": 1, "name": "Home", "item": "{{ site.url | default: 'https://docs.falkordb.com' }}" - } + }, {% assign position = 2 %} {% if page.parent %} {% comment %}Find parent page{% endcomment %} {% assign parent_pages = site.pages | where: "title", page.parent %} {% if parent_pages.size > 0 %} {% assign parent = parent_pages | first %} - ,{ + { "@type": "ListItem", "position": {{ position }}, "name": "{{ parent.title }}", "item": "{{ site.url | default: 'https://docs.falkordb.com' }}{{ parent.url }}" - } + }, {% assign position = position | plus: 1 %} {% endif %} {% endif %} - ,{ + { "@type": "ListItem", "position": {{ position }}, "name": "{{ page.title }}", "item": "{{ site.url | default: 'https://docs.falkordb.com' }}{{ page.url }}" } ]This ensures the JSON array maintains valid syntax regardless of whether the parent element is present.