我有一个通过 iframe 分布在某些网站上的小部件。但我不希望谷歌机器人索引该网址。在
nofollow
标签中添加 iframe
可以解决问题吗? Iframe
标签是否支持nofollow
,Google会理解吗?
当然,您可以将
rel="nofollow"
添加到 iframe。你一定很狡猾。这是如何...
建立一个空白的 html 文件。仅将您的 iframe 添加到其中。在元标记中包括
<meta name="robots" content="noindex,nofollow">
现在,将该页面嵌入到您要显示的页面上。
这是不可能的,但有一个解决方法。您可以使用重定向到 IFRAME 的域 URL。在您的 robots.txt 中,您将阻止机器人跟踪您的 URL 链接。
在您的 robots.txt 添加
User-agent:*
Disallow:/h/
然后,如果您使用其他东西(例如 nginx),请在 htaccess 中创建 301 重定向或类似的东西。这会将本地 URL 重定向到 Iframe 的 URL。
Redirect 301 /h/fancy-url/ http://targetdomain.com/the-uri-of-iframe/
在您的 iframe 中使用
<iframe src="https://yourdomain.com/h/fancy-url/?possibleparam=xx">
根据 W3C 规范,“rel”不是“iframe”标记的可识别属性。您可以使用一些 javascript 和 document.write 将 iframe 代码放置在页面上
您可能想检查一下 IFrame 是否被 Google 抓取? 但据我了解,iframe 上不允许“nofollow”
延迟加载有助于不索引 iframe
<iframe loading="lazy" src="xyz" />