fm-labs/cakephp-seo

Seo plugin for CakePHP

Installs: 59

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 3

Forks: 0

Open Issues: 0

Type:cakephp-plugin

1.2.0 2023-03-27 10:13 UTC

This package is auto-updated.

Last update: 2024-12-28 16:57:01 UTC


README

Installation

You can install this plugin into your CakePHP application using composer.

The recommended way to install composer packages is:

composer require fm-labs/cakephp-seo

Features

  • Robots.txt generator
  • XML Sitemap generator
  • XML Sitemap Index generator
  • XML Sitemap schema validation
  • Sitemaps support for XSL stylesheets
  • TXT Sitemap Genrator
  • Google Analytics Tracking

Usage

Robots TXT

The URL /robots.txt is automatically routed by the Seo plugin to the RobotsController.

By default, the sitemapUrl parameter is mapped to the SitemapController. Override this, if you want to implement your own SitemapController and/or want to use your own route.

Supports following directives:

Configuration

Configure::write('Seo.RobotsTxt', [
    'sitemapUrl' => '/path/to/custom/sitemap.xml',
    'crawlDelay' => 10,                 // Crawl-delay in seconds
    'rules' => [
        '*' => [                        // Default / All user agents
            '/' => true,                // Allow
        ],
        'google-bot' => [               // User agent
            '/' => true,                // Allow
            '/private' => false,        // Disallow
        ],
        
    ]
])

Events

The RobotsTxtBuilder dispatches the Seo.RobotsTxt.build event, which can be used to modify the builder state via the event system.

\Cake\Event\EventManager::instance()->on('Seo.RobotsTxt.build', function($event) {
    $robotsTxt = $event->getSubject();
    
    $rules = []; // put your rules here
    $robotsTxt->addRules($rules);
})

Example output

Sitemap: /path/to/custom/sitemap.xml

User-agent: *
Allow: /

User-agent: google-bot
Allow: /
Disallow: /private

Sitemap XML

Styling

Built-in Stylesheets: