All B2C customers need the capability to publish their product list and product detail pages to Google search engine so that they can be searchable and linkable. The UI template loads data asynchronously and Angular renders the data retrieved from Salesforce.com.

Follow the steps below to enable Google search to crawl a Digital Commerce website by creating a sitemap index, dynamic sitemap’s and register them with Google.

Step 1: Create a robots.txt file and set it in the Community page

<apex:page contentType="text/plain" showHeader="false">
User-agent: *
Disallow: /<store name>/cart?
Disallow: /<store name>/manage-cart?
Disallow: /<store name>/Orders?
Disallow: /<store name>/installed-products?
Disallow: /<store name>/my-account?
Sitemap: http://<domain>/<store name>/APTSSiteIndex
</apex:page>
CODE

Step 2: Create a APTSSiteIndex Visualforce page

Create a APTSSiteIndex Visualforce page that renders the XML as below.

Pre-requisite: There must be 2 existing sitemaps, one for all products and one for all categories.

<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"> 
  <url>
    <loc>http://<domain>/<store name>/APTSSiteMapProducts</loc>
    <lastmod>2019-10-06</lastmod>
  </url>
  <url>
    <loc>http://<domain>/<store name>/APTSSiteMapCategories</loc>
    <lastmod>2019-10-06</lastmod>
  </url>
</urlset>
CODE

Step 3: Create a APTSSiteMapProducts Visualforce page

Create a APTSSiteMapProducts VF page that will generate all the Active Products. Each Sitemap can only have 10K urls.

Sample Output

<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"> 
  <url>
    <loc>http://<domain>/<store name>/APTSProduct?id=<productcode></loc>
    <lastmod>2019-10-06</lastmod>
  </url>
</urlset>
CODE

The APTSProduct renders the following html data.

HTML Data

<html>
<head>
<title>Executive Anvil</title>
<script type="application/ld+json">
{
  "@context": "https://schema.org/",
  "@type": "Product",
  "name": "Executive Anvil",
  "url": "https://example.com/anvil",
  "image": [
    "https://example.com/photos/1x1/photo.jpg",
    "https://example.com/photos/4x3/photo.jpg",
    "https://example.com/photos/16x9/photo.jpg"
   ],
  "description": "Sleeker than ACME's Classic Anvil, the Executive Anvil is perfect for the business traveler looking for something to drop from a height.",
  "sku": "0446310786",
  "offers": {
    "@type": "Offer",
    "url": "https://example.com/anvil",
    "priceCurrency": "USD",
    "price": "119.99",
    "priceValidUntil": "2020-11-05"
  }
}
</script>
</head>
<body>
</body>
</html>
CODE