讓使用者能一鍵把內容分享到各平台,是提升曝光最直接的方式。以下整理二十個常見平台的分享連結寫法,可分為「固定網址型」與「動態抓取型」兩類。
<a href="https://v.t.sina.com.cn/share/share.php?url=https://www.jb51.net&title='分享內容'" target="_blank">新浪微博</a>
<a href="https://v.t.qq.com/share/share.php?url=https://www.jb51.net&title='分享內容'" target="_blank">騰訊微博</a>
<a href="https://www.kaixin001.com/repaste/share.php?rurl=https://www.jb51.net&rcontent=https://www.baidu.com&rtitle=kaixin" target="_blank">開心網</a>
<a href="https://www.douban.com/recommend/?url=https://www.jb51.net&title=douban" target="_blank">豆瓣</a>
<a href="https://share.renren.com/share/buttonshare.do?link=https://www.jb51.net" target="_blank">人人網</a>
<a href="https://tieba.baidu.com/f/commit/share/openShareApi?url=https://www.jb51.net&title=hello&desc=&pic=" target="_blank">百度貼吧</a>
<a href="https://connect.qq.com/widget/shareqq/index.html?title=qqhaoyou&url=https://www.jb51.net&desc=還不錯哦&pics=&site=優酷" target="_blank">QQ 好友</a>
<a href="https://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?url=https://www.jb51.net" target="_blank">QQ 空間</a>
<a href="https://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?to=pengyou&url=https://www.jb51.net" target="_blank">騰訊朋友</a>
<a href="https://i.youku.com/u/share/?url=https://www.jb51.net&content='分享內容'" target="_blank">優酷空間</a>
<a href="https://t.sohu.com/third/post.jsp?content=utf-8&url=https://www.jb51.net&title=souhu" target="_blank">搜狐微博</a>
<a href="https://profile.live.com/badge/?url=https://www.jb51.net&Title=msn" target="_blank">MSN</a>
<a href="https://tt.mop.com/share/shareV.jsp?title=moptietie&pageUrl=https://www.jb51.net" target="_blank">MOP 貼貼</a>
<a href="https://t.163.com/article/user/checkLogin.do?link=https://www.jb51.net" target="_blank">網易微博</a>
這類寫法用 JavaScript 即時取得 document.location.href 與 document.title,不需要為每篇文章手動改參數,適合套用在共用模板上。
<a href="javascript:window.open('https://cang.baidu.com/do/add?it='+encodeURIComponent(document.title.substring(0,76))
+'&iu='+encodeURIComponent(location.href)+'&fr=ien#nw=1',
'scrollbars=no,width=600,height=450,left=75,top=20,status=no,resizable=yes'); void 0">百度搜藏</a>
<a href="javascript:window.open('https://shuqian.qq.com/post?from=3&title='+encodeURIComponent(document.title)
+'&uri='+encodeURIComponent(document.location.href)+'&jumpback=2&noui=1',
'favit','width=930,height=470,left=50,top=50,toolbar=no,menubar=no,location=no,scrollbars=yes,status=yes,resizable=yes'); void 0">QQ 書籤</a>
<a href="javascript:window.open('https://www.google.com/bookmarks/mark?op=add&bkmk='
+encodeURIComponent(document.location.href)+'&title='+encodeURIComponent(document.title)); void 0">Google</a>
<a href="javascript:window.open('https://twitter.com/home?status='
+encodeURIComponent(document.location.href)+' '+encodeURIComponent(document.title)); void 0">Twitter</a>
<a class="fav_facebook" rel="nofollow"
href="javascript:window.open('https://www.facebook.com/sharer.php?u='
+encodeURIComponent(document.location.href)+'&t='+encodeURIComponent(document.title)); void 0">Facebook</a>
<a href="javascript:window.open('https://del.icio.us/post?url='
+encodeURIComponent(document.location.href)+'&title='+encodeURIComponent(document.title)+'¬es='); void 0">Delicious</a>
這份清單中的多數平台(騰訊微博、開心網、人人網、貓撲、MSN、Delicious、Google 書籤等)服務已相繼停止或轉型,連結實際上已失效。今日若要在網站上加分享功能,合理的做法有兩種:
一、接入官方 SDK。Facebook 的 Share Button、X(Twitter)的 Web Intent、LINE 的分享 API 都提供現成的按鈕與參數規範,穩定且會隨平台更新維護。
二、使用第三方分享服務。像是百度分享、AddThis、ShareThis 這類服務,一次整合就能覆蓋大量平台,且相容性較好,不必逐一追蹤各家 API 變動。
另外提醒,若使用 javascript: 標籤,請注意它會被部分瀏覽器的安全政策阻擋,且對無障礙輔具不友善。較好的做法是把 href 設為真實網址,再用 JS 加上 target="_blank" 與 rel="noopener noreferrer"——最後這個屬性很重要,可避免新視窗透過 window.opener 反向操作你的頁面。