<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:media="http://search.yahoo.com/mrss/">
  <channel>
    <title>Open Graph｜林鼎淵 Dean Lin</title>
    <link>https://deanlin.net/tags/open-graph/</link>
    <image><url>https://deanlin.net/images/author_hu_aa256fc934e9a932.jpg</url><title>Open Graph｜林鼎淵 Dean Lin</title><link>https://deanlin.net/tags/open-graph/</link><width>144</width><height>144</height></image>
    <description>林鼎淵（Dean Lin）的部落格：生成式 AI 企業內訓講師、外商資安公司軟體專家、7 本書作者。400 多篇文章用白話分享生成式 AI 實戰、Claude Code 與 Vibe Coding 教學、團隊合作與職場成長。</description>
    <generator>Hugo</generator>
    <language>zh-tw</language>
    <copyright>© 2020–2026 林鼎淵 Dean Lin</copyright>
    <lastBuildDate>Fri, 22 Jan 2021 16:22:50 +0800</lastBuildDate>
    <atom:link href="https://deanlin.net/tags/open-graph/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>什麼是 OG ? 別讓分享的連結看起來是詐騙網站啊!</title>
      <link>https://deanlin.net/blog/202101/what-is-open-graph/</link>
      <pubDate>Fri, 22 Jan 2021 16:22:50 +0800</pubDate>
      <guid>https://deanlin.net/blog/202101/what-is-open-graph/</guid>
      <dc:creator>林鼎淵</dc:creator>
      <category>技術教學</category>
      <description>大家在滑 FB 時常常會看到一些縮圖詭異的分享連結，或著是沒有縮圖跟介紹長得像是詐欺網頁的連結，今天我們就從技術的角度來了解這些連結到底發生了什麼事，同時檢視自己的網頁有沒有犯一樣的錯誤。</description>
      <media:content url="https://deanlin.net/blog/202101/what-is-open-graph/images/what-is-open-graph-og_hu_b6cd824ee1a44cf3.jpg" medium="image" type="image/jpeg" width="1200" height="675" />
      <content:encoded><![CDATA[<p>大家在滑 FB 時常常會看到一些縮圖詭異的分享連結，或著是沒有縮圖跟介紹長得像是詐欺網頁的連結，今天我們就從技術的角度來了解這些連結到底發生了什麼事，同時檢視自己的網頁有沒有犯一樣的錯誤。</p>
<p><img src="https://deanlin.net/blog/202101/what-is-open-graph/images/what-is-open-graph-01.webp" width="1400" height="738" alt="什麼是 OG ? 別讓分享的連結看起來是詐騙網站啊!（圖 1）" fetchpriority="high" decoding="async"></p>
<pre tabindex="0"><code>您將在本篇文章中獲取以下知識：
前言：了解元兇 OG 是什麼？
一、看看 OG 從沒設定到完整設定給人的感覺吧
二、OG 怎麼設定呢？
三、使用官方工具預覽連結畫面
四、不可不知的注意事項
</code></pre><h2 id="前言了解元兇-og-是什麼">前言：了解元兇 OG 是什麼？<a class="h-anchor" href="#%e5%89%8d%e8%a8%80%e4%ba%86%e8%a7%a3%e5%85%83%e5%85%87-og-%e6%98%af%e4%bb%80%e9%ba%bc" aria-label="這個段落的連結"></a></h2>
<p>OG 全名 Open Graph Protocol，由 Facebook 提出，目的在於透過定義網站性質、Title、縮圖網址等等屬性，如果沒設定就是隨機產生的結果，這就是為什麼你看到很多詭異縮圖的原因。</p>
<h2 id="一看看-og-從沒設定到完整設定給人的感覺吧">一、看看 OG 從沒設定到完整設定給人的感覺吧<a class="h-anchor" href="#%e4%b8%80%e7%9c%8b%e7%9c%8b-og-%e5%be%9e%e6%b2%92%e8%a8%ad%e5%ae%9a%e5%88%b0%e5%ae%8c%e6%95%b4%e8%a8%ad%e5%ae%9a%e7%b5%a6%e4%ba%ba%e7%9a%84%e6%84%9f%e8%a6%ba%e5%90%a7" aria-label="這個段落的連結"></a></h2>
<blockquote>
<p>讀者可以把連結貼上 FB 建立貼文的地方來看看結果喔</p>
</blockquote>
<ol>
<li>如果完全沒設定 OG，你分享的連結根本沒人知道內容是什麼</li>
</ol>
<figure class="figure"><img src="https://deanlin.net/blog/202101/what-is-open-graph/images/what-is-open-graph-02.webp" width="552" height="338" alt="什麼是 OG ? 別讓分享的連結看起來是詐騙網站啊!（圖 1）" loading="lazy" decoding="async">
  <figcaption><a href="https://dean9703111.github.io/open_graph_sample/none_open_graph.html">https://dean9703111.github.io/open_graph_sample/none_open_graph.html</a></figcaption>
</figure>

<p>2. 只設定標題就會有懷舊的詐騙網站既視感</p>
<figure class="figure"><img src="https://deanlin.net/blog/202101/what-is-open-graph/images/what-is-open-graph-03.webp" width="552" height="338" alt="什麼是 OG ? 別讓分享的連結看起來是詐騙網站啊!（圖 2）" loading="lazy" decoding="async">
  <figcaption><a href="https://dean9703111.github.io/open_graph_sample/only_title.html">https://dean9703111.github.io/open_graph_sample/only_title.html</a></figcaption>
</figure>

<p>3. 有了標題跟描述後就給人多一點安心的錯覺</p>
<figure class="figure"><img src="https://deanlin.net/blog/202101/what-is-open-graph/images/what-is-open-graph-04.webp" width="552" height="338" alt="什麼是 OG ? 別讓分享的連結看起來是詐騙網站啊!（圖 3）" loading="lazy" decoding="async">
  <figcaption><a href="https://dean9703111.github.io/open_graph_sample/title_description.html">https://dean9703111.github.io/open_graph_sample/title_description.html</a></figcaption>
</figure>

<p>4. 加上縮圖後網站的專業感直線上升</p>
<figure class="figure"><img src="https://deanlin.net/blog/202101/what-is-open-graph/images/what-is-open-graph-05.webp" width="1104" height="836" alt="什麼是 OG ? 別讓分享的連結看起來是詐騙網站啊!（圖 4）" loading="lazy" decoding="async">
  <figcaption><a href="https://dean9703111.github.io/open_graph_sample/small_thumbnail.html">https://dean9703111.github.io/open_graph_sample/small_thumbnail.html</a></figcaption>
</figure>

<p>5. 依據不同的業務需求，在了解 OG 如何設定後你可以決定要使用大縮圖還是小縮圖</p>
<figure class="figure"><img src="https://deanlin.net/blog/202101/what-is-open-graph/images/what-is-open-graph-06.webp" width="552" height="556" alt="什麼是 OG ? 別讓分享的連結看起來是詐騙網站啊!（圖 5）" loading="lazy" decoding="async">
  <figcaption><a href="https://dean9703111.github.io/open_graph_sample/big_thumbnail.html">https://dean9703111.github.io/open_graph_sample/big_thumbnail.html</a></figcaption>
</figure>

<h2 id="二og-怎麼設定呢">二、OG 怎麼設定呢？<a class="h-anchor" href="#%e4%ba%8cog-%e6%80%8e%e9%ba%bc%e8%a8%ad%e5%ae%9a%e5%91%a2" aria-label="這個段落的連結"></a></h2>
<p>設定上真的毫無難度，先了解每個參數的含義</p>
<div class="highlight"><pre tabindex="0" style="color:#e6edf3;background-color:#0d1117;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"><code class="language-html" data-lang="html"><span style="display:flex;"><span>&lt;<span style="color:#7ee787">head</span>&gt;
</span></span><span style="display:flex;"><span>    &lt;<span style="color:#7ee787">meta</span> property<span style="color:#ff7b72;font-weight:bold">=</span><span style="color:#a5d6ff">&#34;og:url&#34;</span> content<span style="color:#ff7b72;font-weight:bold">=</span><span style="color:#a5d6ff">&#34;你的網址&#34;</span>/&gt;
</span></span><span style="display:flex;"><span>    &lt;<span style="color:#7ee787">meta</span> property<span style="color:#ff7b72;font-weight:bold">=</span><span style="color:#a5d6ff">&#34;og:locale&#34;</span> content<span style="color:#ff7b72;font-weight:bold">=</span><span style="color:#a5d6ff">&#34;網站語系，ex:zh_TW&#34;</span> /&gt;
</span></span><span style="display:flex;"><span>    &lt;<span style="color:#7ee787">meta</span> property<span style="color:#ff7b72;font-weight:bold">=</span><span style="color:#a5d6ff">&#34;og:type&#34;</span> content<span style="color:#ff7b72;font-weight:bold">=</span><span style="color:#a5d6ff">&#34;類型，ex：website&#34;</span> /&gt;
</span></span><span style="display:flex;"><span>    &lt;<span style="color:#7ee787">meta</span> property<span style="color:#ff7b72;font-weight:bold">=</span><span style="color:#a5d6ff">&#34;og:title&#34;</span> content<span style="color:#ff7b72;font-weight:bold">=</span><span style="color:#a5d6ff">&#34;文章的標題&#34;</span> /&gt;
</span></span><span style="display:flex;"><span>    &lt;<span style="color:#7ee787">meta</span> property<span style="color:#ff7b72;font-weight:bold">=</span><span style="color:#a5d6ff">&#34;og:description&#34;</span> content<span style="color:#ff7b72;font-weight:bold">=</span><span style="color:#a5d6ff">&#34;內容的簡短說明&#34;</span>/&gt;
</span></span><span style="display:flex;"><span>    &lt;<span style="color:#7ee787">meta</span> property<span style="color:#ff7b72;font-weight:bold">=</span><span style="color:#a5d6ff">&#34;og:image&#34;</span> content<span style="color:#ff7b72;font-weight:bold">=</span><span style="color:#a5d6ff">&#34;縮圖圖片連結&#34;</span> /&gt;
</span></span><span style="display:flex;"><span>    &lt;<span style="color:#7ee787">meta</span> property<span style="color:#ff7b72;font-weight:bold">=</span><span style="color:#a5d6ff">&#34;og:image:type&#34;</span> content<span style="color:#ff7b72;font-weight:bold">=</span><span style="color:#a5d6ff">&#34;圖像的 MIME 類型，可為 image/jpeg、image/gif 或 image/png&#34;</span> /&gt;
</span></span><span style="display:flex;"><span>    &lt;<span style="color:#7ee787">meta</span> property<span style="color:#ff7b72;font-weight:bold">=</span><span style="color:#a5d6ff">&#34;og:image:width&#34;</span> content<span style="color:#ff7b72;font-weight:bold">=</span><span style="color:#a5d6ff">&#34;縮圖 width&#34;</span> /&gt;
</span></span><span style="display:flex;"><span>    &lt;<span style="color:#7ee787">meta</span> property<span style="color:#ff7b72;font-weight:bold">=</span><span style="color:#a5d6ff">&#34;og:image:height&#34;</span> content<span style="color:#ff7b72;font-weight:bold">=</span><span style="color:#a5d6ff">&#34;縮圖 height&#34;</span> /&gt;
</span></span><span style="display:flex;"><span>&lt;/<span style="color:#7ee787">head</span>&gt;
</span></span></code></pre></div><p class="code-source">原始碼：<a href="https://gist.github.com/dean9703111/426c9f892768a2962c15606100154343.js" rel="noopener">og.html</a>（GitHub Gist）</p>
<p>瞭解參數函義後填上自己的資訊就好嚕，完整範例如下</p>
<div class="highlight"><pre tabindex="0" style="color:#e6edf3;background-color:#0d1117;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"><code class="language-html" data-lang="html"><span style="display:flex;"><span>&lt;<span style="color:#7ee787">head</span>&gt;
</span></span><span style="display:flex;"><span>    &lt;<span style="color:#7ee787">meta</span> property<span style="color:#ff7b72;font-weight:bold">=</span><span style="color:#a5d6ff">&#34;og:url&#34;</span> content<span style="color:#ff7b72;font-weight:bold">=</span><span style="color:#a5d6ff">&#34;https://github.com/dean9703111/open_graph_sample&#34;</span> /&gt;
</span></span><span style="display:flex;"><span>    &lt;<span style="color:#7ee787">meta</span> property<span style="color:#ff7b72;font-weight:bold">=</span><span style="color:#a5d6ff">&#34;og:locale&#34;</span> content<span style="color:#ff7b72;font-weight:bold">=</span><span style="color:#a5d6ff">&#34;zh_TW&#34;</span> /&gt;
</span></span><span style="display:flex;"><span>    &lt;<span style="color:#7ee787">meta</span> property<span style="color:#ff7b72;font-weight:bold">=</span><span style="color:#a5d6ff">&#34;og:type&#34;</span> content<span style="color:#ff7b72;font-weight:bold">=</span><span style="color:#a5d6ff">&#34;website&#34;</span> /&gt;
</span></span><span style="display:flex;"><span>    &lt;<span style="color:#7ee787">meta</span> property<span style="color:#ff7b72;font-weight:bold">=</span><span style="color:#a5d6ff">&#34;og:description&#34;</span> content<span style="color:#ff7b72;font-weight:bold">=</span><span style="color:#a5d6ff">&#34;相對於小縮圖而言，大縮圖能顯示的文字量是比較少的，所以圖片上的資訊更加重要&#34;</span> /&gt;
</span></span><span style="display:flex;"><span>    &lt;<span style="color:#7ee787">meta</span> property<span style="color:#ff7b72;font-weight:bold">=</span><span style="color:#a5d6ff">&#34;og:title&#34;</span> content<span style="color:#ff7b72;font-weight:bold">=</span><span style="color:#a5d6ff">&#34;大縮圖分享連結&#34;</span> /&gt;
</span></span><span style="display:flex;"><span>    &lt;<span style="color:#7ee787">meta</span> property<span style="color:#ff7b72;font-weight:bold">=</span><span style="color:#a5d6ff">&#34;og:image:type&#34;</span> content<span style="color:#ff7b72;font-weight:bold">=</span><span style="color:#a5d6ff">&#34;image/png&#34;</span> /&gt;
</span></span><span style="display:flex;"><span>    &lt;<span style="color:#7ee787">meta</span> property<span style="color:#ff7b72;font-weight:bold">=</span><span style="color:#a5d6ff">&#34;og:image&#34;</span>
</span></span><span style="display:flex;"><span>		content<span style="color:#ff7b72;font-weight:bold">=</span><span style="color:#a5d6ff">&#34;https://github.com/dean9703111/open_graph_sample/blob/master/img/big_thumbnail.png?raw=true&#34;</span> /&gt;
</span></span><span style="display:flex;"><span>    &lt;<span style="color:#7ee787">meta</span> property<span style="color:#ff7b72;font-weight:bold">=</span><span style="color:#a5d6ff">&#34;og:image:width&#34;</span> content<span style="color:#ff7b72;font-weight:bold">=</span><span style="color:#a5d6ff">&#34;1400&#34;</span> /&gt;
</span></span><span style="display:flex;"><span>    &lt;<span style="color:#7ee787">meta</span> property<span style="color:#ff7b72;font-weight:bold">=</span><span style="color:#a5d6ff">&#34;og:image:height&#34;</span> content<span style="color:#ff7b72;font-weight:bold">=</span><span style="color:#a5d6ff">&#34;770&#34;</span> /&gt;
</span></span><span style="display:flex;"><span>&lt;/<span style="color:#7ee787">head</span>&gt;
</span></span></code></pre></div><p class="code-source">原始碼：<a href="https://gist.github.com/dean9703111/147652b9c82fdae08457c890ea5c4a63" rel="noopener">og_complete.html</a>（GitHub Gist）</p>
<blockquote>
<p>如果你想要更深入的了解FB對這塊的定義請參考他們<a href="https://developers.facebook.com/docs/sharing/webmasters?locale=zh_TW">給網站管理員的分享功能指南</a></p>
</blockquote>
<h2 id="三使用官方工具預覽連結畫面">三、使用官方工具預覽連結畫面<a class="h-anchor" href="#%e4%b8%89%e4%bd%bf%e7%94%a8%e5%ae%98%e6%96%b9%e5%b7%a5%e5%85%b7%e9%a0%90%e8%a6%bd%e9%80%a3%e7%b5%90%e7%95%ab%e9%9d%a2" aria-label="這個段落的連結"></a></h2>
<ol>
<li>網頁設定完成後，使用 <a href="https://developers.facebook.com/tools/debug/">FB 提供的工具</a> 來做檢查</li>
<li>貼上自己的網址按下偵錯就能看到預覽嚕</li>
</ol>
<p><img src="https://deanlin.net/blog/202101/what-is-open-graph/images/what-is-open-graph-07.webp" width="1145" height="898" alt="三、使用官方工具預覽連結畫面（圖 7）" loading="lazy" decoding="async"></p>
<p>3. 如果發現顯示結果跟預期的不一樣，請觀看<code>應處理的警告</code></p>
<p><img src="https://deanlin.net/blog/202101/what-is-open-graph/images/what-is-open-graph-08.webp" width="1145" height="737" alt="三、使用官方工具預覽連結畫面（圖 8）" loading="lazy" decoding="async"></p>
<p>4. 處理完警告後就能看到美美的預覽圖嚕(fb:app_id可忽略)</p>
<p><img src="https://deanlin.net/blog/202101/what-is-open-graph/images/what-is-open-graph-09.webp" width="1145" height="871" alt="三、使用官方工具預覽連結畫面（圖 9）" loading="lazy" decoding="async"></p>
<p>5. 如果發現設定都改了，為什麼預覽圖都還是有問題的化，請按<code>再次抓取</code></p>
<p><img src="https://deanlin.net/blog/202101/what-is-open-graph/images/what-is-open-graph-10.webp" width="1145" height="493" alt="三、使用官方工具預覽連結畫面（圖 10）" loading="lazy" decoding="async"></p>
<h2 id="四不可不知的注意事項">四、不可不知的注意事項<a class="h-anchor" href="#%e5%9b%9b%e4%b8%8d%e5%8f%af%e4%b8%8d%e7%9f%a5%e7%9a%84%e6%b3%a8%e6%84%8f%e4%ba%8b%e9%a0%85" aria-label="這個段落的連結"></a></h2>
<h3 id="-fb-分享連結有分成大圖及小圖比例如下">FB 分享連結有分成大圖及小圖，比例如下<a class="h-anchor" href="#-fb-%e5%88%86%e4%ba%ab%e9%80%a3%e7%b5%90%e6%9c%89%e5%88%86%e6%88%90%e5%a4%a7%e5%9c%96%e5%8f%8a%e5%b0%8f%e5%9c%96%e6%af%94%e4%be%8b%e5%a6%82%e4%b8%8b" aria-label="這個段落的連結"></a></h3>
<ul>
<li>0 x 0 ~ 199 x 199 抓不到圖</li>
<li>200 x 200 ~ 599 x 314 小圖</li>
<li>600 x 315 ~ 1500 x 1500 大圖</li>
<li>1501 x 1501 以上 小圖</li>
</ul>
<h3 id="-特殊規則">特殊規則<a class="h-anchor" href="#-%e7%89%b9%e6%ae%8a%e8%a6%8f%e5%89%87" aria-label="這個段落的連結"></a></h3>
<ul>
<li>超過 1500 x 1500 會變成小圖喔！！！(之前我卡了很久)</li>
<li>圖片大小不可超過 5MB 喔！</li>
<li>有時圖片頻繁改動時 FB 會抓不到正確的檔案(就算用再次抓取也無效)，這時變更一下圖片的檔名就能解決</li>
</ul>
]]></content:encoded>
    </item>
  </channel>
</rss>
