Sitemap Index Configuration with Magento and HTML sitemap.xml using Magmi
In this blog post, we will discuss how to configure an XML sitemap for your Magento store using sitemap_index.xml
, html sitemap.xml
and Magmi
. Magento is a popular e-commerce platform that supports generating XML sitemaps out of the box. However, in some cases, we might need to customize or generate an HTML sitemap. To achieve this, we can make use of sitemap_index.xml
, html sitemap.xml
and Magmi (Magento Data Migration Tool).
Prerequisites
- A running Magento store
- Basic knowledge of Magento configuration files
Step 1: Create Magento XML Sitemap
First, let us create a default XML sitemap for your Magento store. Magento generates a sitemap.xml
file by default in the following locations based on your Magento installation:
- For a single store:
<magento_root>/pub/sitemap.xml
- For multiple stores:
<magento_root>/store/[Store_Code]/pub/sitemap.xml
Step 2: Configure sitemap_index.xml
Now, we will create a sitemap_index.xml
file that will include links to all our individual XML sitemaps (catalog, CMS, etc.). This file will be located at <magento_root>/pub/sitemap_index.xml
.
Let us assume you are using the default Magento setup with a single store. In this case, create or edit the following file: <magento_root>/pub/sitemap_index.xml
with the following content:
<?xml version="1.0" encoding="UTF-8"?>
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<sitemap>
<loc>sitemap_catalog.xml</loc>
</sitemap>
<sitemap>
<loc>sitemap_cms.xml</loc>
</sitemap>
<!-- Add more sitemaps as needed -->
</sitemapindex>
Step 3: Configure html sitemap.xml
with Magmi
Since Magento does not support generating HTML sitemaps out of the box, we will create an html sitemap.xml
using Magmi (Magento Data Migration Tool). This tool can be used to perform mass updates on Magento stores. In our case, we will use it to generate a static HTML sitemap file.
First, download and install Magmi from: https://github.com/magmi/magmi.
Next, create or edit the following Magmi configuration file at <magmi_root>/conf/magmi.ini
:
[Magmi]
data_directory=./data
logfile=./logs/magmi.log
max_execution_time=-1
[Connection]
db_host = localhost
db_name = magento
db_user = magento
db_passwd = magento
[Magento]
magento_root=<your_magento_installation_path>
magento_store_code=<your_magento_store_code>
[Sitemap]
sitemap_output_dir=./output/html-sitemap/
sitemap_index_file=./output/html-sitemap/sitemap_index.xml
sitemap_filename=sitemap_%d.xml
generate_html_sitemap = true
generate_index_html_file = true
Replace <your_magento_installation_path>
and <your_magento_store_code>
with your actual Magento installation path and store code, respectively.
Now, navigate to the <magmi_root>/scripts/
directory and run:
./generate-sitemaps.sh
This command will generate an XML sitemap in the format sitemap_[page number].xml
for each page on your Magento store, as well as a single sitemap_index.xml
file and an HTML sitemap named sitemap_index.html
. These files are located under the <magmi_root>/output/html-sitemap/
directory.
Conclusion
In this blog post, we covered how to configure an XML sitemap for your Magento store using sitemap_index.xml
, and generated an HTML sitemap by making use of Magmi. The steps outlined above will help you create static HTML sitemaps for your Magento store that can be easily indexed by search engines like Google.
Keep in mind that the HTML sitemap generated using this method is a static file and needs to be updated manually whenever new content is added to the Magento store. To automate the process, you might need to implement additional scripts or cron jobs.