1page.title=Specifying App Content for Indexing
2trainingnavtop=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
27for the Google search engine, can also index content in your Android app.
28By opting in, you can allow Googlebot to crawl the content in the APK
29through the Google Play Store to index the app content. To indicate which app
30content you’d like Google to index, simply add link elements either to
31your existing <a href="https://support.google.com/webmasters/answer/156184?hl=en" class="external-link" target="_blank">Sitemap</a> file or in the {@code &lt;head&gt;} element of each web
32page 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
35format:</p>
36<pre>
37android-app://&lt;package_name&gt;/&lt;scheme&gt;/&lt;host_path&gt;
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
42listed 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
48or 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 &lt;xhtml:link&gt;} 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
54your web page by using the {@code &lt;loc&gt;} tag, and a corresponding deep
55link to your Android app by using the {@code &lt;xhtml:link&gt;} tag.</p>
56<pre>
57&lt;?xml version="1.0" encoding="UTF-8" ?&gt;
58&lt;urlset
59    xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
60    xmlns:xhtml="http://www.w3.org/1999/xhtml"&gt;
61    &lt;url&gt;
62        &lt;loc&gt;example://gizmos&lt;/loc&gt;
63            &lt;xhtml:link
64                rel="alternate"
65                href="android-app://com.example.android/example/gizmos" /&gt;
66    &lt;/url&gt;
67    ...
68&lt;/urlset&gt;
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
72Sitemap file, you can annotate the deep links in the HTML markup of your web
73pages. You can do this in the {@code &lt;head&gt;} section for each web
74page by adding a {@code &lt;link&gt;} tag and specifying the deep link as an
75alternate URI.</p>
76<p>For example, the following HTML snippet shows how you might specify the
77corresponding deep link in a web page that has the URL
78{@code example://gizmos}.</p>
79<pre>
80&lt;html&gt;
81&lt;head&gt;
82    &lt;link rel="alternate"
83          href="android-app://com.example.android/example/gizmos" /&gt;
84    ...
85&lt;/head&gt;
86&lt;body&gt; ... &lt;/body&gt;
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>
92file. When Googlebot indexes your app content, your app might make HTTP
93requests as part of its normal operations. However, these requests will
94appear to your servers as originating from Googlebot. Therefore, you must
95configure your server's {@code robots.txt} file properly to allow these
96requests.</p>
97<p>For example, the following {@code robots.txt} directive shows how you might
98allow access to a specific directory in your web site (for example,
99{@code /api/}) that your app needs to access, while restricting Googlebot's
100access to other parts of your site.</p>
101<pre>
102User-Agent: Googlebot
103Allow: /api/
104Disallow: /
105</pre>
106<p>To learn more about how to modify {@code robots.txt} to control web
107crawling, see the <a href="https://developers.google.com/webmasters/control-crawl-index/docs/getting_started" class="external-link" target="_blank">Controlling Crawling
108and Indexing Getting Started</a> guide.</p>
109