page.title=Specifying App Content for Indexing trainingnavtop=true @jd:body <!-- This is the training bar --> <div id="tb-wrapper"> <div id="tb"> <h2>This lesson teaches you to</h2> <ol> <li><a href="#sitemap">Add Deep Links in Your Sitemap</a></li> <li><a href="#webpages">Add Deep Links in Your Web Pages</a></li> <li><a href="#robots">Allow Google to Crawl URLs Requested By Your App</a></li> </ol> <h2>You should also read</h2> <ul> <li><a href="https://www.google.com/webmasters/tools/home?hl=en" class="external-link" target="_blank">Webmaster Tools</a></li> <li><a href="https://support.google.com/webmasters/answer/183668" class="external-link" target="_blank">Creating Sitemaps</a></li> <li><a href="https://support.google.com/webmasters/answer/182072?hl=en" class="external-link" target="_blank">Googlebot</a></li> </ul> </div> </div> <p>Google's web crawling bot (<a href="https://support.google.com/webmasters/answer/182072?hl=en" class="external-link" target="_blank">Googlebot</a>), which crawls and indexes web sites for the Google search engine, can also index content in your Android app. By opting in, you can allow Googlebot to crawl the content in the APK through the Google Play Store to index the app content. To indicate which app content you’d like Google to index, simply add link elements either to your existing <a href="https://support.google.com/webmasters/answer/156184?hl=en" class="external-link" target="_blank">Sitemap</a> file or in the {@code <head>} element of each web page in your site, in the same way as you would for web pages.</p> <p>The deep links that you share with Google Search must take this URI format:</p> <pre> android-app://<package_name>/<scheme>/<host_path> </pre> <p>The components that make up the URI format are:</p> <ul> <li><strong>package_name.</strong> Represents the package name for your APK as listed in the <a href="https://play.google.com/apps/publish" class="external-link" target="_blank">Google Play Developer Console</a>.</li> <li><strong>scheme.</strong> The URI scheme that matches your intent filter.</li> <li><strong>host_path.</strong> Identifies the specific content within your application. </li> </ul> <p>The following sections describe how to add a deep link URI to your Sitemap or web pages.</p> <h2 id="sitemap">Add Deep Links in Your Sitemap</h2> <p>To annotate the deep link for Google Search app indexing in your <a href="https://support.google.com/webmasters/answer/156184?hl=en" class="external-link" target="_blank">Sitemap</a>, use the {@code <xhtml:link>} tag and specify the deep link as an alternate URI.</p> <p>For example, the following XML snippet shows how you might specify a link to your web page by using the {@code <loc>} tag, and a corresponding deep link to your Android app by using the {@code <xhtml:link>} tag.</p> <pre> <?xml version="1.0" encoding="UTF-8" ?> <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xhtml="http://www.w3.org/1999/xhtml"> <url> <loc>example://gizmos</loc> <xhtml:link rel="alternate" href="android-app://com.example.android/example/gizmos" /> </url> ... </urlset> </pre> <h2 id="webpages">Add Deep Links in Your Web Pages</h2> <p>Instead of specifying the deep links for Google Search app indexing in your Sitemap file, you can annotate the deep links in the HTML markup of your web pages. You can do this in the {@code <head>} section for each web page by adding a {@code <link>} tag and specifying the deep link as an alternate URI.</p> <p>For example, the following HTML snippet shows how you might specify the corresponding deep link in a web page that has the URL {@code example://gizmos}.</p> <pre> <html> <head> <link rel="alternate" href="android-app://com.example.android/example/gizmos" /> ... </head> <body> ... </body> </pre> <h2 id="robots">Allow Google to Crawl URLs Requested By Your App</h2> <p>Typically, you control how Googlebot crawls publicly accessible URLs on your site by using a <a href="https://developers.google.com/webmasters/control-crawl-index/docs/robots_txt" class="external-link" target="_blank">{@code robots.txt}</a> file. When Googlebot indexes your app content, your app might make HTTP requests as part of its normal operations. However, these requests will appear to your servers as originating from Googlebot. Therefore, you must configure your server's {@code robots.txt} file properly to allow these requests.</p> <p>For example, the following {@code robots.txt} directive shows how you might allow access to a specific directory in your web site (for example, {@code /api/}) that your app needs to access, while restricting Googlebot's access to other parts of your site.</p> <pre> User-Agent: Googlebot Allow: /api/ Disallow: / </pre> <p>To learn more about how to modify {@code robots.txt} to control web crawling, see the <a href="https://developers.google.com/webmasters/control-crawl-index/docs/getting_started" class="external-link" target="_blank">Controlling Crawling and Indexing Getting Started</a> guide.</p>