Categories
WordPress

How to add your sitemap to the robots.txt file in WordPress using a plugin

Introduction

This guide explains how to add your sitemap to the robots.txt file in WordPress using the Yoast SEO plugin. This allows search engines to easily find the sitemap, index your site and show it in search results.

If you’ve already submitted your sitemap directly to a search engine (e.g. via Google Search Console), then that search engine won’t require the robots.txt file to be updated. However, updating it makes sure all search engines can find the sitemap, even if you haven’t submitted it directly.

Requirements

  1. WordPress with the Yoast SEO plugin installed and used to generate the sitemap (which it does by default). If you haven’t already installed the plugin, see How to install the Yoast SEO plugin in WordPress.

Skill Level

Basic knowledge of WordPress.

Instructions

Time needed: 5 minutes.

  1. Log into WordPress Admin.

    This is usually accessed via yourdomain.com/wp-admin.

  2. Go to the SEO Tools page.

    Click SEO then Tools in the main menu.SEO and Tools buttons - screenshot

  3. Click File Editor.

    File Editor link - screenshot

  4. Click Create robots.txt file.

    Create robots txt file button - screenshot

  5. Add the sitemap details.

    At the bottom of the content field, enter Sitemap: [your sitemap URL]
    For example, if your site was https://www.yourdomain.com and you’re using the Yoast SEO plugin to generate the sitemap, the text would probably be Sitemap: https://www.yourdomain.com/sitemap_index.xml
    Click Save changes to robots.txt.robots txt content field and Save changes to robots txt button - screenshot

More Info

Guide to Create a robots.txt file: https://support.google.com/webmasters/answer/6062596