How to Improve AI Readiness on Drupal
Enterprise CMS with powerful module ecosystem for structured data. Follow these 6 steps to dramatically improve how AI agents discover and understand your Drupal site.
Expected Score Improvement
Before
After
Estimated improvement based on implementing all steps in this guide. Actual results vary depending on existing site configuration and content quality.
Step-by-Step Instructions
Install Schema.org Metatag Module
Install the Schema.org Metatag module to add comprehensive structured data support to your Drupal site.
# Install via Composer:
composer require drupal/schema_metatag
# Enable the module:
drush en schema_metatag schema_article_metatag schema_organization_metatag schema_web_page_metatag
# Configure at:
# /admin/config/search/metatag
# Set default schema for each content type:
# - Article → Schema Article
# - Page → Schema WebPage
# - Product → Schema ProductCreate llms.txt with a Custom Route
Create a custom Drupal module or use a static file to serve llms.txt from your domain root.
# Method 1: Static file
# Place llms.txt in your Drupal web root (same level as index.php)
# Method 2: Custom module route
# Create: modules/custom/llms_txt/llms_txt.routing.yml
llms_txt.content:
path: '/llms.txt'
defaults:
_controller: '\Drupal\llms_txt\Controller\LlmsTxtController::content'
requirements:
_access: 'TRUE'
# modules/custom/llms_txt/src/Controller/LlmsTxtController.php
<?php
namespace Drupal\llms_txt\Controller;
use Symfony\Component\HttpFoundation\Response;
class LlmsTxtController {
public function content() {
$site_name = \Drupal::config('system.site')->get('name');
$site_slogan = \Drupal::config('system.site')->get('slogan');
$content = "# {$site_name}\n# {$site_slogan}\n\n";
$content .= "## Main Sections\n";
// Add your sections...
return new Response($content, 200, [
'Content-Type' => 'text/plain',
]);
}
}Configure robots.txt
Drupal ships with a robots.txt file in the web root. Edit it to add AI crawler access rules.
# Edit: web/robots.txt (or docroot/robots.txt)
# Add these rules after the existing content:
# AI Crawler Access
User-agent: GPTBot
Allow: /
User-agent: ChatGPT-User
Allow: /
User-agent: ClaudeBot
Allow: /
User-agent: PerplexityBot
Allow: /
User-agent: Amazonbot
Allow: /
# Or use the RobotsTxt module for admin UI control:
composer require drupal/robotstxt
drush en robotstxt
# Configure at: /admin/config/search/robotstxtConfigure XML Sitemap
Install and configure the XML Sitemap module to generate comprehensive sitemaps for all your content types.
# Install Simple XML Sitemap:
composer require drupal/simple_sitemap
drush en simple_sitemap
# Configure at: /admin/config/search/simplesitemap
# 1. Add each content type:
# - Content → Article: priority 0.7, changefreq weekly
# - Content → Page: priority 0.6, changefreq monthly
# 2. Add taxonomy terms if desired
# 3. Set inclusion/exclusion rules
# Verify at: /sitemap.xml
# Submit to Google Search Console
# Alternative: use the xmlsitemap module:
composer require drupal/xmlsitemap
drush en xmlsitemap xmlsitemap_enginesOptimize Metatags for All Content Types
Use the Metatag module to set default meta title patterns, descriptions, and Open Graph tags for every content type.
# Install Metatag:
composer require drupal/metatag
drush en metatag metatag_open_graph metatag_twitter_cards
# Configure at: /admin/config/search/metatag
# Set defaults for each content type:
# Content type: Article
# Title: [node:title] | [site:name]
# Description: [node:summary]
# OG Title: [node:title]
# OG Description: [node:summary]
# OG Image: [node:field_image:entity:url]
# Canonical URL: [node:url]
# Content type: Page
# Title: [node:title] | [site:name]
# Description: [node:field_meta_description]
# Override per-node via the Metatag sidebar in node edit formAdd Breadcrumb Schema
Install a breadcrumb module that outputs JSON-LD BreadcrumbList schema alongside the visual breadcrumbs.
# Use Easy Breadcrumb with Schema.org support:
composer require drupal/easy_breadcrumb
drush en easy_breadcrumb
# Configure at: /admin/config/user-interface/easy-breadcrumb
# Enable: "Add structured data (JSON-LD)" checkbox
# Or manually add breadcrumb schema in your theme:
# THEMENAME.theme file:
function THEMENAME_preprocess_html(&$variables) {
$breadcrumbs = \Drupal::service('breadcrumb')
->build(\Drupal::routeMatch());
$items = [];
$position = 1;
foreach ($breadcrumbs->getLinks() as $link) {
$items[] = [
'@type' => 'ListItem',
'position' => $position++,
'name' => $link->getText(),
'item' => $link->getUrl()->setAbsolute()->toString(),
];
}
$schema = [
'@context' => 'https://schema.org',
'@type' => 'BreadcrumbList',
'itemListElement' => $items,
];
$variables['#attached']['html_head'][] = [
['#type' => 'html_tag', '#tag' => 'script',
'#attributes' => ['type' => 'application/ld+json'],
'#value' => json_encode($schema)],
'breadcrumb_schema',
];
}Recommended Tools for Drupal
- Schema.org Metatag module
- Simple XML Sitemap module
- Metatag module
- Easy Breadcrumb module
- Pathauto module
Frequently Asked Questions
Which Drupal modules are best for AI readiness?
The essential modules are: Metatag (meta tags and Open Graph), Schema.org Metatag (JSON-LD structured data), Simple XML Sitemap (sitemaps), Easy Breadcrumb (breadcrumb schema), and Pathauto (clean URLs). Together these cover all major AI readiness signals.
How do I add llms.txt to a Drupal site?
The simplest approach is to place a static llms.txt file in your Drupal web root directory. For dynamic generation, create a small custom module with a route controller that builds the content from your site's node data.
Does Drupal support structured data natively?
Drupal 10+ includes basic RDFa support in core, but JSON-LD (preferred by most AI agents) requires the Schema.org Metatag contributed module. This module integrates with the Metatag module to generate comprehensive JSON-LD for all content types.
Drupal Benchmark Data
See how Drupal sites score compared to other platforms, with protocol adoption rates and top-performing sites.
View Drupal AI Readiness BenchmarkGuides for Other Platforms
Ready to Check Your Drupal Site?
Run a free AI readiness scan to see your current score and get personalized recommendations for your Drupal site.
Scan Your Drupal Site