XML Sitemap Generation
An XML sitemap tells search robots about site structure and indexation priorities. For sites with complex navigation or large numbers of pages — essential tool.
Sitemap Structure
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
xmlns:xhtml="http://www.w3.org/1999/xhtml"
xmlns:image="http://www.google.com/schemas/sitemap-image/1.1">
<url>
<loc>https://example.ru/</loc>
<lastmod>2024-03-15</lastmod>
<changefreq>weekly</changefreq>
<priority>1.0</priority>
</url>
<url>
<loc>https://example.ru/catalog/laptops</loc>
<lastmod>2024-03-14</lastmod>
<changefreq>daily</changefreq>
<priority>0.8</priority>
<!-- Product images -->
<image:image>
<image:loc>https://example.ru/images/laptop-dell.jpg</image:loc>
<image:title>Dell XPS 15 Laptop</image:title>
</image:image>
</url>
</urlset>
Index Sitemap (for Large Sites)
One sitemap file is limited to 50,000 URLs and 50 MB. For large sites — sitemap index:
<?xml version="1.0" encoding="UTF-8"?>
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<sitemap>
<loc>https://example.ru/sitemap-pages.xml</loc>
<lastmod>2024-03-15</lastmod>
</sitemap>
<sitemap>
<loc>https://example.ru/sitemap-products.xml</loc>
<lastmod>2024-03-15</lastmod>
</sitemap>
<sitemap>
<loc>https://example.ru/sitemap-blog.xml</loc>
<lastmod>2024-03-15</lastmod>
</sitemap>
</sitemapindex>
Generation in Laravel
// routes/web.php
Route::get('/sitemap.xml', [SitemapController::class, 'index']);
// SitemapController.php
public function index()
{
$pages = Page::where('is_published', true)->get(['slug', 'updated_at']);
$products = Product::where('is_active', true)->get(['slug', 'updated_at']);
return response()
->view('sitemap.index', compact('pages', 'products'))
->header('Content-Type', 'text/xml');
}
Registration in robots.txt
Sitemap: https://example.ru/sitemap.xml
Also add sitemap to Google Search Console and Yandex Webmaster manually to speed up indexation.
Setup timeline: a few hours for basic implementation.







