Guide

Discovery

Enable `robots.txt` and `sitemap.xml` only when the application actually needs them.

Enable robots.txt and sitemap.xml

Discovery is optional. Configure robots.txt and sitemap.xml in app/Config/Discovery.yaml, choose stream or cache mode, and set an explicit base URL.

example.php
module: discovery
config:
  robots:
    enabled: true
    route: /robots.txt
  sitemap:
    enabled: true
    route: /sitemap.xml
    mode: stream
    routes:
      - home.index

Route-based sitemap entries

For stable pages, add named routes to the sitemap configuration. Provide parameters explicitly when a route needs a concrete canonical example.

example.php
module: discovery
config:
  sitemap:
    routes:
      - home.index
      - name: articles.detail
        params:
          id: 123

Provider-based sitemap entries

When sitemap entries come from application data, add an implementation of SitemapProviderInterface.

example.php
<?php

use Lemonade\Framework\Discovery\Sitemap\SitemapProviderInterface;
use Lemonade\Framework\Discovery\Sitemap\SitemapUrl;

final class ArticleSitemapProvider implements SitemapProviderInterface
{
    public function urls(): iterable
    {
        yield SitemapUrl::create(
            loc: '/articles/example',
            changefreq: 'weekly',
            priority: 0.8,
        );
    }
}