ai_jsonld_schema_generator
No security coverage
This module helps site builders and content editors add schema.org JSON-LD structured data to a Drupal site without writing JSON by hand. It uses the Drupal AI (Artificial Intelligence) module to generate valid schema from your content or from any internal URL. JSON-LD is output in the page <head>, which can improve how search engines and other tools understand your pages (e.g. rich results, knowledge panels). The module works with any AI provider configured in the AI module (e.g. OpenAI) and supports both content-based schema (per node) and URL-based schema (per path), with preview, validation, and optional auto-generation on publish or update.
Features
What is the basic functionality?
- AI-generated JSON-LD: Uses the Drupal AI module to generate schema.org JSON-LD from page content or from a fetched URL. No direct external API keys in this module—all calls go through the AI module.
- Content (node) schema: For enabled content types, a "Generate Schema via AI" button appears on the node edit form. After generation you get a preview, can fix or regenerate, then save. Schema is stored by path and attached when that page is viewed.
- URL-based schema: You can add any internal path (e.g. /about, /services) and have the module fetch the page, extract text, and ask the AI to produce schema. Results are saved as "Schema mappings" and attached when that path is viewed.
- Output: One or more
<script type="application/ld+json">blocks are added to the page<head>for the current path. Site-wide Organization/WebSite can be set once in configuration.
What unique features does enabling this project add?
- Multiple schema types per page: The AI can return several schema.org types in one go (e.g. Article + BreadcrumbList, WebPage + FAQPage). Each is validated and output as a separate JSON-LD block.
- Preview and validation: Before saving, you see a preview of all blocks and validation messages (e.g. missing @context/@type). You can open a link to Google Rich Results Test to double-check.
- Configurable prompt: A single prompt template (with
{{ content }}) drives generation. The default prompt is content-based: the AI infers types (Article, Event, Service, BreadcrumbList, FAQPage, etc.) from the text. You can customize the prompt in the settings form. - Optional auto-generation: Optionally generate schema when a node is first published or when it is updated, so editors don't have to click "Generate" every time.
- Rate limiting: Configurable limits (e.g. N generations per user per hour) via Drupal's Flood API to avoid overuse of the AI provider.
- Token-based or full-page content: For nodes, you can send either a token-rendered snippet (e.g. title, body, URL) or the full rendered page (including blocks) to the AI.
When and why would someone use this module?
- You want rich results or better indexing (e.g. articles, events, FAQs, breadcrumbs) and prefer not to maintain JSON-LD by hand.
- You want schema generated from existing content or from any URL on the site, with a single UI and optional automation.
- You already use or plan to use the Drupal AI module and want a dedicated, SEO-focused workflow for structured data.
What use cases are there?
- Editorial / marketing sites: Article, BlogPosting, breadcrumbs, author, dates; optional Organization/WebSite site-wide.
- Product or service sites: Product, Service, FAQPage, HowTo, ContactPage, AboutPage.
- Events / webinars: Event schema with date, location, performers.
- List/landing pages: ItemList, WebPage; optional BreadcrumbList when breadcrumb text is provided.
- Mixed content: One prompt and one workflow for many content types; the AI chooses the right types per page.
Post-Installation
How does this module work once I install it?
- Configuration: Go to Configuration → AI (or Configuration → AI JSON-LD Schema Generator if your menu is flat). The main settings page is the AI JSON-LD Schema Generator link.
- Required setup: Choose an AI provider and model (from the AI module's configured providers) or leave default. Enable at least one content type that should show the "Generate Schema via AI" button.
- Optional site-wide schema: In the same form you can paste Organization and WebSite JSON-LD (with tokens like [site:name], [site:url] if supported). These are attached on every page so the AI doesn't need to output them per URL.
- Content workflow: Edit a node of an enabled content type. Use "Generate Schema via AI" (or "Preview Generated Schema" / "Edit Generated Schema" if you already have schema). On the preview page, review blocks and validation, then Save schema or Regenerate.
- URL-based workflow: Open Schema mappings (from the same config section). Add a new mapping or use the URL generator: enter an internal path, generate, then preview and save. Those mappings are attached when the path is visited.
- No new content type: The module does not create a content type. It adds a button to existing node edit forms and stores schema in an internal entity keyed by path.
- Permissions: Assign "Generate AI schema" to roles that may generate schema; "Administer AI schema settings" for the config form; "Manage URL schema" for Schema mappings and the URL generator.
Special considerations
- Schema is generated from saved node content (or from the live URL for URL-based generation). For nodes, save the node first if you just edited it, then generate.
- Rate limits apply to both node and URL generation; when exceeded, users see a message and auto-generation is skipped (node save still succeeds).
- Clearing caches may be needed after changing site-wide schema or after installing the module.
Additional Requirements
Beyond Drupal core, this project needs:
- Drupal 11 (core_version_requirement: ^11).
- AI (Artificial Intelligence) module (drupal.org/project/ai) — required. All AI calls go through this module.
- At least one configured AI provider in the AI module (e.g. OpenAI via drupal.org/project/ai_provider_openai), with valid API credentials configured there.