2011-08-16 51 views
2

Google Plus會將您+1的網頁的小預覽列出您的所有+1。 Techcrunch和Mashable的預覽是作爲文章的第一句,但對我來說,它只需要頁面上的第一個HTML(在我的例子中是導航)。我如何才能將它定位到此預覽的文章而不是導航?如何獲取Google +1按鈕來預覽文章,而不是頁面頂部的HTML?

我已經瀏覽了API,並且找不到任何能夠完成我所說的事情。

回答

0

您需要使用itemprop標籤來告訴+1您要使用什麼。

有很多方法去做:

您可以添加以下代碼到你的HTML開始聲明:

<html itemscope itemtype="http://schema.org/Article"> 

,然後添加下列元描述:

<meta itemprop="name" content="Your article's title" /> 
<meta itemprop="description" content="Your article's description or excerpt" /> 

最後添加到您要使用的圖像:

<img itemprop="image" src="image.jpg" /> 
1

那麼,你有三種選擇來避免G +嘗試最佳猜測。

1)(首選)用微數據標記您的網站。請參閱http://schema.org以及Google網站站長工具幫助部分的微數據和Opera開發人員資源。

它看起來是這樣的:

<body itemscope itemtype="http://schema.org/Article"> 
    <h1 itemprop="name">Article Title</h1> <!-- snippet title --> 
    <img itemprop="image" src="image-url"></img> <!-- the snippet icon --> 
    <p itemprop="description">Snippet text.</p> 
</body> 

的想法是標記,你已經使用作爲基地,爲您的代碼段部分。雅虎,MS Bing,谷歌和其他一些搜索引擎將嘗試爲其搜索片段以及未來的瀏覽器版本(例如,爲書籤。 2)使用facebook開放圖譜協議(這是不是有效的HTML,但使您的片段與Facebook「股份」兼容)。

它看起來像(把這個在您的部分)

<meta property="og:title" content="Your snippet title"/> 
<meta property="og:image" content="url://of-your-snippet-image.jpeg"/> 
<meta property="og:description" content="Your snippet text goes here"/> 

3)設置標題和描述meta標籤。

<meta name="title" content="Your snippet title" /> 
<meta name="description" content="Your snippet text goes here"> 
相關問題