Weixin provides an Mini Program internal search feature. Developers can use the sitemap.json
or admin console page inclusion switch to set whether the Mini Program page permits indexing by Weixin. if allowed, Weixin will use a crawler to create an index of the page content. When a user's search keyword triggers this index, the Mini Program page may be shown in the search results.
When the crawler accesses a Mini Program page, it carries a specific user-agent: mpcrawler
and scene value: 1129
. Note that if a Mini Program crawler discovers that page data is inconsistent with that displayed to real users, the page will not be indexed.
Specific configuration instructions
- Page inclusion settings: You can disable indexing for the entire Mini Program in the Mini Program Admin Console > Settings > Basic Settings > Page Inclusion Settings. Details
- Configuration via sitemap: You can disable indexing for specific pages.
# Configuration via sitemap
The sitemap.json
file in the Mini Program root directory is used to configure indexing by Weixin for the Mini Program and its pages.
For details of configuration items, see Mini Program Sitemap Configuration.
Example 1:
{
"rules":[{
"action": "allow",
"page": "*"
}]
}
All pages are indexed by Weixin by default.
Example 2:
{
"rules":[{
"action": "disallow",
"page": "path/to/page"
}]
}
The path/to/page
page is not indexed, but all other pages are.
Example 3:
{
"rules":[{
"action": "allow",
"page": "path/to/page"
}, {
"action": "disallow",
"page": "*"
}]
}
The path/to/page
page is indexed, but all other pages are not.
Example 4:
{
"rules":[{
"action": "allow",
"page": "path/to/page",
"params": ["a", "b"],
"matching": "inclusive"
}, {
"action": "allow",
"page": "*"
}]
}
The path/to/page
pages containing parameters a and b
are given priority in indexing and the other pages are indexed. For example:
path/to/page?a=1&b=2
=> Indexed firstpath/to/page?a=1&b=2&c=3
=> Indexed firstpath/to/page
=> Indexedpath/to/page?a=1
=> Indexed- All other pages are indexed
Example 5:
{
"rules":[{
"action": "allow",
"page": "path/to/page",
"params": ["a", "b"],
"matching": "inclusive"
}, {
"action": "disallow",
"page": "*"
}, {
"action": "allow",
"page": "*"
}]
}
path/to/page?a=1&b=2
=> Indexed firstpath/to/page?a=1&b=2&c=3
=> Indexed firstpath/to/page
=> Not indexedpath/to/page?a=1
=> Not indexed- All other pages are not indexed
Note: If there is no sitemap.json file, all pages will be indexed by default.
Note: {"action": "allow", "page": "*"}
are default rules of the lowest priority. Pages for which "disallow" is not explicitly specified are indexed by default.
# Debugging
In a Mini Program project, when you set a sitemap
configuration file (sitemap.json
by default), debug information about whether the current page is indexed is displayed on the Weixin DevTools console (the latest version of Weixin DevTools supports index prompts).
Note: The
sitemap
index prompt is enabled by default. You can disable it by settingcheckSiteMap
tofalse
insetting
of the Mini Program project configuration fileproject.config.json
.