Solution To The Magento 1 Default XML Sitemap Generator Problem

Share your love

When I was learning about XML sitemaps, I learned that the number one guideline states that “Google will crawl URLs exactly as listed” in the sitemap. But in 2010, while I was working on one of the first Magento sites I was able to install myself, I saw that the sitemap it generates contains a homepage URL with an added “/home” at the back. Something like this:

That created a problem for me because I knew I need the correct homepage URL in my XML sitemap when I submit it to Google Webmaster Tools (now Google Search Console) and Bing Webmaster Tools.

I found out that I can copy a Magento core file into the /app/code/local/ folder and Magento will use whatever changes I put in that file. And, also my changes will be immune to future Magento upgrades if I put them under the local folder. So, I tried that approach to solve my problem.

I enumerated for you below the steps I have taken.

  1. Using FTP, I opened /app/code/core/Mage/ and found the /Sitemap/ folder.
  2. From that folder, I downloaded the /Model/Sitemap.php file to my computer then opened it with my favorite html editor. (You can use Notepad, Notepad++, Dreamweaver, etc.)
  3. Within that file, I found this line of code which I still see in Magento
  4. I replaced it with this code:

    str_replace is a standard PHP function.

  5. Then, I uploaded the updated Sitemap.php file to /app/code/local/Mage/Sitemap/Model/ folder. (If you have a fresh Magento install you will have to create the /app/code/local/ folder where you can add the /Mage/Sitemap/Model/ sub folders)
  6. Next, I logged into Magento admin and went to Catalog => Google Sitemap to regenerate my sitemap. (Please see Video 1 below If you haven’t generated a sitemap via the Magento backend before.)
  7. This next step is very important. I made sure I reindexed Magento via System => Index Management and cleared the Magento Cache in System=>Cache Management. (See Video 2 and Video 3 below to learn how to safely do these two things)
  8. After that, I refreshed the sitemap I was viewing in my web browser, e.g. and saw that the URL is replaced by which is exactly what I want submitted with my XML sitemap.

Video 1

Video 2

Video 3

If you are going to try this same solution, please do it first on a staging environment. Never attempt anything on a production site even if you are 100% sure it will work okay. And, most important of all, backup your Magento files and database before starting work on them.

I hope what I’ve shared with you in this post helps. Thank you for taking the time to read. I invite you to leave a comment or suggest any other solution for this same topic. Lastly, please don’t forget to subscribe to my blog.

Share your love

Leave a Reply

Physical Address

304 North Cardinal St.
Dorchester Center, MA 02124