sitemap.xml file extension, does it have to be .xml?
Solution 1
It has been verified that a PHP file can be used as a sitemap file such as sitemap.php
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.
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
.
Related videos on Youtube
Duarte Patrício
Updated on September 18, 2022Comments
-
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 almost 10 yearsDon't forget to approve an answer if you like it, thanks!
-
Admin almost 9 yearsUse an HTTP router like github.com/nikic/FastRoute and create a route that matches "/sitemap\.xml", then you render a xml response.
-
-
DisgruntledGoat about 11 yearsBut does it need to be served with an XML mime type i.e. text/xml?