htmlasp.netuser-controlsmeta-tagsgooglebot

Stop user control being indexed


To comply with the cookies law, I have created a user control that gets added to various pages in asp.net . The user control basically is the cookie message that appears in a div. The problem is that google and other search engines are indexing the user control and now the cookie message appears on search results. I attempted to stop this by applying meta data in the user control itself.

<meta name="robots" content="noindex"/>

However this has stopped google indexing most of the site where all I wanted was to stop the user control from being indexed. Is this possible?


Solution

  • There isn't a way to stop a user control getting indexed since it forms part of a page. You are right, having the meta tag to stop indexing will have a detrimental effect on how your site is indexed.

    Why not take a different approach such as having a page on your site detailing the cookie policy with a link on a sub navigation or showing a popup via JavaScript, e.g. http://www.cookieconsent.com/?

    If you went the JavaScript root, you could dynamically pull in your cookie policy text using jQuery AJAX to populate the HTML you would like to show the message on page load. Since the HTML will be populated via AJAX, Google won't index this content.