Enhanced Simple XML Sitemap News module with Drupal 11 and Simple XML Sitemap 4.2.2 compatibility

Created on 11 July 2025, 4 days ago

This patch significantly enhances the Simple XML Sitemap News module with full Drupal 11 compatibility and advanced Google News features. The enhancement includes configurable keywords extraction, automated content age management, and a comprehensive admin interface.

Current Issues Addressed

  • Drupal 11 compatibility: Method signature incompatibilities and deprecated API usage
  • Missing Google News features: No keywords support or configurable publication settings
  • Limited content filtering: No automated age-based filtering for Google News compliance

New Features

Core Enhancements

  • Full Drupal 8/9/10/11 compatibility with proper method signatures and return types
  • Configurable keywords extraction from any taxonomy reference field
  • Automated content age management (1-7 days configurable, default 2 days)
  • Enhanced Google News XML compliance with proper entity escaping and schema adherence

Admin Interface

  • Enhanced configuration form at `/admin/config/search/simplesitemap/news`
  • Smart field discovery for taxonomy reference fields across content types
  • Content age threshold settings with Google News recommendations

Technical Improvements

  • Updated method signatures with proper return types (`:void`)
  • Fixed deprecated `$this->sitemapVariant` to `$this->sitemap` API calls
  • Enhanced dependency injection in admin forms
  • Proper configuration schema definitions
  • Comprehensive error handling and field validation

Implementation Details

Keywords Integration

  // Automatically extracts keywords from configured taxonomy fields
  // Supports multi-value fields and multiple content types
  // Limits to 5 keywords maximum (Google News best practice)
  $keywords = $this->extractKeywords($entity);

XML Output Enhancement

  <news:news>
    <news:publication>
      <news:name>Publication Name</news:name>
      <news:language>en</news:language>
    </news:publication>
    <news:publication_date>2024-01-15T10:30:00+00:00</news:publication_date>
    <news:title>Article Title</news:title>
    <news:keywords>keyword1, keyword2, keyword3</news:keywords>
  </news:news>

Content Age Filtering

  • Configurable threshold (1-7 days) via admin interface
  • Automatic filtering during sitemap generation
  • Follows Google News recommendations for fresh content

Files Modified/Added

Modified:

  • simple_sitemap_news.info.yml - Updated core version requirements
  • simple_sitemap_news.module - Enhanced help and documentation
  • src/Plugin/simple_sitemap/SitemapGenerator/NewsSitemapGenerator.php - Fixed method signatures, added age filtering
  • src/Plugin/simple_sitemap/UrlGenerator/NewsEntityUrlGenerator.php - Complete rewrite with keywords extraction

Added:

  • src/Form/NewsSettingsForm.php - Comprehensive admin configuration form
  • config/schema/simple_sitemap_news.schema.yml - Configuration schema definitions
  • config/install/simple_sitemap_news.settings.yml - Default settings
  • config/install/simple_sitemap.type.news.yml - News sitemap type configuration
  • simple_sitemap_news.routing.yml - Admin routes
  • simple_sitemap_news.links.menu.yml - Admin menu integration
  • README.md - Comprehensive documentation

Testing

  • Drupal 11 compatibility - All method signatures updated, no deprecation warnings
  • Keywords extraction - Successfully extracts from schema_about and other taxonomy fields
  • Admin interface - Form correctly discovers and displays available taxonomy reference fields
  • XML output - Valid Google News XML with proper entity escaping
  • Content age filtering - Configurable threshold working correctly

Why This Matters
Google News sitemaps remain valuable for rapid content discovery and indexing. While Google has simplified the Publisher Center, News sitemaps are still recommended for helping Google crawl fresh content faster. This enhancement makes the module production-ready for modern Drupal sites.

Patch Application
The attached patch can be applied to the latest 8.x-1.x branch:
patch -p1 < simple_sitemap_news_enhanced.patch

Backward Compatibility
This enhancement maintains full backward compatibility while adding new optional features. Existing installations will continue working with default settings.

🐛 Bug report
Status

Active

Version

1.0

Component

Code

Created by

🇰🇬Kyrgyzstan dan_metille

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024