sitemap.xml file extension, does it have to be .xml?

5,742

Solution 1

It has been verified that a PHP file can be used as a sitemap file such as sitemap.php

  1. I checked http://sitemaps.org (the website with the specification information for sitemaps) and there is no mention that the file must be saved in the .XML format. I will have to say that yes, it will work, as long as Google does not have a problem with the extension for some reason.

  2. When you go through Google Webmasters Tools and click on submit/test a sitemap you are prompted with your site's root directory http://example.com/ immediately followed by a text field you can enter any file name and extension into; with no file extension forcing you to use an actual "XML" file here I'm assuming that you can use a sitemap with a .PHP extension.

Solution 2

I gzip my sitemap to mymap.xml.gz and it works fine when I declare it so in my robots.txt. If you have a Google Webmaster Tools (GWT) account, GWT will tell you if there is any issue with your sitemap.

So, no, the extension does not have to be .xml.

Share:
5,742

Related videos on Youtube

Duarte Patrício
Author by

Duarte Patrício

Updated on September 18, 2022

Comments

  • Duarte Patrício
    Duarte Patrício almost 2 years

    Do XML sitemap files have to end with the .xml file extension?

    On the Bigcommerce platform, their XML sitemap file are defined as:

    http://www.examplesite.com/xmlsitemap.php
    

    The sitemap file is all correctly marked up and and when saving locally its saves as an .xml file. I've also seen some Joomla sitemap plugins create sitemaps with .php extensions.

    The Sitemap Protocol site doesn't cover this.

    I unfortunately don't have access to GWT too see if it verifies.

    • Admin
      Admin almost 10 years
      Don't forget to approve an answer if you like it, thanks!
    • Admin
      Admin almost 9 years
      Use an HTTP router like github.com/nikic/FastRoute and create a route that matches "/sitemap\.xml", then you render a xml response.
  • DisgruntledGoat
    DisgruntledGoat about 11 years
    But does it need to be served with an XML mime type i.e. text/xml?