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.
module: discovery
config:
robots:
enabled: true
route: /robots.txt
sitemap:
enabled: true
route: /sitemap.xml
mode: stream
routes:
- home.indexRoute-based sitemap entries
For stable pages, add named routes to the sitemap configuration. Provide parameters explicitly when a route needs a concrete canonical example.
module: discovery
config:
sitemap:
routes:
- home.index
- name: articles.detail
params:
id: 123Provider-based sitemap entries
When sitemap entries come from application data, add an implementation of SitemapProviderInterface.
<?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,
);
}
}