挑選要分享的網站或 Facebook 專頁的網址。
將網址貼至代碼配置工具,然後調整分享按鈕的 layout。點擊 Get Code 按鈕,以產生您的分享按鈕代碼。
複製該代碼片段,然後貼至目標網站的 HTML。
複製該代碼範例,然後貼至您的網站。將 data-href 值調整為您網站的網址。接著使用 og:*** 中繼標籤調整您的連結預覽。og:url 和 data-href 應使用相同的網址。
<html>
<head>
<title>Your Website Title</title>
<!-- You can use Open Graph tags to customize link previews.
Learn more: https://developers.facebook.com/docs/sharing/webmasters -->
<meta property="og:url" content="https://www.your-domain.com/your-page.html" />
<meta property="og:type" content="website" />
<meta property="og:title" content="Your Website Title" />
<meta property="og:description" content="Your description" />
<meta property="og:image" content="https://www.your-domain.com/path/image.jpg" />
</head>
<body>
<!-- Load Facebook SDK for JavaScript -->
<div id="fb-root"></div>
<script>(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = "https://connect.facebook.net/en_US/sdk.js#xfbml=1&version=v3.0";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>
<!-- Your share button code -->
<div class="fb-share-button"
data-href="https://www.your-domain.com/your-page.html"
data-layout="button_count">
</div>
</body>
</html>| 設定 | HTML5 屬性 | 描述 | 預設 |
|---|---|---|---|
|
| 要分享的網頁絕對網址。 | XFBML 和 HTML5 版本會預設為目前的網址。 |
|
|
|
|
|
| 從多款版面中選擇適用於附加程式的配置。可以是 |
|
mobile_iframe已停用項目 | data-mobile_iframe | true,分享按鈕會在流動網站上方的 iframe (而非彈出式視窗)開啟分享對話框。此選項只適用於流動版,不適用桌面版。如需更多詳細資訊,請參閱流動版網頁分享對話框。 | false |
|
| 按鈕共有 2 種尺寸: |
|