How to exclude part of a web page from google's indexing?

馋奶兔 提交于 2019-12-23 08:07:32

问题


There's a way of excluding complete page(s) from google's indexing. But is there a way to specifically exclude certain part(s) of a web page from google's crawling? For example, exclude the side-bar which usually contains unrelated contents?


回答1:


You can include with an IFRAME tag the part of the page that you want hide at Googlebot and block the indexing of the file included from the robots.txt file.

add the iframe for include the side-bar in your page

<iframe src ="sidebar.asp" width="100%" height="300">
    </iframe>

here the rules to be added in the robots.txt file for block the spider

user-agent: *
disallow: sidebar.asp



回答2:


If you're doing this for AdSense, here's an article on how to exclude content from the scraper. If you don't want Google to follow links, you can give them a rel="nofollow" attribute. Otherwise, I'm afraid you may be out of luck here.

Something else you could do, but I wouldn't necessarily recommend doing, is detecting the user agent before rendering your page, and if it's a spider or bot, not showing the portions of your page you want to exclude.



来源:https://stackoverflow.com/questions/2004614/how-to-exclude-part-of-a-web-page-from-googles-indexing

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!