I would like to stop a few of my pages from showing up in search results. My understanding is that I add the following to the <head>
section of the page:
<meta name="robots" content="noindex,nofollow"/>
The problem is that my pages use a common Layout page. Something like:
@{
Layout = "~/Views/Shared/_VanillaLayout.cshtml";
}
Inside the layout page is the head section with a whole lot of links, scripts and meta tags. I don't want to duplicate this for indexable and non-indexable pages.
From my research I have found that: -
- Having multiple
<head>
sections is bad. - Having the robot meta tag outside of head is bad.
- Using robots.txt is more than I want and is bad.
- Trying to pass a model into the layout is a bit of an overkill (need all models to inherit from some base and many pages are purely presentation and don't even have a model) and is bad.
Hopefully, I am missing something and there is a good (non-bad) way to do this or one of the approaches I have mentioned above is not so bad after all.