Search Engine Sitemap Class
The Sitemap class is a specialized utility in GeniXCMS designed to automate the generation of XML-compliant Sitemaps. This functionality is critical for modern SEO, as it provides search engine crawlers with a structured map of your site's content, ensuring all posts, pages, and module-specific resources are indexed accurately.
⚡ Index & Map Generation
GeniXCMS supports both individual content maps and master sitemap indexes for larger installations.
Sitemap::createIndex()
Generates a master Sitemap Index file. This is the primary entry point for search engine crawlers (e.g., sitemap.xml).
- Logic: It dynamically lists available content-type sitemaps (Posts, Pages, Categories).
- Format: Directly streams
XML with the Content-Type: text/xml header.
Sitemap::create(string $type, ...)
Generates an individual content-specific map list.
| Parameter |
Type |
Default |
Description |
$type |
string |
'post' |
The specific content type to include (e.g., post, page). |
$limit |
int |
20 |
Maximum number of items in the XML feed. |
$url_method |
string |
'post' |
The Url Class method used for link generation. |
// Typically executed within a sitemap controller or dedicated route
Sitemap::create('post', 100, 'post');
🏗️ Technical Architecture
The Sitemap class performs automated data transformations to ensure XML compliance and SEO efficacy.
- Metric Acquisition: Fetches recent content updates using the Posts Class.
- Metadata Injection:
lastmod: Automatically calculates the last modification date based on the post timestamp.
changefreq: Defaults to daily to encourage frequent re-crawling.
priority: Assigns relative priority to different content types (Home > Post > Category).
- Link Resolution: Uses the Url Class to ensure all links are absolute permalinks, including Smart URL support.
🔌 Extensibility: Registering Custom Maps
Modules can register their own custom content types into the sitemap engine using the Sitemap::addMap() method.
// Registering a Custom Product Module Sitemap
$new_map = [
'product' => [
'class' => 'ProductUrl', // The class handling the URL logic
'url' => 'detail' // The specific method to call
]
];
Sitemap::addMap($new_map);
priority_highImportantCrawler Submission: Once your sitemap is live (usually at /sitemap.xml or /sitemap/), ensure you submit the URL to Google Search Console and Bing Webmaster Tools to jumpstart your site's index discovery.
lightbulbTipPerformance Hint: Sitemaps are excellent candidates for Caching. Large sitemaps with thousands of entries should be cached as static XML files to prevent unnecessary database load during crawler visits.
See Also
- Url Class — How the system generates absolute permalinks for the sitemap.
- Posts Class — The underlying model consumed by the map engine.
- Cache Settings — Optimizing XML delivery performance.