Metatags For Dynamic Search Results Pages
Metatags For Dynamic Search Results Pages
Where can we put the <noindex> metatag for the dynamically-generated search results pages? Google keeps indexing our search results pages. Thank you!
Re: Metatags For Dynamic Search Results Pages
You can add an entry to the robots.txt file (inside website root directory) to prevent search result page from indexing.
Locate the following
and replace with the below code (if your search results page becomes something like /search.aspx?k=somekeyword)
Locate the following
Code: Select all
Disallow: /BuyProduct.ashx
Code: Select all
Disallow: /BuyProduct.ashx
Disallow: /?k=
Re: Metatags For Dynamic Search Results Pages
Thanks, we have tried that and it seems that more search strings keep coming up, such as /?c=, /?m=, etc. Google doesn't like seeing a large robots.txt file, so we were trying to follow Google's recommendation of adding the <noindex> metatag,
Re: Metatags For Dynamic Search Results Pages
Ok. Then you can add the meta tag dynamically to the specific pages you don't want to index. Put the following code to the Page_Load method
You also have to add the following using statement at the top of the page.
Code: Select all
// ADD NOINDEX META TAG TO PREVENT BROWSERS FROM INDEXING THE PAGE
HtmlMeta keyword = new HtmlMeta();
keyword.Name = "robots";
keyword.Content = "noindex";
Page.Header.Controls.Add(keyword);
Code: Select all
using System.Web.UI.HtmlControls;
Re: Metatags For Dynamic Search Results Pages
Thank you for the help. As I will be the one having to input the code, please let me know if this should go into the Search.aspx / Search.aspx.cs files.
Rick Morris
Brewhaus (America) Inc.
Hot Sauce Depot
Brewhaus (America) Inc.
Hot Sauce Depot
Re: Metatags For Dynamic Search Results Pages
This will go into the search.aspx.cs file's Page_Load method. You can do something like this:
Locate
and replace with
Locate
Code: Select all
BindSearchResultsPanel();
Code: Select all
// ADD NOINDEX META TAG TO PREVENT BROWSERS FROM INDEXING THE PAGE
HtmlMeta keyword = new HtmlMeta();
keyword.Name = "robots";
keyword.Content = "noindex";
Page.Header.Controls.Add(keyword);
BindSearchResultsPanel();
Re: Metatags For Dynamic Search Results Pages
Perfect. Thank you so much for your help! 

Rick Morris
Brewhaus (America) Inc.
Hot Sauce Depot
Brewhaus (America) Inc.
Hot Sauce Depot