SitemapamicUrl object
The SitemapamicUrl object is used when you are adding Dynamic Routes to your sitemaps.
Properties
Argument | Type | Required | Description |
|---|---|---|---|
|
| Yes | The page's full URL. It must be an absolute |
|
| No | The page's last modified date, written to |
|
| No | One of |
|
| No | A value from |
|
| No | Alternate language versions of the page, as |
Use
1use MityDigital\Sitemapamic\Enums\ChangeFrequency; 2use MityDigital\Sitemapamic\Models\SitemapamicUrl; 3 4new SitemapamicUrl( 5 loc: 'https://example.com/events', 6 lastmod: $latestEvent->updated_at->toW3cString(), 7 changefreq: ChangeFrequency::Daily, 8 priority: 0.8, 9 alternates: [10 ['hreflang' => 'en', 'href' => 'https://example.com/events'],11 ['hreflang' => 'fr', 'href' => 'https://example.com/fr/evenements'],12 ],13);
Validation
A
locor alternatehrefthat isn't an absolutehttp/httpsURL throws anInvalidArgumentExceptionwhen the sitemap is built.The closure must return an iterable containing only
SitemapamicUrlobjects. Anything else throws anInvalidArgumentException.A
changefreqthat isn't one of the allowed values, or apriorityoutside0–1, is left out of that URL without an error.