1 page.title=Specifying App Content for Indexing 2 trainingnavtop=true 3 4 @jd:body 5 6 <!-- This is the training bar --> 7 <div id="tb-wrapper"> 8 <div id="tb"> 9 10 <h2>This lesson teaches you to</h2> 11 <ol> 12 <li><a href="#sitemap">Add Deep Links in Your Sitemap</a></li> 13 <li><a href="#webpages">Add Deep Links in Your Web Pages</a></li> 14 <li><a href="#robots">Allow Google to Crawl URLs Requested By Your App</a></li> 15 </ol> 16 17 <h2>You should also read</h2> 18 <ul> 19 <li><a href="https://www.google.com/webmasters/tools/home?hl=en" class="external-link" target="_blank">Webmaster Tools</a></li> 20 <li><a href="https://support.google.com/webmasters/answer/183668" class="external-link" target="_blank">Creating Sitemaps</a></li> 21 <li><a href="https://support.google.com/webmasters/answer/182072?hl=en" class="external-link" target="_blank">Googlebot</a></li> 22 </ul> 23 </div> 24 </div> 25 26 <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 27 for the Google search engine, can also index content in your Android app. 28 By opting in, you can allow Googlebot to crawl the content in the APK 29 through the Google Play Store to index the app content. To indicate which app 30 content youd like Google to index, simply add link elements either to 31 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 32 page in your site, in the same way as you would for web pages.</p> 33 34 <p>The deep links that you share with Google Search must take this URI 35 format:</p> 36 <pre> 37 android-app://<package_name>/<scheme>/<host_path> 38 </pre> 39 <p>The components that make up the URI format are:</p> 40 <ul> 41 <li><strong>package_name.</strong> Represents the package name for your APK as 42 listed in the <a href="https://play.google.com/apps/publish" class="external-link" target="_blank">Google Play Developer Console</a>.</li> 43 <li><strong>scheme.</strong> The URI scheme that matches your intent filter.</li> 44 <li><strong>host_path.</strong> Identifies the specific content within your application. 45 </li> 46 </ul> 47 <p>The following sections describe how to add a deep link URI to your Sitemap 48 or web pages.</p> 49 <h2 id="sitemap">Add Deep Links in Your Sitemap</h2> 50 <p>To annotate the deep link for Google Search app indexing in your 51 <a href="https://support.google.com/webmasters/answer/156184?hl=en" class="external-link" target="_blank">Sitemap</a>, use the 52 {@code <xhtml:link>} tag and specify the deep link as an alternate URI.</p> 53 <p>For example, the following XML snippet shows how you might specify a link to 54 your web page by using the {@code <loc>} tag, and a corresponding deep 55 link to your Android app by using the {@code <xhtml:link>} tag.</p> 56 <pre> 57 <?xml version="1.0" encoding="UTF-8" ?> 58 <urlset 59 xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" 60 xmlns:xhtml="http://www.w3.org/1999/xhtml"> 61 <url> 62 <loc>example://gizmos</loc> 63 <xhtml:link 64 rel="alternate" 65 href="android-app://com.example.android/example/gizmos" /> 66 </url> 67 ... 68 </urlset> 69 </pre> 70 <h2 id="webpages">Add Deep Links in Your Web Pages</h2> 71 <p>Instead of specifying the deep links for Google Search app indexing in your 72 Sitemap file, you can annotate the deep links in the HTML markup of your web 73 pages. You can do this in the {@code <head>} section for each web 74 page by adding a {@code <link>} tag and specifying the deep link as an 75 alternate URI.</p> 76 <p>For example, the following HTML snippet shows how you might specify the 77 corresponding deep link in a web page that has the URL 78 {@code example://gizmos}.</p> 79 <pre> 80 <html> 81 <head> 82 <link rel="alternate" 83 href="android-app://com.example.android/example/gizmos" /> 84 ... 85 </head> 86 <body> ... </body> 87 </pre> 88 89 <h2 id="robots">Allow Google to Crawl URLs Requested By Your App</h2> 90 <p>Typically, you control how Googlebot crawls publicly accessible URLs on 91 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> 92 file. When Googlebot indexes your app content, your app might make HTTP 93 requests as part of its normal operations. However, these requests will 94 appear to your servers as originating from Googlebot. Therefore, you must 95 configure your server's {@code robots.txt} file properly to allow these 96 requests.</p> 97 <p>For example, the following {@code robots.txt} directive shows how you might 98 allow access to a specific directory in your web site (for example, 99 {@code /api/}) that your app needs to access, while restricting Googlebot's 100 access to other parts of your site.</p> 101 <pre> 102 User-Agent: Googlebot 103 Allow: /api/ 104 Disallow: / 105 </pre> 106 <p>To learn more about how to modify {@code robots.txt} to control web 107 crawling, see the <a href="https://developers.google.com/webmasters/control-crawl-index/docs/getting_started" class="external-link" target="_blank">Controlling Crawling 108 and Indexing Getting Started</a> guide.</p> 109