In fact, Safari is not looking for the <link> or anything else. We can use two different things:
Both methods work very well, and you can use either of them or even both of them if you want to be sure.
Php
If we check the HTTP headers, we will see that when sending a Safari Top Sites Preview request, there is X_PURPOSE that is set to preview . Then you should write on a regular website:
if($_SERVER["HTTP_X_PURPOSE"]=="preview") { header("Location:thumbnail link");
And you can add to the page where there is a thumbnail:
if($_SERVER["HTTP_X_PURPOSE"]!="preview") { header("Location:normal link");
Thus, you will not be able to see the thumbnail except from the preview of Safari Top Sites.
Javascript
window.navigator.loadPurpose is preview if it is a Safari Top Sites Preview that is trying to open a website. But window.navigator does not exist if it is in the normal view. Thus, when you check this value, you need to check the very existence of this property, as well as its likelihood. Then this is the code for a regular website:
if(window.navigator&&window.navigator.loadPurpose==="preview") { window.location.href="thumbnail link";
And for the thumbnail page:
if(!window.navigator||window.navigator.loadPurpose!=="preview") { window.location.href="normal link";
A little trick from me :
If you really want to put the <link> tag you can write:
<link rel="safari-preview" href="thumbnail link" />
Then add the section at the end of the chapter:
<script>for(var i=0,link=document.getElementsByTagName("link"),l=link.length;i<l;i++)if(link[i].getAttribute("rel")==="safari-preview"&&window.navigator&&window.navigator.loadPurpose==="preview")window.location.href=link[i].getAttribute("href");</script>
Sources