404 for resources based on specific template

Hi everyone. I have some resources that should not be indexed. They are not in the sitemap, but Google still finds and indexes them. How can I generate a 404 error based on the template of such resources?
Tell me the right ways of implementation. Thank you in advance!

Add this in the head section of the sites you don’t want to get indexed:
<meta name="robots" content="noindex">

or put the URLs in a robots.txt file

To kick these sites out of the index you could try the Google SearchConsole and submit a removal entry there.


This topic was automatically closed 2 days after discussion ended and a solution was marked. New replies are no longer allowed. You can open a new topic by clicking the link icon below the original post or solution and selecting “+ New Topic”.