Magento - Where do I go to edit file that outputs the sitemap?

Magento - Where do I go to edit file that outputs the sitemap?

October 18, 2026 · Illustrated author avatarBy Stefan Bogdanescu
Magento - Where do I go to edit file that outputs the sitemap?

Editing the Google Sitemap Template in Magento 1.5

As an experienced developer with extensive knowledge of e-commerce platforms like Magento, I understand your need to customize the sitemap generation process to include full URLs instead of just URL keys. Here’s a step-by-step guide on how to achieve this:

Understanding the Current Sitemap Generation Process in Magento 1.5

Magento generates the Google sitemap using the Mage_Sitemap_Model_Observer class located at app/code/core/Mage/Sitemap/Model/Observer.php. This observer triggers when a product is saved, updating the sitemap with the URL key (e.g., /my-jacket.html).

Identifying the Problem: Magento Uses Only URL Keys

The issue arises because Magento’s core functionality only uses the URL key for the sitemap entries. It doesn’t automatically include the full path from the category structure.

The Desired Solution: Include Full URLs in the Sitemap

Your approach of looping through the product categories and building a custom URL is correct, but it needs to be integrated with Magento’s core sitemap generation process.

Where to Edit the Sitemap Template

To update the sitemap template, you’ll need to modify the app/design/frontend/default/[your-theme]/template/catalog/sitemap.xml file. This file is responsible for rendering the XML structure of the sitemap.

How to Implement Your Custom URL Logic

In the sitemap.xml file, look for the section where product URLs are generated. It typically looks like this:

<url>
  <loc>{{var url}}</loc>
  <lastmod>{{var last_modified_date}}</lastmod>
  <changefreq>weekly</changefreq>
  <priority>0.5</priority>
</url>

To apply your custom URL logic, you can use Magento’s template variables and the getUrlPath method from the category model:

<loc>{{var catalog_category.getUrlPath()}}{{var product.getUrlKey()}}</loc>

This will generate URLs like /outerwear/jackets/my-jacket.html.

Finalizing Your Changes

After updating the sitemap.xml file, clear your cache using Magento’s built-in cache management system: go to System > Cache Management and click “Flush Magento Cache.”

Testing the New Sitemap

To verify your changes, visit the sitemap page (usually located at http://www.yourwebsite.com/sitemap.xml) or use an SEO tool like Google Search Console to check if the new URLs are being generated correctly.

Remember that any changes you make should be done using a child theme to avoid overwriting core files during updates. For more detailed information on customizing your Magento theme, I recommend exploring our comprehensive guide on Magento Theme Development.

Conclusion

By following this guide, you’ve successfully updated the Google sitemap template in Magento 1.5 to include full URLs instead of just URL keys. This change will provide a more accurate representation of your website’s structure for search engines like Google.

If you encounter any further issues or need additional assistance with Magento development, feel free to explore our Magento Development Services. We offer expert consulting and solutions tailored to meet the unique needs of e-commerce businesses.

Magento 1 Catalog Extensions Themes

Our network