在公司发展还没有那么成熟的时候,也许你的测试网站是外网可以公开访问的,也许你网站中的机密图片在测试环境(不小心上到正式环境)却被搜索引擎无情抓取,以及有些内部用户才能使用的网址,你并不想被搜索引擎抓到。
这时候,就要祭出Google SEO 搜索中心了。
文档阅读:
Google搜索中心
重点:
- 首先进行网站所有权验证,可以通过HTML文件和Meta标签两种方式。
- 将测试、正式网站都验证上,之后可以进行Google搜索的管理。
测试网站 / 不想被搜索引擎收录的网址
参考文档:
从 Google 搜索结果中移除您网站上托管的网页
robots.txt 简介
- 紧急在 【编制索引-删除】的这个菜单中申请移除。(1天内受理,管用6个月)
- 永久有效:然后在网站上增加robots.txt文件,它规定了搜索引擎抓取工具可以访问网站上的哪些网址
User-agent: *Disallow: /user
Disallow: /*/user
- 但是这样有个问题,测试网站是需要全部禁止、正式网站只禁止几个网页,在robot.txt中无法识别测试还是正式,因此需要其他的灵活设置方式。可以使用
noindex
或者X-Robots-Tag
使用 noindex 阻止搜索引擎编入索引
// 为防止支持 noindex 规则的所有搜索引擎将您网站上的某个网页编入索引,并将以下 <meta> 标记添加到网页的 <head> 部分:
<meta name="robots" content="noindex">
// 若想仅阻止 Google 网页抓取工具将网页编入索引,请使用以下元标记:
<meta name="googlebot" content="noindex">
- 因此,综上,noindex方式将安置在测试网站的所有页面,而robot.txt记录正式网站中不希望被搜录的网址。
不想被搜索引擎收录的图片
从搜索结果中移除您网站上托管的图片
- 在 【编制索引-删除】的这个菜单中申请移除。(1天内受理,管用6个月)
- 然后使用使用 robots.txt 规则移除图片,比如:
User-agent: Googlebot-Image
Disallow: /images/dogs.jpg// 移除全部图片(测试环境之类的)
User-agent: Googlebot-Image
Disallow: /
- 更灵活的配置方式,设置响应头:X-Robots-Tag,这需要为每张图片配置上。当然最好的方式是直接不允许外网访问,这样就不用为每张图片配置了。
不过我们的图片一般存储在OSS上,我不了解,也不清楚怎么给OSS配置这个响应头。
X-Robots-Tag:"noindex, nofollow"
SEO规范网址
为重复的页面选择正确的规范网址
// 在想要规范合并的重复页面上增加这个标记头:
<link rel='canonical' href='' />
例如,在 /checkout1,/checkout2,/checkout3 页面中的 < head> 标签中添加以下标签:
<link rel="canonical" href="https://www.example.com/checkout" />
这样搜索引擎就会认为 /checkout 页面是主要页面,而 /checkout1、 /checkout2和 /checkout3 页面是重复内容,并且只会索引 /checkout 页面。
SEO结构化数据
结构化数据:在搜索引擎页面中展示出商品的简要信息,甚至包括产品简介、产品评分、产品图片等。
参考文档:结构化数据
<html><head><title>Executive Anvil</title><script type="application/ld+json">{"@context": "https://schema.org/","@type": "Product","name": "Executive 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","mpn": "925872","brand": {"@type": "Brand","name": "ACME"},"review": {"@type": "Review","reviewRating": {"@type": "Rating","ratingValue": "4","bestRating": "5"},"author": {"@type": "Person","name": "Fred Benson"}},"aggregateRating": {"@type": "AggregateRating","ratingValue": "4.4","reviewCount": "89"},"offers": {"@type": "Offer","url": "https://example.com/anvil","priceCurrency": "USD","price": "119.99","priceValidUntil": "2020-11-20","itemCondition": "https://schema.org/UsedCondition","availability": "https://schema.org/InStock"}}</script></head><body></body>
</html>