Use a robots meta tag for HTML and the X-Robots-Tag header for everything else.
- Why
- The meta tag works only in HTML. PDFs, images and other files need the X-Robots-Tag HTTP header to carry the same noindex rule.
- Verify
- Check response headers for non-HTML files that should stay out of results, not only the HTML templates.
- Failure mode
- A downloads folder of PDFs is indexed because the noindex was only added to the HTML landing page.
- Sources
- Block Search indexing with noindex; Robots meta tag, data-nosnippet, and X-Robots-Tag specifications