The Sitemap app allows you to generate a sitemap.xml
file for your store website. After deploying and installing the app on your account, you can create a sitemap to improve store visibility on search engines such as Google.
To learn how to generate a sitemap, follow the instructions below.
Before you begin
-
This app is available for stores using
vtex.edition-store@3.x
or a later version of the Edition App. To check which Edition App is installed on your account, runvtex edition get
. If it's an older edition, please open a ticket with VTEX Support asking for the installation of thevtex.edition-store@5.x
Edition App. -
Adjust the products, navigation, and custom routes that will be included in the sitemap. Check the Advanced Configuration section for more information.
Instructions
-
Using your terminal and the VTEX IO CLI, log in to your account.
-
Run
vtex use {workspaceName} --production
to use a production workspace or create a production workspace from scratch.Remember to replace the values between the curly brackets with the corresponding values of your environment.
-
Run
vtex install vtex.store-sitemap@2.x
to install the Sitemap app.If you're using
vtex.edition-store@5.x
, skip step 3, as thevtex.store-sitemap@2.x
app is installed by default with this version. Check our Edition App documentation to learn more about the different versions. -
Run
vtex install vtex.admin-graphql-ide@3.x
to install the GraphQL admin IDE. -
In your browser, access the Admin and go to Store Setting > Storefront > GraphQL IDE.
-
From the dropdown list, choose the
vtex.routes-bootstrap@0.x
app. -
If this isn't the first time you're generating the store sitemap or if no changes have been made to the store routes since the last time you generated the store sitemap, go to step 8. Otherwise, run the following query:
_10{_10bootstrap {_10brands_10categories_10}_10}The expected response body is
_10{_10"data":{_10"bootstrap": {_10"brands": true,_10"categories": true_10}_10}_10} -
Now, from the GraphQL IDE dropdown list, select the
vtex.store-sitemap@2.x
app. -
Run the following query:
_10{_10generateSitemap_10}The expected response body is
_10{_10"data": {_10"generateSitemap": true_10}_10}This means your sitemap will be available in some minutes, after being processed and saved on our database.
The time taken to generate a sitemap is proportional to the number of products. For example, the average time to generate a sitemap for a store with 60k products is 30 minutes. For 5k products, the duration should be about 5 minutes.
If you attempt to send a new request to the Sitemap API during store sitemap generation, the following message will be displayed:
_10Sitemap generation already in place_10Next generation available: <End-date>To force a restart, add the
force
argument to the query, as ingenerateSitemap(force: true)
. This will cancel the previous process. -
Check the sitemap generated for the current workspace you're working on by accessing
https://{workspace}--{account}.myvtex.com/sitemap.xml
on your browser. Keep in mind that if you have a cross-border store, you’ll first see an index with a sitemap for each locale.Different
.xml
files are generated based on their entity type (product, category, subcategory, user routes, brand, and department), and each.xml
file supports a maximum of 5k routes. -
If you're happy with the results, run
vtex promote
to promote your workspace and include your sitemap in your master workspace.Once you’ve promoted your workspace, no further actions are needed on your part: you’re ready to check the store sitemap by accessing
https://{account}.myvtex.com/sitemap.xml
on your browser.
Advanced configuration
Managing routes
You can manage whether to include products, navigation, apps, and/or routes containing a specific term in your sitemap. To do that, follow the instructions below:
-
In your browser, type
{workspace}--{account}.myvtex.com/admin
, replacing the values between curly brackets with the corresponding values of your environment, to access the account's Admin of the production workspace you're working on. -
Go to Account settings > Apps > My apps and search for Sitemap app.
-
Enable or disable products, navigation, apps, or routes containing a specific term for your scenario.
Enabling custom routes
If you have custom pages configured in a routes.json
file and want them to be included in the store sitemap, add isSitemapEntry=true
as a prop of the routes you want to include in the sitemap. Example:
_10{_10 "store.custom#about-us": {_10 "path": "/about-us",_10 "isSitemapEntry": true_10 }_10}
Once everything is set up, go back to step 4 of the Instructions.
Extending the sitemap
To add custom routes created by an app (for example, the ones created by store-locator
) to the store sitemap, the app must respond to an XML file containing a list of the routes created by that app. Lastly, you must include the path to the XML file that your app responds to as an index of the store sitemap.
For implementation details, check the following instructions:
-
Create or modify your app to respond to the following route
/sitemap/{index-name}.xml
and to return an XML file containing the data that you want the search engine (for example, Google) to index. Replace the values between the curly brackets according to your scenario.We recommend using a pre-generated XML file. Otherwise, the XML file will be built from scratch for every request, consuming more time to complete the task.
-
Publish and install your app in a production workspace.
-
To make your index available in the sitemap root file (
/sitemap.xml
), access the account Admin of the workspace you're working on, and select the GraphQL IDE. -
From the dropdown list, choose the
vtex.store-sitemap@2.x
app and perform the following mutation, adapting it to your scenario:_10mutation {_10saveIndex(index: "{index-name}")_10}If you have a cross-border store, the
saveIndex
mutation also accepts thebinding
ID as an argument, which means that by specifying thebinding
ID, you can add your new index to the sitemap of the desired binding. If thebinding
ID is not specified, the mutation will consider the default binding of the store. -
Check the updated sitemap for the current workspace you're working on by accessing
https://{workspace}--{account}.myvtex.com/sitemap.xml
in your browser. -
If you're happy with the results, run
vtex promote
to promote your workspace and include the sitemap in your master workspace.
Removing a custom route
If you ever want to remove a custom route, you can execute the following mutation, which takes the same arguments as saveIndex
:
_10mutation {_10 deleteIndex(index: "{index-name}")_10}