How do I make my page look good in Google Instant Previews?

跟風遠走 提交于 2019-12-12 07:30:10

问题


When you view a page from my site in Google Instant Previews, you see an AJAX error message (caused by some AJAX that fires on document ready):

I assume the way to fix this is to make my javascript compatible with whatever javascript engine Google's "browser" uses (like one might design for IE6).

So: what javascript does Google Instant Previews understand?


回答1:


Previews are generated in one of two ways:

  • Via normal Googlebot crawls
  • On the fly using the user-agent Mozilla/5.0 (en-us) AppleWebKit/525.13 (KHTML, like Gecko; Google Web Preview) Version/3.1 Safari/525.13

If the content has been crawled recently, it's likely to reuse the normal crawled content. If not, then it'll try to generate it on the fly. Internally, it uses a similar Safari/Webkit-based browser, so that's what you'd probably want to use to check your pages. I believe there's a way to modify the user-agent that Safari uses, which would be one way to do a more specific check.

If for some reason the AJAX content can't be fetched (say it's disallowed by robots.txt or the server actively blocks Googlebot from accessing it), then the site should fail gracefully (as it should when users run into the same problem). Don't show an error popup -- just log it internally and fall back to some default content.

One way to double-check if it works after you have made changes to your site's template is to do a site:-query to find similar, obscure pages, and to check their preview images; if nobody else has checked the preview images, it will be rendered on the fly so you will see the results right away. Once you're happy with how it renders, it will take a bit of time to catch up and re-render the existing pages; it doesn't update with the same frequency as cached pages or normal snippets do.




回答2:


Here is Google's description of the preview tool for users. Here is there Developer FAQs.




回答3:


It seems odd that your page tells the visitor that there was a JavaScript error in the first place. As a web user, I would be annoyed to get a pop-up because the AJAX failed. My suggestion would be to remove that pop-up and have your AJAX retry if there was an error.



来源:https://stackoverflow.com/questions/4151815/how-do-i-make-my-page-look-good-in-google-instant-previews

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!