aslain.dev
0%
01 Hizmetler 02 Hakkımda 03 Projeler 04 Stack 05 Blog 06 İletişim
← Tüm makaleler SEO & Marketing

What Is a Sitemap and How to Create an XML Sitemap

Before a search engine can list your site properly, it first has to find your pages, and that is exactly where the question of what a sitemap is begins. A sitemap is a machine-readable list of the important URLs on your site. It is the cleanest way to tell Google and other bots, "these addresses matter to me, please crawl and index them." In this article we will build, step by step, what an XML sitemap is, how to create one manually and automatically, and how to submit it to Google Search Console.

What a sitemap is and why you need one

The most common format is the XML sitemap: a text file that follows a defined schema and contains URLs plus optional metadata. Bots already crawl your site by following links, so why hand them a map as well? Because:

  • Pages with weak internal linking — a bot may not find a page that nothing links to; the sitemap announces it directly.
  • New or large sites — discovery is slow on sites with no history or with thousands of URLs; the map speeds up the process.
  • Content signals — hints such as the last modification date help the bot decide what to revisit.

An important point: a sitemap is a suggestion, not a guarantee. Putting a URL in the map does not mean Google will definitely index it; it only makes that page easier to discover.

The structure of an XML sitemap

A standard sitemap starts with the urlset root tag and defines each page inside a url block. The simplest valid example looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
  <url>
    <loc>https://aslain.dev/</loc>
    <lastmod>2026-06-27</lastmod>
  </url>
  <url>
    <loc>https://aslain.dev/blog/sitemap-xml-olusturma</loc>
    <lastmod>2026-06-27</lastmod>
  </url>
</urlset>

What the tags mean:

  • <loc> — the full, absolute URL of the page. It is required and must contain the canonical address.
  • <lastmod> — the date the page actually last changed (ISO 8601 format, e.g. 2026-06-27). Google does consider this field, but only if you keep it honest; writing today's date on every page erodes trust.
  • <changefreq> and <priority> — these are legacy tags that Google largely ignores, so they are not required.

A few rules: all URLs must use the same protocol and domain, special characters (&, <) must be escaped for XML, and the file must be UTF-8 encoded. A single sitemap can hold at most 50,000 URLs and 50 MB uncompressed.

Splitting large sites with a sitemap index

If you exceed the limit, split the pages across several sitemaps and tie them together with a sitemap index. The index is a parent file that points to the individual maps:

<?xml version="1.0" encoding="UTF-8"?>
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
  <sitemap>
    <loc>https://aslain.dev/sitemap-posts.xml</loc>
  </sitemap>
  <sitemap>
    <loc>https://aslain.dev/sitemap-pages.xml</loc>
  </sitemap>
</sitemapindex>

This approach lets you keep groups like blog posts, products and static pages in separate files, so in Search Console you can see which section is indexed properly on its own.

Ways to create a sitemap

There are three practical methods depending on the type of site:

  • CMS plugin — for WordPress, Yoast or Rank Math generates the map automatically and updates it as you add content. For most small sites this is the easiest route.
  • Framework / dynamic generation — in stacks like Laravel or Next.js the healthiest option is to generate the map dynamically from the database via a route, so it stays current whenever content changes.
  • Static generator — for small, rarely changing sites you can produce the XML once with a browser-based generator and upload it.

A simple dynamic sitemap route in Laravel looks like this:

Route::get('/sitemap.xml', function () {
    $posts = Post::where('published', true)->get();
    return response()
        ->view('sitemap', ['posts' => $posts])
        ->header('Content-Type', 'application/xml');
});

In the matching Blade view you use @foreach to print a <url> block for each post and write the model's updated_at value into the lastmod field. That way the map updates instantly when you publish a new post.

Submitting via robots.txt and Search Console

Once the map is ready, you notify Google in two ways. The first is to add one line to your robots.txt file, which lets every bot find the map:

Sitemap: https://aslain.dev/sitemap.xml

The second and stronger way is to enter the address in the Sitemaps section of Google Search Console and click "Submit." Within a few minutes to a few days the status becomes "Success" and Google reports how many URLs it found in the map. It is a good idea to repeat the same step in Bing Webmaster Tools. You do not need to resubmit every time; Google re-crawls the map regularly.

Common mistakes

The most frequent issues that reduce a sitemap's value are:

  • Including noindex or redirected URLs — only put canonical pages that return 200 and that you want indexed in the map.
  • Listing blocked pages — putting a URL that is blocked from crawling in robots.txt into the map sends a contradictory signal.
  • Wrong or static lastmod — always writing today, or never updating it, makes the field useless.
  • Using relative URLs<loc> must always be a full address, not a relative path like /blog.

Frequently Asked Questions

Does a small site really need a sitemap?

A site of a few pages with strong internal linking will be found by Google even without one. Still, a sitemap is harmless and speeds up discovery; since it takes only minutes to create, it is recommended even for small sites.

Is an HTML sitemap the same as an XML sitemap?

No. The XML sitemap is for bots and guides indexing. The HTML sitemap is a navigation page for visitors. The two serve different purposes; the one that matters for SEO is the XML version.

How often should I update the sitemap?

Keep it automatic if you can: let the map update itself when content is added. If you build it manually, refresh it after every important content change; a fixed schedule is not required.

Want every page of your site to be discovered correctly by Google? For dynamic sitemap setup, robots.txt configuration and a Search Console audit, get in touch with me — let's put your technical foundation on solid ground together.

Bu kategorideki tüm yazılar →

Devamı için