The indexPage hook is triggered when a page’s content is added to the search index. It passes the content, the data and the data collected for indexing so far as arguments and does not expect a return value.


  1. string $content

    The content of the page.

  2. array $pageData

    The data array containing information about the page.

  3. array $indexData

    An array containing the data collected so far.


// src/EventListener/IndexPageListener.php
namespace App\EventListener;

use Contao\CoreBundle\DependencyInjection\Attribute\AsHook;

class IndexPageListener
    public function __invoke(string $content, array $pageData, array &$indexData): void
        // Modify $indexData which will eventually be stored in tl_search