Improve SEO with a Sitemap
Sitemaps provide search crawlers with instructions on the pages to index and the site hierarchy, which can improve your SEO rankings. Submitting a sitemap to tools such as Google Search Console can also help identify broken links or duplicate content. B2C Commerce includes sitemap management features for:
- Storefront Reference Architecture (SFRA) and SiteGenesis (SG) ecommerce sites
- Headless ecommerce applications like those built on Progressive Web App (PWA) Kit
This guide explains how to create and upload a sitemap for a headless site built on B2C Commerce.
You can use the sitemap feature for headless sites if you built your site on B2C Commerce with any of these storefront implementations:
- Composable Storefront (PWA Kit) for your whole site
- A hybrid storefront (SG/SFRA and PWA Kit)
- Your own bespoke headless implementation
Unless otherwise stated, the steps in this guide apply to all three implementations.
- If your routes are configured in Business Manager, create a sitemap in Business Manager. See Create a Sitemap.
- If your routes aren’t configured in Business Manager, create a sitemap or supplement your existing sitemap by using this API endpoint: uploadCustomSitemapAndTriggerSitemapGeneration.
- If you haven’t done so already, set up a vanity domain in embedded CDN (eCDN).
If you’re not routing your site traffic directly to eCDN, create a subdomain such as seo.example.com
to serve your sitemap. Replace example.com
with your vanity domain name.
- In Business Manager (BM), configure a hostname alias for your site that matches your vanity domain.
- In BM, generate a sitemap. You can find your sitemap at
example.com/sitemap_index.xml
. Replace “example.com” with your vanity domain name. - Update your existing
robots.txt
file in your PWA Kit or headless site withexample.com/sitemap_index.xml
. - If you have a hybrid storefront project (SFRA and PWA Kit) then also:
- Notify search engines about your B2C Commerce sitemap.
Improve your site's visibility, user experience, and efficiency by uploading your site map to your domain's root. In your PWA Kit project:
-
In
ssr.template-retail-react-app/app/ssr.js
, add a path to your sitemap. For example:app.get('/sitemap_index.xml', runtime.serveStaticFile('static/sitemap_index.xml'))
-
Update the
ssrShared
property intemplate-retail-react-app/config/default.js
so that your sitemap is available to the server-side rendering system. For example:
-
Deploy your bundle to your chosen environment.
-
Confirm that your sitemap is available in your domain's root. In this example, replace
test-env.example.com
with the path that applies to your deployed environment:test-env.example.com/sitemap_index.xml
- Make sure that your sitemap incorporates all the crucial pages that you want search engines to find and index. This includes product listing pages, product detail pages, blog posts, and other relevant content.
- If your sitemap becomes very large, consider using priority settings in BM. You can use these settings to indicate which pages are most important for search engines to crawl first. See Generate Sitemaps in B2C Commerce.
- Schedule a job to update the sitemap regularly so that search engines are aware of these changes and can index them promptly. See Generate Sitemaps in B2C Commerce.
- Review and update any crawl directives in the
robots.txt
file to ensure that they align with your SEO strategy and don’t block important parts of the site. - Regularly test the accessibility of the sitemap URL to ensure that search engines and users can reach it without any issues.
This section provides suggested solutions for a few common errors that you can encounter while using sitemaps.
Potential Cause: Syntax errors or other errors in your sitemap.
Suggested Solution: Ensure that all URLs in the sitemap are absolute and correctly formatted. Use the correct protocol (http or https) and don’t include session IDs or other dynamic parameters. See Generate Sitemaps in B2C Commerce.
Potential Cause: Inaccurate URLs in your sitemap.
Suggested Solution: Regularly check the URLs in your sitemap to ensure that they’re accessible and don't return errors. Fix any broken links or server issues. See Generate Sitemaps in B2C Commerce.
Potential Cause: Blocking directives errors or other issues in your robots.txt
file.
Suggested Solution: Test the robots.txt file by using a robots.txt tester. Ensure that there are no blocking directives that prevent search engines from accessing important pages or the sitemap itself. See Generate a Robots.txt File with Business Manage for B2C Commerce.