示例工程 40-seo-metadata

40-seo-metadata/demo-02-jsonld/index.html

html · 2.2 KB

运行:JSON-LD 演示

点击「运行示例」后,左侧显示源码、右侧显示运行结果;console 输出会实时回传。

<!doctype html>
<html lang="zh-CN">
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <title>JSON-LD 演示</title>
    <meta name="description" content="Article 与 BreadcrumbList 结构化数据示例。" />
    <script type="application/ld+json">
      {
        "@context": "https://schema.org",
        "@type": "Article",
        "headline": "JSON-LD 演示",
        "description": "Article 与 BreadcrumbList 结构化数据示例。",
        "author": { "@type": "Person", "name": "林小满" },
        "datePublished": "2026-11-28",
        "image": "https://example.com/og/demo.png",
        "mainEntityOfPage": "https://example.com/demo/"
      }
    </script>
    <script type="application/ld+json">
      {
        "@context": "https://schema.org",
        "@type": "BreadcrumbList",
        "itemListElement": [
          { "@type": "ListItem", "position": 1, "name": "首页", "item": "https://example.com/" },
          { "@type": "ListItem", "position": 2, "name": "教程", "item": "https://example.com/tutorials/" }
        ]
      }
    </script>
    <style>
      body { margin: 0; padding: 32px; background: #f8fafc; color: #0f172a; font-family: system-ui, sans-serif; line-height: 1.7; }
      .box { max-width: 720px; margin-bottom: 16px; padding: 18px; border: 1px solid #e2e8f0; border-radius: 12px; background: #fff; }
      h1 { margin: 0 0 16px; font-size: 28px; }
      h2 { margin: 0 0 8px; font-size: 17px; }
      p { margin: 0 0 10px; color: #334155; }
      pre { margin: 8px 0 0; padding: 12px; overflow-x: auto; border-radius: 8px; background: #0f172a; color: #e2e8f0; font-size: 12px; }
      code { padding: 1px 5px; border-radius: 4px; background: #f1f5f9; font-family: ui-monospace, monospace; }
    </style>
  </head>
  <body>
    <h1>JSON-LD</h1>

    <div class="box">
      <h2>Article</h2>
      <p>描述文章标题、作者、日期、图片与主页面。</p>
    </div>

    <div class="box">
      <h2>BreadcrumbList</h2>
      <p>描述面包屑层级与链接。</p>
      <pre>首页 → 教程 → 当前页</pre>
      <p>结构化数据必须与页面可见内容一致。</p>
    </div>
  </body>
</html>