Trusted WordPress tutorials, when you need them most.
Beginner’s Guide to WordPress
Copa WPB
25 Million+
Websites using our plugins
16+
Years of WordPress experience
3000+
WordPress tutorials
by experts

Cómo optimizar su WordPress Robots.txt para SEO

Nota editorial: Ganamos una comisión de los enlaces de socios en WPBeginner. Las comisiones no afectan a las opiniones o evaluaciones de nuestros editores. Más información sobre Proceso editorial.

Recientemente, uno de nuestros lectores nos preguntó cómo optimizar el archivo robots.txt para mejorar el SEO.

El archivo robots.txt indica a los motores de búsqueda cómo rastrear su sitio web, lo que lo convierte en una herramienta SEO increíblemente potente.

En este artículo, le mostraremos algunos consejos sobre cómo crear un archivo robots.txt perfecto para SEO.

Optimizing robots.txt file for better SEO

¿Qué es un archivo Robots.txt?

Robots.txt es un archivo de texto que los propietarios de sitios web pueden crear para indicar a los robots de los motores de búsqueda cómo rastrear e indexar las páginas de sus sitios.

Normalmente se almacena en el directorio raíz (también conocido como la carpeta principal) de su sitio web. El formato básico de un archivo robots.txt es el siguiente:

User-agent: [user-agent name]
Disallow: [URL string not to be crawled]
 
User-agent: [user-agent name]
Allow: [URL string to be crawled]
 
Sitemap: [URL of your XML Sitemap]

Puede tener varias líneas de instrucciones para permitir o desautorizar URL específicas y añadir varios mapas del sitio. Si no desautoriza una URL, los robots de los motores de búsqueda supondrán que tienen permiso para rastrearla.

Este es el aspecto que puede tener un archivo robots.txt de ejemplo:

User-Agent: *
Allow: /wp-content/uploads/
Disallow: /wp-content/plugins/
Disallow: /wp-admin/

Sitemap: https://example.com/sitemap_index.xml

En el ejemplo anterior de robots.txt, hemos permitido a los motores de búsqueda rastrear e indexar archivos en nuestra carpeta de subidas de WordPress.

A continuación, impedimos que los robots de búsqueda rastreen e indexen los plugins y las carpetas de administrador de WordPress.

Por último, hemos proporcionado la URL de nuestro mapa del sitio XML.

¿Necesita un archivo Robots.txt para su sitio WordPress?

Si no tiene un archivo robots.txt, los motores de búsqueda rastrearán e indexarán su sitio web. Sin embargo, no podrá indicarles qué páginas o carpetas no deben rastrear.

Esto no tendrá mucho impacto cuando empieces un blog y no tengas mucho contenido.

Sin embargo, a medida que su sitio web crezca y añada más contenido, es probable que desee controlar mejor cómo se rastrea e indexa su sitio web.

He aquí por qué.

Los robots de búsqueda tienen una cuota de rastreo para cada sitio web.

Esto significa que rastrean un determinado número de páginas durante una sesión de rastreo. Si agotan su presupuesto de rastreo antes de terminar de rastrear todas las páginas de su sitio, volverán y reanudarán el rastreo en la siguiente sesión.

Esto puede ralentizar la tasa / tarifa de indexación de su sitio web.

Puede corregirlo impidiendo que los robots de búsqueda rastreen páginas innecesarias, como las páginas de administrador de WordPress, los archivos de plugins y la carpeta de temas.

Al no permitir páginas innecesarias, usted guarda su cuota de rastreo. Esto ayuda a los motores de búsqueda a rastrear aún más páginas de su sitio e indexarlas lo más rápidamente posible.

Otra buena razón para utilizar un archivo robots.txt es impedir que los motores de búsqueda indexen una entrada o página de su sitio web.

Esta no es la forma más segura de ocultar contenido al público en general, pero le ayudará a evitar que el contenido aparezca en los resultados de búsqueda.

¿Cómo es un archivo Robots.txt ideal?

Muchos blogs populares utilizan un archivo robots.txt muy sencillo. Su contenido puede variar en función de las necesidades del sitio específico:

User-agent: *
Disallow:

Sitemap: http://www.example.com/post-sitemap.xml
Sitemap: http://www.example.com/page-sitemap.xml

Este archivo robots.txt permite a todos los robots indexar todo el contenido y les enlaza con los mapas del sitio web en formato XML.

Para sitios WordPress, recomendamos las siguientes reglas en el archivo robots.txt:

User-Agent: *
Allow: /wp-content/uploads/
Disallow: /wp-admin/
Disallow: /readme.html
Disallow: /refer/

Sitemap: http://www.example.com/post-sitemap.xml
Sitemap: http://www.example.com/page-sitemap.xml

Indica a los robots de búsqueda que indexen todas las imágenes y archivos de WordPress. Impide que los robots de búsqueda indexen el área de administrador de WordPress, el archivo readme y los enlaces de afiliados ocultos.

Si añade mapas del sitio al archivo robots.txt, facilitará a los robots de Google la búsqueda de todas las páginas de su sitio.

Ahora que ya sabe cómo es un archivo robots.txt ideal, veamos cómo crear un archivo robots.txt en WordPress.

Cómo crear un archivo Robots.txt en WordPress

Existen dos formas de crear un archivo robots.txt en WordPress. Puede elegir el método que más le convenga.

Método 1: Editar el archivo Robots.txt con All in One SEO

All in One SEO, también conocido como AIOSEO, es el mejor plugin SEO para WordPress del mercado, utilizado por más de 3 millones de sitios web. Es fácil de usar y viene con un generador de archivos robots.txt.

Para obtener más información, consulte nuestra reseña / valoración detallada de AIOSEO.

Si aún no tiene instalado el plugin AIOSEO, puede consultar nuestra guía paso a paso sobre cómo instalar un plugin de WordPress.

Nota: También existe una versión gratuita de AIOSEO que incorpora esta característica.

Una vez instalado y activado el plugin, puede utilizarlo para crear y editar su archivo robots.txt directamente desde su área de administrador de WordPress.

Simplemente vaya a All in One SEO ” Herramientas para editar su archivo robots.txt.

Robots.txt file editor in All in One SEO

En primer lugar, deberá activar la opción de edición haciendo clic en el conmutador “Activar Robots.txt personalizados” en azul.

Con este conmutador activado, puede crear un archivo robots.txt personalizado en WordPress.

Enable custom robots.txt file

All in One SEO mostrará su archivo robots.txt existente en la sección “Vista previa de Robots.txt” en la parte inferior de su pantalla.

Esta versión mostrará las reglas por defecto que fueron añadidas por WordPress.

Robots.txt file preview in All in One SEO

Estas reglas por defecto indican a los motores de búsqueda que no rastreen los archivos del núcleo de WordPress, permiten a los robots indexar todo el contenido y les proporcionan un enlace a los mapas del sitio XML de su sitio.

Ahora, puede añadir sus propias reglas personalizadas para mejorar su robots.txt para SEO.

Para añadir una regla, introduzca un agente de usuario en el campo “Agente de usuario”. Si utiliza *, la regla se aplicará a todos los agentes de usuario.

A continuación, seleccione si desea “Permitir” o “No permitir” que los motores de búsqueda rastreen.

A continuación, introduzca el nombre del archivo o la ruta del directorio en el campo “Ruta del directorio”.

Add robots file rules

La regla se aplicará automáticamente a su robots.txt. Para añadir otra regla, basta con hacer clic en el botón “Añadir regla”.

Recomendamos añadir reglas hasta crear el formato ideal de robots.txt que compartimos anteriormente.

Sus reglas personalizadas tendrán este aspecto.

Custom robots txt file preview

Cuando hayas terminado, no olvides hacer clic en el botón “Guardar cambios” para guardar los cambios.

Método 2: Editar el archivo Robots.txt usando WPCode

WPCode es un potente plugin de fragmentos de código que te permite añadir código personalizado a tu sitio web de forma fácil y segura.

También incluye una práctica característica que le permite editar rápidamente el archivo robots.txt.

Nota: También existe un plugin gratuito de WPCode, pero no incluye la característica de editor de archivos.

Lo primero que tienes que hacer es instalar el plugin WPCode. Para obtener instrucciones paso a paso, consulte nuestra guía para principiantes sobre cómo instalar un plugin de WordPress.

Una vez activado, tienes que ir a la página WPCode ” Editor de archivos. Una vez allí, simplemente haga clic en la pestaña ‘robots.txt’ para editar el archivo.

WPCode robots.txt Editor

Ahora, puede pegar o escribir el contenido del archivo robots.txt.

Una vez que haya terminado, asegúrese de hacer clic en el botón “Guardar cambios” situado en la parte inferior de la página para establecer los ajustes.

Método 3: Edición manual del archivo Robots.txt mediante FTP

Para este método, necesitará utilizar un cliente FTP para editar el archivo robots.txt. También puede utilizar el gestor de archivos de su alojamiento de WordPress.

Simplemente conéctese a los archivos de su sitio web WordPress utilizando un cliente FTP.

Una vez dentro, podrá ver el archivo robots.txt en la carpeta raíz de su sitio web.

Edit robots file via FTP

Si no ve ninguno, es probable que no tenga un archivo robots.txt.

En ese caso, puedes seguir adelante y crear uno.

Create new robots file

Robots.txt es un archivo de texto plano, lo que significa que puede descargarlo a su ordenador y editarlo con cualquier editor de texto plano como Notepad o TextEdit.

Tras guardar los cambios, puede volver a subir el archivo robots.txt a la carpeta raíz de su sitio web.

Cómo probar su archivo Robots.txt

Una vez que haya creado su archivo robots.txt, siempre es una buena idea probarlo utilizando una herramienta de comprobación de robots.txt.

Existen muchas herramientas de comprobación de robots.txt, pero te recomendamos que utilices la que se encuentra en Google Search Console.

En primer lugar, tendrás que enlazar tu sitio web con Google Search Console. Si aún no lo ha hecho, consulte nuestra guía sobre cómo añadir su sitio de WordPress a Google Search Console.

A continuación, puede utilizar la herramienta de comprobación de robots de Google Search Console.

Choose property

Sólo tiene que seleccionar su propiedad en la lista desplegable.

La herramienta buscará automáticamente el archivo robots.txt de su sitio web y resaltará los errores y advertencias si encuentra alguno.

Robots tester tool

Reflexiones finales

El objetivo de optimizar su archivo robots.txt es evitar que los motores de búsqueda rastreen páginas que no están disponibles públicamente. Por ejemplo, páginas en su carpeta wp-plugins o páginas en su carpeta de administrador de WordPress.

Un mito común entre los expertos en SEO es que el bloqueo de categorías, etiquetas y páginas de archivo de WordPress mejorará la tasa de rastreo y dará lugar a una indexación más rápida y mejores clasificaciones.

Esto no es cierto. También va en contra de las directrices para webmasters de Google.

Le recomendamos que siga el formato robots.txt anterior para crear un archivo robots.txt para su sitio web.

Esperamos que este artículo le haya ayudado a aprender a optimizar su archivo robots.txt de WordPress para SEO. Puede que también quieras ver nuestra guía definitiva de SEO para WordPress y nuestra selección de las mejores herramientas SEO para WordPress para hacer crecer tu sitio web.

If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.

Descargo: Nuestro contenido está apoyado por los lectores. Esto significa que si hace clic en algunos de nuestros enlaces, podemos ganar una comisión. Vea cómo se financia WPBeginner , por qué es importante, y cómo puede apoyarnos. Aquí está nuestro proceso editorial .

Avatar

Editorial Staff at WPBeginner is a team of WordPress experts led by Syed Balkhi with over 16 years of experience in WordPress, Web Hosting, eCommerce, SEO, and Marketing. Started in 2009, WPBeginner is now the largest free WordPress resource site in the industry and is often referred to as the Wikipedia for WordPress.

El último kit de herramientas de WordPress

Obtenga acceso GRATUITO a nuestro kit de herramientas - una colección de productos y recursos relacionados con WordPress que todo profesional debería tener!

Reader Interactions

129 comentariosDeja una respuesta

  1. Syed Balkhi says

    Hey WPBeginner readers,
    Did you know you can win exciting prizes by commenting on WPBeginner?
    Every month, our top blog commenters will win HUGE rewards, including premium WordPress plugin licenses and cash prizes.
    You can get more details about the contest from here.
    Start sharing your thoughts below to stand a chance to win!

  2. Moinuddin Waheed says

    Thanks for this informative post about robots.txt file.
    I didn’t know that websites should maintain this file in order to have a control over Google bots that how should they crawl over our pages and posts.
    for beginner websites just starting out, is there a need to have robots.txt file or is there a way like plugin which can a make a robots.txt file for our website?

    • WPBeginner Support says

      Most SEO plugins help with setting up the robots.txt for a new site to prevent bots from scrolling sections they shouuldn’t.

      Administrador

  3. Jiří Vaněk says

    Thanks to this article, I checked the robots.txt file and added URL addresses with sitemaps. At the same time, I had other problematic lines there, which were revealed by the validator. I wasn’t familiar with sitemaps in robots.txt until now. Thanks.

  4. Stéphane says

    Hi,

    Thanks for that post, it becomes clearer how to use the robots.txt file. On most websites that you find while looking for some advice regarding the robots.txt file, you can see that the following folders are explicitly excluded from crawling (for WordPress):
    Disallow: /wp-content/plugins
    Disallow: /wp-content/cache
    Disallow: /wp-content/themes

    I don’t really understand the reasons to exclude those folders (is there one actually?). What would be your take regarding that matter?

    • WPBeginner Support says

      It is mainly to prevent anything in those folders from showing as a result when a user searches for your site. As that is not your content it is not something most people would want to appear for the site’s results.

      Administrador

  5. zaid haris says

    Disallow: /wp-admin/
    Allow: /wp-admin/admin-ajax.php

    GSC show the coverage error for “Disallow: /wp-admin/” Is this wrong?

    • WPBeginner Support says

      For most sites, you do not want anything from your wp-admin to appear as a search result so it is fine and expected to receive the coverage area when you deny Google the ability to scan your wp-admin.

      Administrador

  6. Hansini says

    I am creating my robots.txt manually as you instructed for my WordPress site.

    I have one doubt. when I write User-Agent: * won’t it allow another spamming robot to access my site?
    Should I write User-Agent: * or User-Agent: Googlebot.?

    • WPBeginner Support says

      The User-Agent line is setting the rules that all robots should follow on your site, if you specify a specific bot on that line it would be setting rules for that specific bot and none of the others.

      Administrador

  7. Sanjeev Pandey says

    should we also disallow /wp-content/themes/ ?

    It is appearing in the search result when I run the command site:abcdef.com in google search

    • WPBeginner Support says

      You would not want to worry about blocking your themes folder and as you write SEO-friendly content you should no longer see the themes as a search result.

      Administrador

    • WPBeginner Support says

      That means you’re telling search engines to not look at any referral links or the readme.html file.

      Administrador

    • WPBeginner Support says

      If you block your uploads folder then search engines would not normally crawl your uploaded content like images.

      Administrador

  8. Ravi kumar says

    Sir i m very confused about robot.txt many time i submitted site map in blogger but the after 3,4 days coming the same issue what is the exactly robot.txt.. & how submit that please guide me

  9. Bharat says

    Hi
    I have a question
    i receive google search console coverage issue warning for blocked by robots.txt
    /wp-admin/widgets.php
    My question is, can i allow for wp-admin/widgets.php to robots.txt and this is safe?

  10. Amila says

    Hello! I really like this article and as I’m a beginner with all this crawling stuff I would like to ask something in this regard. Recently, Google has crawled and indexed one of my websites on a really terrible way, showing the pages in search results which are deleted from the website. The website didn’t have discouraged search engine from indexing in the settings of WordPress at the beginning, but it did later after Google showed even 3 more pages in the search results (those pages also doesn’t exist) and I really don’t understand how it could happen with “discourage search engine from indexing” option on. So, can the Yoast method be helpful and make a solution for my website to Google index my website on the appropriate way this time? Thanks in advance!

    • WPBeginner Support says

      The Yoast plugin should be able to assist in ensuring the pages you have are indexed properly, there is a chance before you discouraged search engines from crawling your site your page was cached.

      Administrador

      • Amila says

        Well yes and from all pages, it cached the once who doesn’t exist anymore. Anyway, as the current page is on “discourage” setting on, is it better to keep it like that for now or to uncheck the box and leave the Google to crawl and index it again with Yoast help? Thanks! With your articles, everything became easier!

        • WPBeginner Support says

          You would want to have Google recrawl your site once it is set up how you want.

  11. Pradhuman Kumar says

    Hi I loved the article, very precise and perfect.
    Just a small suggestion kindly update the image ROBOTS.txt tester, as Google Console is changed and it would be awesome if you add the link to check the robots.txt from Google.

    • WPBeginner Support says

      Thank you for the feedback, we’ll be sure to look into updating the article as soon as we are able.

      Administrador

  12. Kamaljeet Singh says

    My blog’s robots.txt file was:
    User-Agent: *
    crawl-delay: 10

    After reading this post, I have changed it into your recommended robots.txt file. Is that okay that I removed crawl-delay

    • WPBeginner Support says

      It should be fine, crawl-delay tells search engines to slow down how quickly to crawl your site.

      Administrador

  13. Sagar Arakh says

    Thank you for sharing. This was really helpful for me to understand robots.txt
    I have updated my robots.txt to the ideal one you suggested. i will wait for the results now

  14. Jasper says

    thanks for update information for me. Your article was good for Robot txt. file. It gave me a piece of new information. thanks and keep me updating with new ideas.

    • WPBeginner Support says

      For a multisite, you would need to have a robots.txt file in the root folder of each site.

      Administrador

  15. Pacifique Ndanyuzwe says

    My wordpress site is new and my robot.txt by default is
    user-agent: *
    Disallow: /wp-admin/
    Allow: /wp-admin/admin-ajax.php

    I want google to crawl and index my content. Is that robot.txt okay?

  16. Ritesh Seth says

    Great Airticle…

    I was confused from so many days about Robots.txt file and Disallow links. Have copied the tags for robots file. Hope this will solve the issue of my Site

  17. Kurt says

    The files in the screenshots of your home folder are actually located under the public_html folder under my home folder.

    I did not have a /refer folder under my public_html folder.

    I did not have post or page xml files anywhere on my WP account.

    I did include an entry in the robots.txt file I created to disallow crawling my sandbox site. I’m not sure that’s necessary since I’ve already selected the option in WP telling crawlers not to crawl my sandbox site, but I don’t think it will hurt to have the entry.

    • WPBeginner Support says

      Some hosts do rename public_html to home which is why you see it there. You would want to ensure Yoast is active for the XML files to be available. The method in this article is an additional precaution to help with preventing crawling your site :)

      Administrador

  18. Elyn Ashton says

    User-agent: *
    Disallow: /wp-admin/
    Allow: /wp-admin/admin-ajax.php <– This is my robot.txt code but im confuse why my /wp-admin is index? How to no index it?

    • WPBeginner Support says

      If it was indexed previously you may need to give time for the search engine’s cache to clear

      Administrador

  19. Ashish kumar says

    This website really inspire me to start a blog .Thank you lost of tema.this website each and every article have rich of information and explanation.when i have some problem at first i visit this blog . Thank You

  20. Anna says

    I am trying to optimise robots for my website using Yoast. However Tools in Yoast does not have the option for ‘File Editor’.
    There are just two options
    (i) Import and Export
    (ii) Bulk editor
    May you please advise how this can be addressed. Could it be that I am on a free edition of Yoast?

    • WPBeginner Support says

      The free version of Yoast still has the option, your installation may be disallowing file editing in which case you would likely need to use the FTP method.

      Administrador

  21. Emmanuel Husseni says

    I really find this article helpful because I really don’t know much on how robot.txt works but now I do.

    pls what I don’t understand is how do I find the best format of robot.txt to use on my site (I mean one that works generally)?

    I noticed lots of big blogs I check ranking high on search engine uses different robot.txt format..

    I’ll be clad to see a reply from you or just anyone that can help

    • Editorial Staff says

      Having a sitemap and allowing the areas that need to be allowed is the most important part. The disallow part will vary based on each site. We shared a sample in our blog post, and that should be good for most WordPress sites.

      Administrador

    • WPBeginner Support says

      Hey Emmanuel,

      Please see the section regarding the ideal robots.txt file. It depends on your own requirements. Most bloggers exclude WordPress admin and plugin folders from the crawl.

      Administrador

  22. jack says

    Well written article, I recommend the users to do sitemap before creating and enabling their ROBOTS text it will help your site to crawl faster and indexed easily.

    Jack

  23. Cherisa says

    I keep getting the error message below on google webmaster. I am basically stuck. A few things that were not clear to me on this tutorial is where do I find my site’s root files, how do you determine if you already have a “robots.txt” and how do you edit it?

    • WPBeginner Support says

      Hi Cherisa,

      Your site’s root folder is the one that contains folders like wp-admin, wp-includes, wp-content, etc. It also contains files like wp-config.php, wp-cron.php, wp-blogheader.php, etc.

      If you cannot see a robots.txt file in this folder, then you don’t have one. You can go a head and create a new one.

      Administrador

      • Cherisa says

        Thank you for your response. I have looked everywhere and can’t seem to locate these root files as you describe. Is there a path directory I can take that leads to this folder. Like it is under Settings, etc?

  24. Devender says

    I had a decent web traffic to my website. Suddenly dropped to zero in the month of May. Till now I have been facing the issue. Please help me to recover my website.

  25. Haris Aslam says

    Hello There Thank you For This Information, But I Have A Question
    That I Just Create The Sitemap.xml and Robots.txt File, & Its Crawling well. But How Can I Create “Product-Sitemap.xml”
    There is all list of product in sitemap.xml file. Do I Have To Create Product-sitemap.xml separately?

    and submit to google or bing again ?
    Can You please Help me out…
    Thank You

  26. Mahadi Hassan says

    I have a problem on robots.txt file setting. Only one robots.txt is showing for all websites. Please help me to show separate robots.txt file of all websites. I have all separate robots.txt file of all individual website. But only one robots.txt file is showing in browser for all websites.

  27. Debu Majumdar says

    Please explain why did you include
    Disallow: /refer/
    in the beginner Robots.txt example? I do not understand the implications of this line. Is this important for the beginner? You have explained the other two Disallowed ones.

    Thanks.

  28. harsh kumar says

    hey,,i am getting error in yoast seo regarding site map..once i click on fix it ,,,it’s coming again..my site html is not loading properly

  29. Tom says

    I’ve just been reviewing my Google Webmaster Tools account and using the Search Console, I’ve found the following:
    Page partially loaded
    Not all page resources could be loaded. This can affect how Google sees and understands your page. Fix availability problems for any resources that can affect how Google understands your page.

    This is because all CSS stylesheets associated with Plugins are disallowed by the default robots.txt.

    I understand good reasons why I shouldn’t just make this allowable, but what would be an alternative as I would suspect the Google algorithms are marking down the site for not seeing these.

  30. Suren says

    Hi,

    Whenever, I search my site on the google this text appears below the link: “A description for this result is not available because of this site’s robots.txt”

    How, can i solve this issue?

    Regards

    • WPBeginner Support says

      Hi Suren,

      Seems like someone accidentally changed your site’s privacy settings. Go to Settings » Reading page and scroll down to ‘Search engine visibility’ section. Make sure that the box next to is unchecked.

      Administrador

  31. Divyesh says

    Hello

    As i seen in webmaster tool, i got robot.txt file like below :

    User-agent: *
    Disallow: /wp-admin/
    Allow: /wp-admin/admin-ajax.php

    let me know is that okey ? or should i use any other ?

  32. John Cester says

    I want to know, does it a good idea to block (disallow) “/wp-content/plugins/” in robots.tx? Every time i remove a plugin it shows 404 error in some pages of that plugin.

  33. Himanshu singh says

    I loved this explanation. As a beginner I was very confused about robot.txt file and its uses. But now I know what is its purpose.

Deja tu comentario

Gracias por elegir dejar un comentario. Tenga en cuenta que todos los comentarios son moderados de acuerdo con nuestros política de comentarios, y su dirección de correo electrónico NO será publicada. Por favor, NO utilice palabras clave en el campo de nombre. Tengamos una conversación personal y significativa.