Sitemap Creation
A sitemap is an XML file that lists website URLs with metadata: last modification date, update frequency, and indexing priority. Search engine crawlers use it to navigate site structure, especially when internal linking is weak or the site has thousands of pages.
Formats and Standards
The primary format is sitemap.xml according to the sitemaps.org protocol. For large sites, Sitemap Index is used — a file that references multiple child sitemap files (limits: 50,000 URLs and 50 MB per file).
Additional types:
-
Image Sitemap —
<image:image>for indexing images in Google Images -
Video Sitemap —
<video:video>with metadata for Google Video -
News Sitemap — for Google News, requires
<news:publication>with publication date not older than 48 hours
Implementation in Practice
On a Laravel project, Sitemap is convenient to generate with the spatie/laravel-sitemap package:
use Spatie\Sitemap\SitemapGenerator;
use Spatie\Sitemap\Tags\Url;
SitemapGenerator::create('https://example.com')
->hasCrawled(function (Url $url) {
if (str_contains($url->url, '/admin')) {
return null; // exclude protected sections
}
return $url;
})
->writeToFile(public_path('sitemap.xml'));
For Next.js, next-sitemap is used:
// next-sitemap.config.js
module.exports = {
siteUrl: 'https://example.com',
generateRobotsTxt: true,
exclude: ['/admin/*', '/api/*'],
changefreq: 'weekly',
priority: 0.7,
}
Important Settings
<priority> — value from 0.0 to 1.0. The homepage is usually 1.0, categories 0.8, individual pages 0.6–0.7. The value is advisory: Google considers it, but is not obligated to follow it.
<changefreq> — a hint, not a directive. For a news site, use always or hourly on the homepage; for static pages — monthly.
<lastmod> — date in W3C Datetime format (2024-03-15T10:30:00+03:00). Calculated from the updated_at field in the database.
Registration in Search Console
After generating the sitemap:
- Add the path to
robots.txt:Sitemap: https://example.com/sitemap.xml - Register in Google Search Console → Sitemaps
- Register in Yandex Webmaster → Indexation → Sitemap files
- Configure automatic regeneration when publishing new pages (via queue or model hook)
Execution Timeline
Setting up a basic XML-sitemap and registering with search engines — 1–2 business days. Implementing Sitemap Index with multiple types (images, news) and auto-update via queue — 3–4 days.







