问题原文
原帖链接 · Yoga · CC BY-SA 3.0
Are there any harms if my site send NOINDEX headers for all my static assets?
For image files, I refer to those valueless, e.g. background images, button images, etc.
Update: more background information
I have this concern is since recent Google said they also execute JS and they might fetch content via Ajax. So, for example, if I send noindex for my jQuery script, so Google would not be able to use them to load Ajax, I suppose it is not good for my site's SEO, right?
社区高分解答
原帖链接 · John Mueller · CC BY-SA 4.0
(I work with Google's crawling & indexing teams) - deleted most of the old answer :).
Three things:
In general, JS & CSS files don't appear in normal search results, rarely even if you explicitly look for them with a
site:-query. So probably this is a non-issue nowadays.If you do find non-HTML content from your site indexed (and don't want it), and it's ranking for normal queries that users make instead of your normal HTML pages, then you should fix the HTML pages first. If a CSS file is seen as being more relevant than your actual content, then the problem is not the CSS file.
If after all of this, you still want to get those non-HTML files out of the search results, use the
x-robots-tagHTTP header withnoindex. The reference docs have all the details. This is a server-side header that you have to set, sometimes you can do it on a CDN too.
Let's start with the easy one: assuming you don't want these files used for indexing at all, you can just use the robots.txt file to disallow crawling of the scripts and responses. This prevents Googlebot from accessing the URLs, and would of course also prevent it from using them for anything else. The URLs themselves may be indexed (just as the URL based on factors like links to the URLs, without having been crawled), but they can't be processed or executed. Our robots.txt reference has more specifics for those who love details.
On the other hand, if you do want the content (and potentially the responses, etc) indexed: We recommend not using the noindex x-robots-tag HTTP header for embedded content (JavaScript, CSS, responses, etc.) if you'd like it potentially used for indexing. For example, if a JavaScript file uses an AJAX request to retrieve content from your server which is then displayed, all of those elements would first need to be crawlable (not disallowed by the robots.txt file), and we recommend that they aren't served with a "noindex" x-robots-tag HTTP header. We can't guarantee that we'll be able to process & index all JavaScript, but our systems are getting better and better over time.
In general, most sites don't link to their JavaScript or CSS files using normal HTML links, they just reference them within their HTML files. Because of that, for the most part we won't index those files separately anyway (and even if we did, your website most likely has more relevant content than what we find in the JavaScript files :)).
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
