Skip to content

Add FAQ Schema (JSON-LD) support for native Gutenberg FAQ block and GenerateBlocks Accordion #130

@davidperezgar

Description

@davidperezgar

Feature Request: FAQ Schema (JSON-LD) Support

Description

Add the ability to inject a FAQPage JSON-LD structured data schema into pages that contain FAQ content. This should work for:

  1. Native Gutenberg FAQ block — with an opt-in toggle (checkbox) in the block settings sidebar to enable schema generation.
  2. GenerateBlocks Accordion block — compatible integration so FAQ schema is also generated when using the GenerateBlocks Accordion as a FAQ.

Expected Schema Output

When enabled, the following JSON-LD script should be injected into the page <head> or inline at the bottom of the block:

<script type="application/ld+json">
{
  "@context": "https://schema.org",
  "@type": "FAQPage",
  "mainEntity": [{
    "@type": "Question",
    "name": "How to find an apprenticeship?",
    "acceptedAnswer": {
      "@type": "Answer",
      "text": "<p>We provide an official service to search through available apprenticeships. To get started, create an account here, specify the desired region, and your preferences. You will be able to search through all officially registered open apprenticeships.</p>"
    }
  }, {
    "@type": "Question",
    "name": "Whom to contact?",
    "acceptedAnswer": {
      "@type": "Answer",
      "text": "You can contact the apprenticeship office through our official phone hotline above, or with the web-form below. We generally respond to written requests within 7-10 days."
    }
  }]
}
</script>

Proposed Behaviour

Native Gutenberg FAQ Block

  • Add a toggle/checkbox in the block inspector panel (sidebar) labeled something like "Add FAQ Schema (JSON-LD)".
  • When enabled, the plugin reads the question/answer pairs from the block content and generates the FAQPage JSON-LD structure.
  • The script tag is injected into the page <head> using wp_head or equivalent.

GenerateBlocks Accordion

  • Detect when a GenerateBlocks Accordion is being used as a FAQ (e.g. via a dedicated toggle in the block settings or a CSS class convention).
  • When enabled, parse the accordion items (title = question, content = answer) and generate the same FAQPage JSON-LD output.

Why This Matters

FAQ structured data helps search engines understand Q&A content and can enable rich results in Google Search (expandable FAQ entries in SERPs), improving SEO and click-through rates.

Reference: Google FAQ Rich Results documentation


Acceptance Criteria

  • Toggle added to native Gutenberg FAQ block inspector panel.
  • When toggle is ON, valid FAQPage JSON-LD is injected in the page <head>.
  • Schema correctly reflects all question/answer pairs in the block.
  • GenerateBlocks Accordion has an equivalent opt-in toggle.
  • When enabled on an Accordion, FAQ schema is generated from accordion item titles and content.
  • No schema is output when the toggle is OFF.
  • Schema validates correctly with Google's Rich Results Test.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions