跳至主要內容

    JSON-LD

    JSON-LD 是結構化資料格式,讓搜尋引擎與答案引擎更容易理解你的內容與實體關係(Schema.org)。

    定義

    JSON-LD(JavaScript Object Notation for Linked Data)是一種把結構化資料以 JSON 形式嵌入網頁的方式,通常用於 Schema.org 標記(Organization、WebSite、Article、FAQPage…),幫助搜尋引擎理解內容語意與實體關係。

    為什麼重要

    • 提升搜尋引擎理解度,增加 Rich Results/摘要顯示機會
    • 讓答案引擎更容易抽取可引用的資訊(AEO)
    • 比 microdata 更好維護:不會污染 HTML 結構
    • Google 明確表示偏好 JSON-LD 格式
    • 可以描述頁面外的實體(例如作者、組織)
    • 支援巢狀結構和實體間關係(@id 引用)
    • 容易用程式動態產生,適合 pSEO 場景

    怎麼做(實作重點)

    • 把 JSON-LD 放進 <script type="application/ld+json">
    • 內容要與頁面可見內容一致(FAQ/HowTo 特別重要)
    • 用工具驗證(Schema Validator / Google Rich Results Test)
    • 不要把多個不相干的 schema 硬塞在同一頁
    • 使用 @id 建立實體間引用關係
    • 優先實作 Google 支援的 schema 類型
    • 保持 JSON 語法正確(逗號、引號、跳脫字元)

    範例

    html
    <script type="application/ld+json">
    {
      "@context": "https://schema.org",
      "@type": "Organization",
      "@id": "https://example.com/#organization",
      "name": "Developer SEO Hub",
      "url": "https://example.com",
      "logo": "https://example.com/logo.png",
      "sameAs": [
        "https://twitter.com/devseo",
        "https://github.com/devseo"
      ]
    }
    </script>
    typescript
    // 動態產生 Article JSON-LD
    interface ArticleSchema {
      title: string;
      description: string;
      author: string;
      publishDate: string;
      url: string;
    }
    
    function generateArticleJsonLd(article: ArticleSchema): string {
      const schema = {
        '@context': 'https://schema.org',
        '@type': 'Article',
        headline: article.title,
        description: article.description,
        author: {
          '@type': 'Person',
          name: article.author
        },
        datePublished: article.publishDate,
        mainEntityOfPage: article.url
      };
      return JSON.stringify(schema);
    }

    相關連結

    常見問題

    關於這個詞彙的常見問答。

    回到詞彙表