Web Design SEO and Google Spanish version

Support article

Sitemap.xml and robots.txt: How to Create and Submit Them

Learn what sitemap.xml and robots.txt are, how to create them in WordPress and HTML, and how to submit them to Google Search Console.

Published: 12/07/2026 Updated: 12/07/2026

Introduction

The sitemap.xml and robots.txt are two files that help Google understand and read your website. Although not visible to visitors, they’re fundamental for SEO.

In this article you’ll see what they are, how to create them and how to submit them to Google.

What sitemap.xml is

The sitemap.xml is a file listing all your website’s pages. It’s like an index you give Google so it knows what pages exist and when they were updated.

Without a sitemap, Google has to discover your pages by following links. With a sitemap, you give it the complete index directly.

Sitemap example

<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
  <url>
    <loc>https://yourdomain.com/</loc>
    <lastmod>2026-07-12</lastmod>
    <priority>1.0</priority>
  </url>
  <url>
    <loc>https://yourdomain.com/contact/</loc>
    <lastmod>2026-07-10</lastmod>
    <priority>0.8</priority>
  </url>
</urlset>

What robots.txt is

The robots.txt is a file that tells Google’s robots which pages they can read and which they can’t. It’s placed at your website’s root: yourdomain.com/robots.txt.

robots.txt example

User-agent: *
Allow: /
Disallow: /wp-admin/
Sitemap: https://yourdomain.com/sitemap.xml
  • User-agent: *: applies to all robots.
  • Allow: /: allows reading everything.
  • Disallow: /wp-admin/: doesn’t read the admin panel.
  • Sitemap: indicates where your sitemap is.

robots.txt doesn’t serve to hide pages from Google (use noindex for that). It serves to guide robots and prevent them reading unnecessary folders.

How to create the sitemap in WordPress

With Yoast SEO

Yoast generates the sitemap automatically:

  1. Go to SEO → General → Features.
  2. Enable XML sitemaps.
  3. Your sitemap is at yourdomain.com/sitemap_index.xml.

With Rank Math

Rank Math also generates it:

  1. Go to Rank Math → General Settings → Sitemap.
  2. Make sure it’s active.
  3. Sitemap at yourdomain.com/sitemap_index.xml.

If you use WordPress with an SEO plugin, the sitemap creates and updates itself. You don’t have to do anything manually.

How to create the sitemap in HTML (without WordPress)

If your website isn’t WordPress:

  1. Use an online generator like xml-sitemaps.com.
  2. Enter your URL.
  3. Download the sitemap.xml file.
  4. Upload it to your website root via FTP.

How to create robots.txt

On WordPress

WordPress generates a virtual robots.txt by default. But you can edit it:

  • With Yoast SEO: SEO → Tools → File editor.
  • With Rank Math: Rank Math → General Settings → robots.txt.
  • With cPanel: create a robots.txt file in public_html.

On HTML

Create a text file called robots.txt and upload it to your website root.

How to submit the sitemap to Google

  1. Go to Google Search Console.
  2. In the menu, click Sitemaps.
  3. Type your sitemap URL: sitemap_index.xml or sitemap.xml.
  4. Click Submit.

[Imagen sugerida: screenshot of sitemap submission in Search Console]

Google takes a few days to process the sitemap. Afterwards, you’ll see how many URLs it has indexed.

Useful tips

  • If you use WordPress, you don’t need to create the sitemap by hand. Yoast or Rank Math do it.
  • Don’t block important resources in robots.txt. If you block CSS or JS, Google doesn’t see your website well.
  • Submit the sitemap only once. Google reads it regularly afterwards.
  • If you have few pages, the sitemap is less important. But it costs nothing to have it.
  • Check the sitemap is accessible. Go to yourdomain.com/sitemap.xml in the browser.

Frequently asked questions

Does the sitemap guarantee Google will index me?

It doesn’t guarantee, but it facilitates. Google decides what to index, but the sitemap helps it discover your pages.

Can I have several sitemaps?

Yes. Large websites can have several (one for pages, another for images, etc.). The index sitemap groups them.

Does robots.txt hide pages from Google?

No. It only tells robots not to enter, but Google can index the page if others link to it. To truly hide, use noindex.

Where is robots.txt placed?

At your website’s root: yourdomain.com/robots.txt.

Do I need a sitemap if my website has 5 pages?

It’s not indispensable, but it’s recommended. It’s free and facilitates indexing.

Sitemap and robots.txt: the foundation of technical SEO

The sitemap.xml and robots.txt are the foundation of technical SEO. They help Google read and understand your website. If you use WordPress with Yoast or Rank Math, they create themselves; you just have to submit the sitemap to Search Console.

If you need help with your technical SEO, at miHosting we advise you. Open a ticket from your client panel.