简体   繁体   中英

Proving noscript website content for hashbang URL

Lately Google announced it will be rolling out support for _escape_fragment. It was a feature Google used to get "static" content of website if it had hashbang (#!) in URL.

So now Google advices to provide along with JS version of website a static, non JS version for users with no JS and for Google bots in the same manner.

So when person visits for example website test.com/#!/item/2

I should generate a JS version of website and in noscript tag a non-JS version. Ok.

But since hashbang is not sent to server how should i know that i need generate a static website for item 2?

So my question is: how to provide static content for no-JS users in hashbang url scheme website.

You can't, but that isn't what Google is saying.

Instead of using hashbangs , you should use pushState and the rest of the History API .

That will let you have URLs like http://test.com/item/2 .

If someone visits http://test.com/item/2 then your server should generate the page in the state it would be in if they had visited http://test.com/item/1 and then triggered the JavaScript event that would convert it into http://test.com/item/2 .

No need to use noscript at all.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM