ai_schema_markup_generator
Introduction
The AI Schema Markup Generator module automatically creates Schema.org JSON-LD structured data for Drupal content using OpenAI. Instead of manually writing complex schema markup, the module reads node fields, sends the content to the OpenAI API, and generates valid structured data that is automatically injected into the page head.
This helps search engines better understand your content and improves eligibility for rich results in search engines without requiring manual schema configuration.
Automatically generate Schema.org JSON-LD structured data for Drupal nodes using AI, improving SEO and search visibility with zero manual markup effort.
Features
- Automatic on-save generation – When a node is saved with schema generation enabled, the module sends the node's field data to OpenAI and stores the generated JSON-LD schema directly on the node.
- AI-powered schema type detection – The AI automatically determines the most appropriate Schema.org
@type(such as Article, Event, Product, or Person) based on the content. - AI schema validation – Generated schema is validated using AI. If the schema is invalid, the module requests a corrected version and stores the fixed result.
- Bulk schema generation – An administrative batch interface allows schema generation and validation for large numbers of existing nodes.
- Multilingual support – Bulk schema generation supports language filtering.
- Per-node opt-in checkbox – A Schema JSON section appears in the node edit form where editors can enable or disable schema generation.
- Automatic JSON-LD injection – The generated schema is automatically embedded into the HTML head as a
<script type="application/ld+json">tag. - Customisable prompts – Administrators can configure the prompts used for schema generation and validation.
- Field exclusion list – Administrators can exclude specific fields from being sent to the AI prompt.
- Content type defaults – Schema generation can be enabled by default for selected content types.
- CSV export – Bulk generation results can be exported as a CSV report.
- Drupal logging – All API calls, successes, failures, and validation events are logged in Drupal watchdog.
Typical use cases
- News or blog sites generating Article or NewsArticle schema
- Event websites using Event structured data
- E-commerce sites using Product schema
- Any Drupal site where manual Schema.org markup is difficult to maintain
Post-Installation
1. Run database updates
drush updb
The module will create two fields on nodes:
- field_schema_json
- field_schema_json_checkbox
2. Configure the module
Go to:
Administration → Configuration → AI Schema Markup Generator /admin/config/ai-schema-markup-generator/settings
Configure the following settings:
- API Endpoint
- OpenAI Access Token
- Model Name
- Max Tokens
- Max Context Length
- Temperature
- Schema Generation Prompt
- Validation Prompt
- Exclude Fields
- Enable for Content Types
3. Enable schema generation on nodes
Edit or create a node and expand the Schema JSON section in the Advanced sidebar. Enable the checkbox and save the node. The module will generate and validate schema automatically.
4. View generated schema
Visit the node page and inspect the HTML source. The schema will appear inside:
<script type="application/ld+json"> ... </script>
5. Bulk generate schema for existing content
Administration → Configuration → AI Schema Markup Generator → Bulk Generate /admin/config/ai-schema-markup-generator/bulk
Select content types, choose language, optionally set a node limit, configure batch size, and start the batch process.
Additional Requirements
- Drupal 9, 10, or 11
- PHP 8.1 or higher
- OpenAI API key
- Drupal core modules: Node, Field, File
No additional contributed modules are required.
Recommended modules/libraries
- Metatag – Helps manage HTML meta tags and works well alongside structured data.
- Simple XML Sitemap – Improves content discoverability for search engines.
- Key module – Recommended for securely storing the OpenAI API key.
Supporting this Module
This module is developed and maintained by Specbee.
You can support the project by:
- Reporting issues on Drupal.org
- Submitting patches and improvements
- Sharing the module with the Drupal community