Can a relative sitemap url be used in a robots.txt?

后端 未结 3 1286
遇见更好的自我
遇见更好的自我 2020-12-04 08:12

In robots.txt can I write the following relative URL for the sitemap file?

sitemap: /sitemap.ashx

Or do I have to use the complete (absolut

相关标签:
3条回答
  • 2020-12-04 08:32

    According to the official documentation on sitemaps.org it needs to be a full URL:

    You can specify the location of the Sitemap using a robots.txt file. To do this, simply add the following line including the full URL to the sitemap:

    Sitemap: http://www.example.com/sitemap.xml
    
    0 讨论(0)
  • 2020-12-04 08:32

    Good technical & logical question my dear friend. No in robots.txt file you can't go with relative URL of the sitemap; you need to go with the complete URL of the sitemap.

    It's better to go with "sitemap: https://www.example.com/sitemap_index.xml"

    In the above URL after the colon gives space. I also like to support Deepak.

    0 讨论(0)
  • 2020-12-04 08:44

    Google crawlers are not smart enough, they can't crawl relative URLs, that's why it's always recommended to use absolute URL's for better crawlability and indexability.

    Therefore, you can not use this variation

    > sitemap: /sitemap.xml
    

    Recommended syntax is

    Sitemap: https://www.yourdomain.com/sitemap.xml
    

    Note:

    • Don't forgot to capitalise the first letter in "sitemap"
    • Don't forgot to put space after "Sitemap:"
    0 讨论(0)
提交回复
热议问题